Skip to content

Commit aa0ec1a

Browse files
jtgrabowskijacek-lewandowski
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 e6505d9 commit aa0ec1a

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
@@ -1075,6 +1075,56 @@ def nodetool_resume_command(cluster):
10751075
nt_resume_cmd += ' -f'
10761076
return nt_resume_cmd
10771077

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

10791129
class TestBootstrap(BootstrapTester):
10801130
"""

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)