Skip to content

Commit 63c1e8f

Browse files
jtgrabowskidjatnieks
authored andcommitted
STAR-452: add EverywhereStrategy smoke test (#10)
(cherry picked from commit eb3049c) (cherry picked from commit fe23e0b) (cherry picked from commit af5e094) (cherry picked from commit caaa548) (cherry picked from commit 31b6a86) (cherry picked from commit c32760d) (cherry picked from commit abc36a8) (cherry picked from commit 510ee55) (cherry picked from commit c7d5965)
1 parent 46d442f commit 63c1e8f

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed

bootstrap_test.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,56 @@ def nodetool_resume_command(cluster):
10761076
nt_resume_cmd += ' -f'
10771077
return nt_resume_cmd
10781078

1079+
@since('4.0')
1080+
@pytest.mark.no_vnodes
1081+
def test_simple_bootstrap_with_everywhere_strategy(self):
1082+
cluster = self.cluster
1083+
tokens = cluster.balanced_tokens(2)
1084+
cluster.set_configuration_options(values={'num_tokens': 1})
1085+
1086+
logger.debug("[node1, node2] tokens: %r" % (tokens,))
1087+
1088+
keys = 10000
1089+
1090+
# Create a single node cluster
1091+
cluster.populate(1)
1092+
node1 = cluster.nodelist()[0]
1093+
node1.set_configuration_options(values={'initial_token': tokens[0]})
1094+
cluster.start()
1095+
1096+
session = self.patient_cql_connection(node1)
1097+
create_ks(session, 'ks', 'EverywhereStrategy')
1098+
create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'})
1099+
1100+
insert_statement = session.prepare("INSERT INTO ks.cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
1101+
execute_concurrent_with_args(session, insert_statement, [['k%d' % k] for k in range(keys)])
1102+
1103+
node1.flush()
1104+
node1.compact()
1105+
1106+
# Reads inserted data all during the bootstrap process. We shouldn't
1107+
# get any error
1108+
query_c1c2(session, random.randint(0, keys - 1), ConsistencyLevel.ONE)
1109+
session.shutdown()
1110+
1111+
# Bootstrapping a new node in the current version
1112+
node2 = new_node(cluster)
1113+
node2.set_configuration_options(values={'initial_token': tokens[1]})
1114+
node2.start(wait_for_binary_proto=True)
1115+
node2.compact()
1116+
1117+
node1.cleanup()
1118+
logger.debug("node1 size for ks.cf after cleanup: %s" % float(data_size(node1,'ks','cf')))
1119+
node1.compact()
1120+
logger.debug("node1 size for ks.cf after compacting: %s" % float(data_size(node1,'ks','cf')))
1121+
1122+
logger.debug("node2 size for ks.cf after compacting: %s" % float(data_size(node2,'ks','cf')))
1123+
1124+
size1 = float(data_size(node1,'ks','cf'))
1125+
size2 = float(data_size(node2,'ks','cf'))
1126+
assert_almost_equal(size1, size2, error=0.3)
1127+
1128+
assert_bootstrap_state(self, node2, 'COMPLETED')
10791129

10801130
class TestBootstrap(BootstrapTester):
10811131
"""

dtest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,8 @@ def create_ks(session, name, rf):
383383
if isinstance(rf, int):
384384
# we assume simpleStrategy
385385
query = query % (name, "'class':'SimpleStrategy', 'replication_factor':%d" % rf)
386+
elif 'EverywhereStrategy' in rf:
387+
query = query % (name, "'class':'org.apache.cassandra.locator.EverywhereStrategy'")
386388
else:
387389
assert len(rf) >= 0, "At least one datacenter/rf pair is needed"
388390
# we assume networkTopologyStrategy
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
--- a/bootstrap_test.py
2+
+++ b/bootstrap_test.py
3+
@@ -1017,7 +1017,17 @@
4+
assert_bootstrap_state(self, node3, 'COMPLETED', user='cassandra', password='cassandra')
5+
node3.wait_for_binary_interface()
6+
7+
-<<<<<<<
8+
+ @staticmethod
9+
+ def nodetool_resume_command(cluster):
10+
+ """
11+
+ In versions after 4.1, we disable resumable bootstrap by default (see CASSANDRA-17679). In order to run
12+
+ nodetool boostrap resume in these subsequent versions we have to manually indicate the intent to allow resumability.
13+
+ """
14+
+ nt_resume_cmd = 'bootstrap resume'
15+
+ if cluster.version() >= '4.2':
16+
+ nt_resume_cmd += ' -f'
17+
+ return nt_resume_cmd
18+
+
19+
@since('4.0')
20+
@pytest.mark.no_vnodes
21+
def test_simple_bootstrap_with_everywhere_strategy(self):
22+
@@ -1068,19 +1078,6 @@
23+
assert_almost_equal(size1, size2, error=0.3)
24+
25+
assert_bootstrap_state(self, node2, 'COMPLETED')
26+
-=======
27+
- @staticmethod
28+
- def nodetool_resume_command(cluster):
29+
- """
30+
- In versions after 4.1, we disable resumable bootstrap by default (see CASSANDRA-17679). In order to run
31+
- nodetool boostrap resume in these subsequent versions we have to manually indicate the intent to allow resumability.
32+
- """
33+
- nt_resume_cmd = 'bootstrap resume'
34+
- if cluster.version() >= '4.2':
35+
- nt_resume_cmd += ' -f'
36+
- return nt_resume_cmd
37+
-
38+
->>>>>>>
39+
40+
class TestBootstrap(BootstrapTester):
41+
"""

0 commit comments

Comments
 (0)