Skip to content

Commit 69bb8ef

Browse files
sylwiaszunejkodkropachev
authored andcommitted
tests: replace SimpleStrategy with NetworkTopologyStrategy
Replace SimpleStrategy with NetworkTopologyStrategy across integration tests to align with ScyllaDB's tablet-based replication defaults. In the tablets test module, skip default keyspace creation (set_keyspace=False) to avoid RF=3 keyspaces that block node decommission when all nodes already hold replicas.
1 parent 442f1ed commit 69bb8ef

17 files changed

Lines changed: 54 additions & 43 deletions

tests/integration/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,17 +651,17 @@ def setup_keyspace(ipformat=None, protocol_version=None, port=9042):
651651

652652
ddl = '''
653653
CREATE KEYSPACE test3rf
654-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}'''
654+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '3'}'''
655655
execute_with_long_wait_retry(session, ddl)
656656

657657
ddl = '''
658658
CREATE KEYSPACE test2rf
659-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2'}'''
659+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '2'}'''
660660
execute_with_long_wait_retry(session, ddl)
661661

662662
ddl = '''
663663
CREATE KEYSPACE test1rf
664-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}'''
664+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}'''
665665
execute_with_long_wait_retry(session, ddl)
666666

667667
ddl_3f = '''
@@ -774,7 +774,7 @@ def drop_keyspace(cls):
774774

775775
@classmethod
776776
def create_keyspace(cls, rf):
777-
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '{1}'}}".format(cls.ks_name, rf)
777+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}".format(cls.ks_name, rf)
778778
execute_with_long_wait_retry(cls.session, ddl)
779779

780780
@classmethod

tests/integration/standard/column_encryption/test_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class ColumnEncryptionPolicyTest(unittest.TestCase):
3030

3131
def _recreate_keyspace(self, session):
3232
session.execute("drop keyspace if exists foo")
33-
session.execute("CREATE KEYSPACE foo WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}")
33+
session.execute("CREATE KEYSPACE foo WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}")
3434
session.execute("CREATE TABLE foo.bar(encrypted blob, unencrypted int, primary key(unencrypted))")
3535

3636
def _create_policy(self, key, iv = None):

tests/integration/standard/test_client_routes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ def test_queries_succeed_through_proxy(self):
741741
session = cluster.connect()
742742
session.execute(
743743
"CREATE KEYSPACE IF NOT EXISTS test_cr_ks "
744-
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}"
744+
"WITH replication = {'class':'NetworkTopologyStrategy', 'replication_factor': 3}"
745745
)
746746
session.execute(
747747
"CREATE TABLE IF NOT EXISTS test_cr_ks.t (k int PRIMARY KEY, v text)"

tests/integration/standard/test_cluster.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def test_basic(self):
180180
result = execute_until_pass(session,
181181
"""
182182
CREATE KEYSPACE clustertests
183-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
183+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
184184
""")
185185
assert not result
186186

@@ -1506,7 +1506,7 @@ def test_prepare_on_ignored_hosts(self):
15061506
hosts = cluster.metadata.all_hosts()
15071507
session.execute("CREATE KEYSPACE clustertests "
15081508
"WITH replication = "
1509-
"{'class': 'SimpleStrategy', 'replication_factor': '1'}")
1509+
"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}")
15101510
session.execute("CREATE TABLE clustertests.tab (a text, PRIMARY KEY (a))")
15111511
# assign to an unused variable so cluster._prepared_statements retains
15121512
# reference

tests/integration/standard/test_concurrent_schema_change_and_node_kill.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def test_schema_change_after_node_kill(self):
2727
"DROP KEYSPACE IF EXISTS ks_deadlock;")
2828
self.session.execute(
2929
"CREATE KEYSPACE IF NOT EXISTS ks_deadlock "
30-
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '2' };")
30+
"WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '2' };")
3131
self.session.set_keyspace('ks_deadlock')
3232
self.session.execute("CREATE TABLE IF NOT EXISTS some_table(k int, c int, v int, PRIMARY KEY (k, v));")
3333
self.session.execute("INSERT INTO some_table (k, c, v) VALUES (1, 2, 3);")

tests/integration/standard/test_control_connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def test_drop_keyspace(self):
6868
self.session = self.cluster.connect()
6969
self.session.execute("""
7070
CREATE KEYSPACE keyspacetodrop
71-
WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1' }
71+
WITH replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor': '1' }
7272
""")
7373
self.session.set_keyspace("keyspacetodrop")
7474
self.session.execute("CREATE TYPE user (age int, name text)")

tests/integration/standard/test_custom_protocol_handler.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ class CustomProtocolHandlerTest(unittest.TestCase):
4242
def setUpClass(cls):
4343
cls.cluster = TestCluster()
4444
cls.session = cls.cluster.connect()
45-
cls.session.execute("CREATE KEYSPACE custserdes WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor': '1'}")
45+
cls.session.execute("CREATE KEYSPACE custserdes WITH replication = { 'class' : 'NetworkTopologyStrategy', 'replication_factor': '1'}")
4646
cls.session.set_keyspace("custserdes")
47+
cls.session.execute("CREATE TABLE IF NOT EXISTS custserdes.test (k int PRIMARY KEY, v int)")
4748

4849
@classmethod
4950
def tearDownClass(cls):
@@ -165,7 +166,7 @@ def test_protocol_divergence_v5_fail_by_flag_uses_int(self):
165166
int_flag=False)
166167

167168
def _send_query_message(self, session, timeout, **kwargs):
168-
query = "SELECT * FROM test3rf.test"
169+
query = "SELECT * FROM custserdes.test"
169170
message = QueryMessage(query=query, **kwargs)
170171
future = ResponseFuture(session, message, query=None, timeout=timeout)
171172
future.send_request()
@@ -175,8 +176,8 @@ def _protocol_divergence_fail_by_flag_uses_int(self, version, uses_int_query_fla
175176
cluster = TestCluster(protocol_version=version, allow_beta_protocol_version=beta)
176177
session = cluster.connect()
177178

178-
query_one = SimpleStatement("INSERT INTO test3rf.test (k, v) VALUES (1, 1)")
179-
query_two = SimpleStatement("INSERT INTO test3rf.test (k, v) VALUES (2, 2)")
179+
query_one = SimpleStatement("INSERT INTO custserdes.test (k, v) VALUES (1, 1)")
180+
query_two = SimpleStatement("INSERT INTO custserdes.test (k, v) VALUES (2, 2)")
180181

181182
execute_with_long_wait_retry(session, query_one)
182183
execute_with_long_wait_retry(session, query_two)
@@ -190,7 +191,7 @@ def _protocol_divergence_fail_by_flag_uses_int(self, version, uses_int_query_fla
190191
# This means the flag are not handled as they are meant by the server if uses_int=False
191192
assert response.has_more_pages == uses_int_query_flag
192193

193-
execute_with_long_wait_retry(session, SimpleStatement("TRUNCATE test3rf.test"))
194+
execute_with_long_wait_retry(session, SimpleStatement("TRUNCATE custserdes.test"))
194195
cluster.shutdown()
195196

196197

tests/integration/standard/test_cython_protocol_handlers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def setUpClass(cls):
3434
cls.cluster = TestCluster()
3535
cls.session = cls.cluster.connect()
3636
cls.session.execute("CREATE KEYSPACE testspace WITH replication = "
37-
"{ 'class' : 'SimpleStrategy', 'replication_factor': '1'}")
37+
"{ 'class' : 'NetworkTopologyStrategy', 'replication_factor': '1'}")
3838
cls.session.set_keyspace("testspace")
3939
cls.colnames = create_table_with_all_types("test_table", cls.session, cls.N_ITEMS)
4040

@@ -225,7 +225,7 @@ def setUpClass(cls):
225225
cls.cluster = TestCluster()
226226
cls.session = cls.cluster.connect()
227227
cls.session.execute("CREATE KEYSPACE IF NOT EXISTS test_wide_table WITH replication = "
228-
"{ 'class' : 'SimpleStrategy', 'replication_factor': '1'}")
228+
"{ 'class' : 'NetworkTopologyStrategy', 'replication_factor': '1'}")
229229
cls.session.set_keyspace("test_wide_table")
230230

231231
# Create a wide table with many int columns

tests/integration/standard/test_metadata.py

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,8 @@ def test_basic_table_meta_properties(self):
230230

231231
assert ksmeta.name == self.keyspace_name
232232
assert ksmeta.durable_writes
233-
assert ksmeta.replication_strategy.name == 'SimpleStrategy'
234-
assert ksmeta.replication_strategy.replication_factor == 1
233+
assert ksmeta.replication_strategy.name == 'NetworkTopologyStrategy'
234+
assert ksmeta.replication_strategy.dc_replication_factors["dc1"] == 1
235235

236236
assert self.function_table_name in ksmeta.tables
237237
tablemeta = ksmeta.tables[self.function_table_name]
@@ -448,6 +448,8 @@ def test_dense_compact_storage(self):
448448
tablemeta = self.get_table_metadata()
449449
self.check_create_statement(tablemeta, create_statement)
450450

451+
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Counters are not yet supported with tablets',
452+
oss_scylla_version="7.0", ent_scylla_version="2026.1")
451453
def test_counter(self):
452454
create_statement = (
453455
"CREATE TABLE {keyspace}.{table} ("
@@ -601,7 +603,7 @@ def test_refresh_schema_metadata(self):
601603
assert "new_keyspace" not in cluster2.metadata.keyspaces
602604

603605
# Cluster metadata modification
604-
self.session.execute("CREATE KEYSPACE new_keyspace WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}")
606+
self.session.execute("CREATE KEYSPACE new_keyspace WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}")
605607
assert "new_keyspace" not in cluster2.metadata.keyspaces
606608

607609
cluster2.refresh_schema_metadata()
@@ -722,6 +724,8 @@ def test_refresh_table_metadata(self):
722724
cluster2.shutdown()
723725

724726
@greaterthanorequalcass30
727+
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
728+
oss_scylla_version="7.0", ent_scylla_version="2026.1")
725729
def test_refresh_metadata_for_mv(self):
726730
"""
727731
test for synchronously refreshing materialized view metadata
@@ -931,6 +935,8 @@ def test_refresh_user_aggregate_metadata(self):
931935

932936
@greaterthanorequalcass30
933937
@requires_collection_indexes
938+
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
939+
oss_scylla_version="7.0", ent_scylla_version="2026.1")
934940
def test_multiple_indices(self):
935941
"""
936942
test multiple indices on the same column.
@@ -964,6 +970,8 @@ def test_multiple_indices(self):
964970
assert index_2.keyspace_name == "schemametadatatests"
965971

966972
@greaterthanorequalcass30
973+
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
974+
oss_scylla_version="7.0", ent_scylla_version="2026.1")
967975
def test_table_extensions(self):
968976
s = self.session
969977
ks = self.keyspace_name
@@ -1077,7 +1085,7 @@ def test_metadata_pagination_keyspaces(self):
10771085

10781086
for ks in keyspaces:
10791087
self.session.execute(
1080-
f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 3 }}"
1088+
f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3 }}"
10811089
)
10821090

10831091
self.cluster.schema_metadata_page_size = 2000
@@ -1138,7 +1146,7 @@ def test_export_keyspace_schema_udts(self):
11381146

11391147
session.execute("""
11401148
CREATE KEYSPACE export_udts
1141-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
1149+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
11421150
AND durable_writes = true;
11431151
""")
11441152
session.execute("""
@@ -1162,7 +1170,7 @@ def test_export_keyspace_schema_udts(self):
11621170
addresses map<text, frozen<address>>)
11631171
""")
11641172

1165-
expected_prefix = """CREATE KEYSPACE export_udts WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
1173+
expected_prefix = """CREATE KEYSPACE export_udts WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'} AND durable_writes = true;
11661174
11671175
CREATE TYPE export_udts.street (
11681176
street_number int,
@@ -1212,7 +1220,7 @@ def test_case_sensitivity(self):
12121220
session.execute("DROP KEYSPACE IF EXISTS {0}".format(ksname))
12131221
session.execute("""
12141222
CREATE KEYSPACE "%s"
1215-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
1223+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
12161224
""" % (ksname,))
12171225
session.execute("""
12181226
CREATE TABLE "%s"."%s" (
@@ -1256,7 +1264,7 @@ def test_already_exists_exceptions(self):
12561264

12571265
ddl = '''
12581266
CREATE KEYSPACE %s
1259-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}'''
1267+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '3'}'''
12601268
with pytest.raises(AlreadyExists):
12611269
session.execute(ddl % ksname)
12621270

@@ -1387,7 +1395,7 @@ def setUp(self):
13871395
self.session = self.cluster.connect()
13881396
name = self._testMethodName.lower()
13891397
crt_ks = '''
1390-
CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} AND durable_writes = true''' % name
1398+
CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1} AND durable_writes = true''' % name
13911399
self.session.execute(crt_ks)
13921400

13931401
def tearDown(self):
@@ -1437,7 +1445,7 @@ def setup_class(cls):
14371445
cls.session.execute(
14381446
"""
14391447
CREATE KEYSPACE %s
1440-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};
1448+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'};
14411449
""" % cls.keyspace_name)
14421450
cls.session.set_keyspace(cls.keyspace_name)
14431451
except Exception:
@@ -1540,7 +1548,7 @@ def setup_class(cls):
15401548
cls.cluster = TestCluster()
15411549
cls.keyspace_name = cls.__name__.lower()
15421550
cls.session = cls.cluster.connect()
1543-
cls.session.execute("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}" % cls.keyspace_name)
1551+
cls.session.execute("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}" % cls.keyspace_name)
15441552
cls.session.set_keyspace(cls.keyspace_name)
15451553
cls.keyspace_function_meta = cls.cluster.metadata.keyspaces[cls.keyspace_name].functions
15461554
cls.keyspace_aggregate_meta = cls.cluster.metadata.keyspaces[cls.keyspace_name].aggregates
@@ -2007,7 +2015,7 @@ def setup_class(cls):
20072015
cls.cluster = TestCluster()
20082016
cls.keyspace_name = cls.__name__.lower()
20092017
cls.session = cls.cluster.connect()
2010-
cls.session.execute("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}" % cls.keyspace_name)
2018+
cls.session.execute("CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" % cls.keyspace_name)
20112019
cls.session.set_keyspace(cls.keyspace_name)
20122020
connection = cls.cluster.control_connection._connection
20132021

tests/integration/standard/test_policies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,5 @@ def test_exponential_retries(self):
104104
self.session.execute(
105105
"""
106106
CREATE KEYSPACE preparedtests
107-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
107+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
108108
""")

0 commit comments

Comments
 (0)