Skip to content

Commit d1156dc

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 af4b739 commit d1156dc

File tree

3 files changed

+77
-0
lines changed

3 files changed

+77
-0
lines changed

bootstrap_test.py

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,6 +1018,57 @@ def test_bootstrap_binary_disabled(self):
10181018
assert_bootstrap_state(self, node3, 'COMPLETED', user='cassandra', password='cassandra')
10191019
node3.wait_for_binary_interface()
10201020

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

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: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--- a/bootstrap_test.py
2+
+++ b/bootstrap_test.py
3+
@@ -1018,7 +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+
@@ -1069,7 +1068,7 @@
12+
assert_almost_equal(size1, size2, error=0.3)
13+
14+
assert_bootstrap_state(self, node2, 'COMPLETED')
15+
-=======
16+
+
17+
@since('4.1')
18+
def test_invalid_host_id(self):
19+
"""
20+
@@ -1149,4 +1148,3 @@
21+
# 3. check host_id in other node's table
22+
session1 = self.patient_exclusive_cql_connection(node1)
23+
assert_one(session1, "SELECT host_id FROM system.peers_v2 WHERE peer = {}".format(address2), [uuid.UUID(host_id)])
24+
->>>>>>>

0 commit comments

Comments
 (0)