Skip to content

Commit bb73387

Browse files
Replace SimpleStrategy with NetworkTopologyStrategy in integration tests
In tests/integration/__init__.py, SimpleStrategy is kept but tablets are explicitly disabled to avoid decommission failures.
1 parent 8e6c4d4 commit bb73387

16 files changed

Lines changed: 36 additions & 36 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': 'SimpleStrategy', 'replication_factor': '3'} AND tablets = {'enabled': false}'''
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': 'SimpleStrategy', 'replication_factor': '2'} AND tablets = {'enabled': false}'''
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': 'SimpleStrategy', 'replication_factor': '1'} AND tablets = {'enabled': false}'''
665665
execute_with_long_wait_retry(session, ddl)
666666

667667
ddl_3f = '''
@@ -779,7 +779,7 @@ def drop_keyspace(cls):
779779

780780
@classmethod
781781
def create_keyspace(cls, rf):
782-
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '{1}'}}".format(cls.ks_name, rf)
782+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': '{1}'}} AND tablets = {{'enabled': false}}".format(cls.ks_name, rf)
783783
execute_with_long_wait_retry(cls.session, ddl)
784784

785785
@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
@@ -729,7 +729,7 @@ def test_queries_succeed_through_proxy(self):
729729
session = cluster.connect()
730730
session.execute(
731731
"CREATE KEYSPACE IF NOT EXISTS test_cr_ks "
732-
"WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}"
732+
"WITH replication = {'class':'NetworkTopologyStrategy', 'replication_factor': 3}"
733733
)
734734
session.execute(
735735
"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
@@ -168,7 +168,7 @@ def test_basic(self):
168168
result = execute_until_pass(session,
169169
"""
170170
CREATE KEYSPACE clustertests
171-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
171+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
172172
""")
173173
assert not result
174174

@@ -1491,7 +1491,7 @@ def test_prepare_on_ignored_hosts(self):
14911491
hosts = cluster.metadata.all_hosts()
14921492
session.execute("CREATE KEYSPACE clustertests "
14931493
"WITH replication = "
1494-
"{'class': 'SimpleStrategy', 'replication_factor': '1'}")
1494+
"{'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}")
14951495
session.execute("CREATE TABLE clustertests.tab (a text, PRIMARY KEY (a))")
14961496
# assign to an unused variable so cluster._prepared_statements retains
14971497
# 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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ 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")
4747

4848
@classmethod

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' : 'SimpleStrategy', 'replication_factor': '1'} AND tablets = {'enabled': false}")
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: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ def test_refresh_schema_metadata(self):
601601
assert "new_keyspace" not in cluster2.metadata.keyspaces
602602

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

607607
cluster2.refresh_schema_metadata()
@@ -1077,7 +1077,7 @@ def test_metadata_pagination_keyspaces(self):
10771077

10781078
for ks in keyspaces:
10791079
self.session.execute(
1080-
f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'SimpleStrategy', 'replication_factor' : 3 }}"
1080+
f"CREATE KEYSPACE IF NOT EXISTS {ks} WITH REPLICATION = {{ 'class' : 'NetworkTopologyStrategy', 'replication_factor' : 3 }}"
10811081
)
10821082

10831083
self.cluster.schema_metadata_page_size = 2000
@@ -1138,7 +1138,7 @@ def test_export_keyspace_schema_udts(self):
11381138

11391139
session.execute("""
11401140
CREATE KEYSPACE export_udts
1141-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
1141+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
11421142
AND durable_writes = true;
11431143
""")
11441144
session.execute("""
@@ -1162,7 +1162,7 @@ def test_export_keyspace_schema_udts(self):
11621162
addresses map<text, frozen<address>>)
11631163
""")
11641164

1165-
expected_prefix = """CREATE KEYSPACE export_udts WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND durable_writes = true;
1165+
expected_prefix = """CREATE KEYSPACE export_udts WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'} AND durable_writes = true;
11661166
11671167
CREATE TYPE export_udts.street (
11681168
street_number int,
@@ -1212,7 +1212,7 @@ def test_case_sensitivity(self):
12121212
session.execute("DROP KEYSPACE IF EXISTS {0}".format(ksname))
12131213
session.execute("""
12141214
CREATE KEYSPACE "%s"
1215-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'}
1215+
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND tablets = {'enabled': false}
12161216
""" % (ksname,))
12171217
session.execute("""
12181218
CREATE TABLE "%s"."%s" (
@@ -1256,7 +1256,7 @@ def test_already_exists_exceptions(self):
12561256

12571257
ddl = '''
12581258
CREATE KEYSPACE %s
1259-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}'''
1259+
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '3'}'''
12601260
with pytest.raises(AlreadyExists):
12611261
session.execute(ddl % ksname)
12621262

@@ -1387,7 +1387,7 @@ def setUp(self):
13871387
self.session = self.cluster.connect()
13881388
name = self._testMethodName.lower()
13891389
crt_ks = '''
1390-
CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} AND durable_writes = true''' % name
1390+
CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1} AND durable_writes = true''' % name
13911391
self.session.execute(crt_ks)
13921392

13931393
def tearDown(self):
@@ -1437,7 +1437,7 @@ def setup_class(cls):
14371437
cls.session.execute(
14381438
"""
14391439
CREATE KEYSPACE %s
1440-
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'};
1440+
WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '1'} AND tablets = {'enabled': false};
14411441
""" % cls.keyspace_name)
14421442
cls.session.set_keyspace(cls.keyspace_name)
14431443
except Exception:
@@ -1540,7 +1540,7 @@ def setup_class(cls):
15401540
cls.cluster = TestCluster()
15411541
cls.keyspace_name = cls.__name__.lower()
15421542
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)
1543+
cls.session.execute("CREATE KEYSPACE IF NOT EXISTS %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': 1}" % cls.keyspace_name)
15441544
cls.session.set_keyspace(cls.keyspace_name)
15451545
cls.keyspace_function_meta = cls.cluster.metadata.keyspaces[cls.keyspace_name].functions
15461546
cls.keyspace_aggregate_meta = cls.cluster.metadata.keyspaces[cls.keyspace_name].aggregates
@@ -2007,7 +2007,7 @@ def setup_class(cls):
20072007
cls.cluster = TestCluster()
20082008
cls.keyspace_name = cls.__name__.lower()
20092009
cls.session = cls.cluster.connect()
2010-
cls.session.execute("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1}" % cls.keyspace_name)
2010+
cls.session.execute("CREATE KEYSPACE %s WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 1} AND tablets = {'enabled': false}" % cls.keyspace_name)
20112011
cls.session.set_keyspace(cls.keyspace_name)
20122012
connection = cls.cluster.control_connection._connection
20132013

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)