tlasica commented on a change in pull request #117:
URL: https://github.com/apache/cassandra-dtest/pull/117#discussion_r570857344
##########
File path: bootstrap_test.py
##########
@@ -280,6 +280,55 @@ def
test_consistent_range_movement_true_with_rf1_should_fail(self):
def test_consistent_range_movement_false_with_rf1_should_succeed(self):
self._bootstrap_test_with_replica_down(False, rf=1)
+ def test_rf_gt_nodes_multidc_should_succeed(self):
+ """
+ Test creating a KS with RF > N on multi DC doesn't break bootstrap
+ @jira_ticket CASSANDRA-16296 CASSANDRA-16411
+ """
+ cluster = self.cluster
+
cluster.set_environment_variable('CASSANDRA_TOKEN_PREGENERATION_DISABLED',
'True')
+ cluster.populate([1, 1])
+ cluster.start()
+
+ node1 = cluster.nodelist()[0]
+ session = self.patient_cql_connection(node1)
+ session.execute("CREATE KEYSPACE k WITH REPLICATION = {'class' :
'NetworkTopologyStrategy', 'dc1' : '3'}")
+ warning = 'Your replication factor 3 for keyspace k is higher than the
number of nodes 1 for datacenter dc1'
+
+ if cluster.version() >= '4.0':
+ warnings_total = 0
Review comment:
```
warnings_total = sum([len(node.grep_log(warning) for node in
cluster.node_list()])
assert warnings_total == 1
```
but actually what we would like to check is: "warning on a dc1 node, and no
warning on dc2 node"
so maybe more explicit:
```
assert len(node1.grep_log(warning)) == 1
assert len(node2.grep_log(warning)) == 0
```
##########
File path: bootstrap_test.py
##########
@@ -280,6 +280,55 @@ def
test_consistent_range_movement_true_with_rf1_should_fail(self):
def test_consistent_range_movement_false_with_rf1_should_succeed(self):
self._bootstrap_test_with_replica_down(False, rf=1)
+ def test_rf_gt_nodes_multidc_should_succeed(self):
+ """
+ Test creating a KS with RF > N on multi DC doesn't break bootstrap
+ @jira_ticket CASSANDRA-16296 CASSANDRA-16411
+ """
+ cluster = self.cluster
+
cluster.set_environment_variable('CASSANDRA_TOKEN_PREGENERATION_DISABLED',
'True')
+ cluster.populate([1, 1])
+ cluster.start()
+
+ node1 = cluster.nodelist()[0]
+ session = self.patient_cql_connection(node1)
+ session.execute("CREATE KEYSPACE k WITH REPLICATION = {'class' :
'NetworkTopologyStrategy', 'dc1' : '3'}")
+ warning = 'Your replication factor 3 for keyspace k is higher than the
number of nodes 1 for datacenter dc1'
+
+ if cluster.version() >= '4.0':
+ warnings_total = 0
+ for node in cluster.nodelist():
+ warnings_total += len(node.grep_log(warning))
+ assert warnings_total == 1
+
+ session.execute("ALTER KEYSPACE k WITH REPLICATION = {'class' :
'NetworkTopologyStrategy', 'dc1' : '2'}")
+ session.execute("CREATE TABLE k.testgtrfmultidc (KEY text PRIMARY
KEY)")
+ session.execute("INSERT INTO k.testgtrfmultidc (KEY) VALUES
('test_rf_gt_nodes_multidc_should_succeed')")
+ warning = 'Your replication factor 2 for keyspace k is higher than the
number of nodes 1 for datacenter dc1'
+
+ if cluster.version() >= '4.0':
+ warnings_total = 0
Review comment:
same here
##########
File path: bootstrap_test.py
##########
@@ -280,6 +280,53 @@ def
test_consistent_range_movement_true_with_rf1_should_fail(self):
def test_consistent_range_movement_false_with_rf1_should_succeed(self):
self._bootstrap_test_with_replica_down(False, rf=1)
+ def test_rf_gt_nodes_multidc_should_succeed(self):
+ """
+ Test creating a KS with RF > N on multi DC doesn't break bootstrap
Review comment:
so maybe rather then describing what test does we should describe what
it validates?
"Test validating that a KS with RF > N on multi DC doesn not break a
bootsrtap"
##########
File path: bootstrap_test.py
##########
@@ -280,6 +280,55 @@ def
test_consistent_range_movement_true_with_rf1_should_fail(self):
def test_consistent_range_movement_false_with_rf1_should_succeed(self):
self._bootstrap_test_with_replica_down(False, rf=1)
+ def test_rf_gt_nodes_multidc_should_succeed(self):
+ """
+ Test creating a KS with RF > N on multi DC doesn't break bootstrap
+ @jira_ticket CASSANDRA-16296 CASSANDRA-16411
+ """
+ cluster = self.cluster
+
cluster.set_environment_variable('CASSANDRA_TOKEN_PREGENERATION_DISABLED',
'True')
+ cluster.populate([1, 1])
+ cluster.start()
+
+ node1 = cluster.nodelist()[0]
+ session = self.patient_cql_connection(node1)
+ session.execute("CREATE KEYSPACE k WITH REPLICATION = {'class' :
'NetworkTopologyStrategy', 'dc1' : '3'}")
+ warning = 'Your replication factor 3 for keyspace k is higher than the
number of nodes 1 for datacenter dc1'
+
+ if cluster.version() >= '4.0':
+ warnings_total = 0
+ for node in cluster.nodelist():
+ warnings_total += len(node.grep_log(warning))
+ assert warnings_total == 1
+
+ session.execute("ALTER KEYSPACE k WITH REPLICATION = {'class' :
'NetworkTopologyStrategy', 'dc1' : '2'}")
+ session.execute("CREATE TABLE k.testgtrfmultidc (KEY text PRIMARY
KEY)")
+ session.execute("INSERT INTO k.testgtrfmultidc (KEY) VALUES
('test_rf_gt_nodes_multidc_should_succeed')")
+ warning = 'Your replication factor 2 for keyspace k is higher than the
number of nodes 1 for datacenter dc1'
+
+ if cluster.version() >= '4.0':
+ warnings_total = 0
+ for node in cluster.nodelist():
+ warnings_total += len(node.grep_log(warning))
+ assert warnings_total == 1
+
+ node3 = Node(name='node3',
+ cluster=cluster,
+ auto_bootstrap=True,
+ thrift_interface=('127.0.0.3', 9160),
+ storage_interface=('127.0.0.3', 7000),
+ jmx_port='7300',
+ remote_debug_port='0',
+ initial_token=None,
+ binary_interface=('127.0.0.3', 9042))
+ cluster.add(node3, is_seed=False, data_center="dc1")
+ node3.start(wait_for_binary_proto=True);
+ if cluster.version() >= '4.0':
+ assert len(node3.grep_log(warning)) == 0
Review comment:
this check for warning can be missed because number of nodes changed.
so for example `of nodes 1` will not be found if the warning would be `of
nodes 2` (as we added the node).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]