Skip to content

Commit c7d5965

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)
1 parent ba3f669 commit c7d5965

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
@@ -1028,6 +1028,56 @@ def nodetool_resume_command(cluster):
10281028
nt_resume_cmd += ' -f'
10291029
return nt_resume_cmd
10301030

1031+
@since('4.0')
1032+
@pytest.mark.no_vnodes
1033+
def test_simple_bootstrap_with_everywhere_strategy(self):
1034+
cluster = self.cluster
1035+
tokens = cluster.balanced_tokens(2)
1036+
cluster.set_configuration_options(values={'num_tokens': 1})
1037+
1038+
logger.debug("[node1, node2] tokens: %r" % (tokens,))
1039+
1040+
keys = 10000
1041+
1042+
# Create a single node cluster
1043+
cluster.populate(1)
1044+
node1 = cluster.nodelist()[0]
1045+
node1.set_configuration_options(values={'initial_token': tokens[0]})
1046+
cluster.start()
1047+
1048+
session = self.patient_cql_connection(node1)
1049+
create_ks(session, 'ks', 'EverywhereStrategy')
1050+
create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'})
1051+
1052+
insert_statement = session.prepare("INSERT INTO ks.cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
1053+
execute_concurrent_with_args(session, insert_statement, [['k%d' % k] for k in range(keys)])
1054+
1055+
node1.flush()
1056+
node1.compact()
1057+
1058+
# Reads inserted data all during the bootstrap process. We shouldn't
1059+
# get any error
1060+
query_c1c2(session, random.randint(0, keys - 1), ConsistencyLevel.ONE)
1061+
session.shutdown()
1062+
1063+
# Bootstrapping a new node in the current version
1064+
node2 = new_node(cluster)
1065+
node2.set_configuration_options(values={'initial_token': tokens[1]})
1066+
node2.start(wait_for_binary_proto=True)
1067+
node2.compact()
1068+
1069+
node1.cleanup()
1070+
logger.debug("node1 size for ks.cf after cleanup: %s" % float(data_size(node1,'ks','cf')))
1071+
node1.compact()
1072+
logger.debug("node1 size for ks.cf after compacting: %s" % float(data_size(node1,'ks','cf')))
1073+
1074+
logger.debug("node2 size for ks.cf after compacting: %s" % float(data_size(node2,'ks','cf')))
1075+
1076+
size1 = float(data_size(node1,'ks','cf'))
1077+
size2 = float(data_size(node2,'ks','cf'))
1078+
assert_almost_equal(size1, size2, error=0.3)
1079+
1080+
assert_bootstrap_state(self, node2, 'COMPLETED')
10311081

10321082
class TestBootstrap(BootstrapTester):
10331083
"""

dtest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,8 @@ def create_ks(session, name, rf):
374374
if isinstance(rf, int):
375375
# we assume simpleStrategy
376376
query = query % (name, "'class':'SimpleStrategy', 'replication_factor':%d" % rf)
377+
elif 'EverywhereStrategy' in rf:
378+
query = query % (name, "'class':'org.apache.cassandra.locator.EverywhereStrategy'")
377379
else:
378380
assert len(rf) >= 0, "At least one datacenter/rf pair is needed"
379381
# 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)