Skip to content

Commit d7230fd

Browse files
jtgrabowskijacek-lewandowski
authored andcommitted
STAR-452 add EverywhereStrategy smoke test (#10)
(cherry picked from commit eb3049c) (cherry picked from commit fe23e0b)
1 parent 30c714c commit d7230fd

File tree

3 files changed

+170
-0
lines changed

3 files changed

+170
-0
lines changed

bootstrap_test.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,3 +1097,54 @@ def test_host_id_override(self):
10971097
# 3. check host_id in other node's table
10981098
session1 = self.patient_exclusive_cql_connection(node1)
10991099
assert_one(session1, "SELECT host_id FROM system.peers_v2 WHERE peer = {}".format(address2), [uuid.UUID(host_id)])
1100+
1101+
@since('4.0')
1102+
@pytest.mark.no_vnodes
1103+
def test_simple_bootstrap_with_everywhere_strategy(self):
1104+
cluster = self.cluster
1105+
tokens = cluster.balanced_tokens(2)
1106+
cluster.set_configuration_options(values={'num_tokens': 1})
1107+
1108+
logger.debug("[node1, node2] tokens: %r" % (tokens,))
1109+
1110+
keys = 10000
1111+
1112+
# Create a single node cluster
1113+
cluster.populate(1)
1114+
node1 = cluster.nodelist()[0]
1115+
node1.set_configuration_options(values={'initial_token': tokens[0]})
1116+
cluster.start()
1117+
1118+
session = self.patient_cql_connection(node1)
1119+
create_ks(session, 'ks', 'EverywhereStrategy')
1120+
create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'})
1121+
1122+
insert_statement = session.prepare("INSERT INTO ks.cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
1123+
execute_concurrent_with_args(session, insert_statement, [['k%d' % k] for k in range(keys)])
1124+
1125+
node1.flush()
1126+
node1.compact()
1127+
1128+
# Reads inserted data all during the bootstrap process. We shouldn't
1129+
# get any error
1130+
query_c1c2(session, random.randint(0, keys - 1), ConsistencyLevel.ONE)
1131+
session.shutdown()
1132+
1133+
# Bootstrapping a new node in the current version
1134+
node2 = new_node(cluster)
1135+
node2.set_configuration_options(values={'initial_token': tokens[1]})
1136+
node2.start(wait_for_binary_proto=True)
1137+
node2.compact()
1138+
1139+
node1.cleanup()
1140+
logger.debug("node1 size for ks.cf after cleanup: %s" % float(data_size(node1,'ks','cf')))
1141+
node1.compact()
1142+
logger.debug("node1 size for ks.cf after compacting: %s" % float(data_size(node1,'ks','cf')))
1143+
1144+
logger.debug("node2 size for ks.cf after compacting: %s" % float(data_size(node2,'ks','cf')))
1145+
1146+
size1 = float(data_size(node1,'ks','cf'))
1147+
size2 = float(data_size(node2,'ks','cf'))
1148+
assert_almost_equal(size1, size2, error=0.3)
1149+
1150+
assert_bootstrap_state(self, node2, 'COMPLETED')

dtest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ def create_ks(session, name, rf):
359359
if isinstance(rf, int):
360360
# we assume simpleStrategy
361361
query = query % (name, "'class':'SimpleStrategy', 'replication_factor':%d" % rf)
362+
elif 'EverywhereStrategy' in rf:
363+
query = query % (name, "'class':'org.apache.cassandra.locator.EverywhereStrategy'")
362364
else:
363365
assert len(rf) >= 0, "At least one datacenter/rf pair is needed"
364366
# we assume networkTopologyStrategy
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
--- a/bootstrap_test.py
2+
+++ b/bootstrap_test.py
3+
@@ -1018,58 +1018,6 @@
4+
assert_bootstrap_state(self, node3, 'COMPLETED', user='cassandra', password='cassandra')
5+
node3.wait_for_binary_interface()
6+
7+
-<<<<<<<
8+
- @since('4.0')
9+
- @pytest.mark.no_vnodes
10+
- def test_simple_bootstrap_with_everywhere_strategy(self):
11+
- cluster = self.cluster
12+
- tokens = cluster.balanced_tokens(2)
13+
- cluster.set_configuration_options(values={'num_tokens': 1})
14+
-
15+
- logger.debug("[node1, node2] tokens: %r" % (tokens,))
16+
-
17+
- keys = 10000
18+
-
19+
- # Create a single node cluster
20+
- cluster.populate(1)
21+
- node1 = cluster.nodelist()[0]
22+
- node1.set_configuration_options(values={'initial_token': tokens[0]})
23+
- cluster.start()
24+
-
25+
- session = self.patient_cql_connection(node1)
26+
- create_ks(session, 'ks', 'EverywhereStrategy')
27+
- create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'})
28+
-
29+
- insert_statement = session.prepare("INSERT INTO ks.cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
30+
- execute_concurrent_with_args(session, insert_statement, [['k%d' % k] for k in range(keys)])
31+
-
32+
- node1.flush()
33+
- node1.compact()
34+
-
35+
- # Reads inserted data all during the bootstrap process. We shouldn't
36+
- # get any error
37+
- query_c1c2(session, random.randint(0, keys - 1), ConsistencyLevel.ONE)
38+
- session.shutdown()
39+
-
40+
- # Bootstrapping a new node in the current version
41+
- node2 = new_node(cluster)
42+
- node2.set_configuration_options(values={'initial_token': tokens[1]})
43+
- node2.start(wait_for_binary_proto=True)
44+
- node2.compact()
45+
-
46+
- node1.cleanup()
47+
- logger.debug("node1 size for ks.cf after cleanup: %s" % float(data_size(node1,'ks','cf')))
48+
- node1.compact()
49+
- logger.debug("node1 size for ks.cf after compacting: %s" % float(data_size(node1,'ks','cf')))
50+
-
51+
- logger.debug("node2 size for ks.cf after compacting: %s" % float(data_size(node2,'ks','cf')))
52+
-
53+
- size1 = float(data_size(node1,'ks','cf'))
54+
- size2 = float(data_size(node2,'ks','cf'))
55+
- assert_almost_equal(size1, size2, error=0.3)
56+
-
57+
- assert_bootstrap_state(self, node2, 'COMPLETED')
58+
-=======
59+
@since('4.1')
60+
def test_invalid_host_id(self):
61+
"""
62+
@@ -1149,4 +1097,54 @@
63+
# 3. check host_id in other node's table
64+
session1 = self.patient_exclusive_cql_connection(node1)
65+
assert_one(session1, "SELECT host_id FROM system.peers_v2 WHERE peer = {}".format(address2), [uuid.UUID(host_id)])
66+
->>>>>>>
67+
+
68+
+ @since('4.0')
69+
+ @pytest.mark.no_vnodes
70+
+ def test_simple_bootstrap_with_everywhere_strategy(self):
71+
+ cluster = self.cluster
72+
+ tokens = cluster.balanced_tokens(2)
73+
+ cluster.set_configuration_options(values={'num_tokens': 1})
74+
+
75+
+ logger.debug("[node1, node2] tokens: %r" % (tokens,))
76+
+
77+
+ keys = 10000
78+
+
79+
+ # Create a single node cluster
80+
+ cluster.populate(1)
81+
+ node1 = cluster.nodelist()[0]
82+
+ node1.set_configuration_options(values={'initial_token': tokens[0]})
83+
+ cluster.start()
84+
+
85+
+ session = self.patient_cql_connection(node1)
86+
+ create_ks(session, 'ks', 'EverywhereStrategy')
87+
+ create_cf(session, 'cf', columns={'c1': 'text', 'c2': 'text'})
88+
+
89+
+ insert_statement = session.prepare("INSERT INTO ks.cf (key, c1, c2) VALUES (?, 'value1', 'value2')")
90+
+ execute_concurrent_with_args(session, insert_statement, [['k%d' % k] for k in range(keys)])
91+
+
92+
+ node1.flush()
93+
+ node1.compact()
94+
+
95+
+ # Reads inserted data all during the bootstrap process. We shouldn't
96+
+ # get any error
97+
+ query_c1c2(session, random.randint(0, keys - 1), ConsistencyLevel.ONE)
98+
+ session.shutdown()
99+
+
100+
+ # Bootstrapping a new node in the current version
101+
+ node2 = new_node(cluster)
102+
+ node2.set_configuration_options(values={'initial_token': tokens[1]})
103+
+ node2.start(wait_for_binary_proto=True)
104+
+ node2.compact()
105+
+
106+
+ node1.cleanup()
107+
+ logger.debug("node1 size for ks.cf after cleanup: %s" % float(data_size(node1,'ks','cf')))
108+
+ node1.compact()
109+
+ logger.debug("node1 size for ks.cf after compacting: %s" % float(data_size(node1,'ks','cf')))
110+
+
111+
+ logger.debug("node2 size for ks.cf after compacting: %s" % float(data_size(node2,'ks','cf')))
112+
+
113+
+ size1 = float(data_size(node1,'ks','cf'))
114+
+ size2 = float(data_size(node2,'ks','cf'))
115+
+ assert_almost_equal(size1, size2, error=0.3)
116+
+
117+
+ assert_bootstrap_state(self, node2, 'COMPLETED')

0 commit comments

Comments
 (0)