Skip to content

Commit cf01c3f

Browse files
sylwiaszunejkodkropachev
authored andcommitted
tests: use tablets-disabled keyspace instead of xfail for scylladb/scylladb#22677
Tests that previously xfailed on ScyllaDB < 2026.1 due to MVs, secondary indexes, and counters not being supported on tables with tablets now create their keyspace with 'AND tablets = {"enabled": false}' for those older versions, so the tests run and pass rather than being expected to fail. A new helper get_tablets_disabled_ddl_suffix() is added to tests/integration/__init__.py to return the appropriate DDL suffix.
1 parent f7d945f commit cf01c3f

4 files changed

Lines changed: 55 additions & 37 deletions

File tree

tests/integration/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,17 @@ def xfail_scylla_version_lt(reason, scylla_version, *args, **kwargs):
707707
return pytest.mark.xfail(current_version < Version(scylla_version), reason=reason, *args, **kwargs)
708708

709709

710+
def get_tablets_disabled_ddl_suffix(scylla_version='2026.1'):
711+
"""
712+
Returns DDL option string for disabling tablets on ScyllaDB versions older than scylla_version.
713+
Used to work around features not yet supported with tablets (e.g. MVs, secondary indexes, counters).
714+
:param scylla_version: str, version from which tablets support the feature
715+
"""
716+
if SCYLLA_VERSION is not None and Version(get_scylla_version(SCYLLA_VERSION)) < Version(scylla_version):
717+
return " AND tablets = {'enabled': false}"
718+
return ""
719+
720+
710721
def skip_scylla_version_lt(reason, scylla_version):
711722
"""
712723
Skip tests on scylla versions older than the specified thresholds.

tests/integration/cqlengine/query/test_named.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from tests.integration.cqlengine.query.test_queryset import BaseQuerySetUsage
2828

2929

30-
from tests.integration import BasicSharedKeyspaceUnitTestCase, greaterthanorequalcass30, requires_collection_indexes, xfail_scylla_version_lt
30+
from tests.integration import BasicSharedKeyspaceUnitTestCase, greaterthanorequalcass30, requires_collection_indexes, get_tablets_disabled_ddl_suffix, execute_with_long_wait_retry
3131
import pytest
3232

3333

@@ -280,6 +280,12 @@ def test_get_multipleobjects_exception(self):
280280

281281
class TestNamedWithMV(BasicSharedKeyspaceUnitTestCase):
282282

283+
@classmethod
284+
def create_keyspace(cls, rf):
285+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}{2}".format(
286+
cls.ks_name, rf, get_tablets_disabled_ddl_suffix())
287+
execute_with_long_wait_retry(cls.session, ddl)
288+
283289
@classmethod
284290
def setUpClass(cls):
285291
super(TestNamedWithMV, cls).setUpClass()
@@ -292,8 +298,6 @@ def tearDownClass(cls):
292298
super(TestNamedWithMV, cls).tearDownClass()
293299

294300
@greaterthanorequalcass30
295-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Materialized views and secondary indexes are not supported on base tables with tablets.',
296-
scylla_version='2026.1')
297301
@execute_count(5)
298302
def test_named_table_with_mv(self):
299303
"""

tests/integration/standard/test_metadata.py

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
lessthancass40,
4646
TestCluster, requires_java_udf, requires_composite_type,
4747
requires_collection_indexes, SCYLLA_VERSION, xfail_scylla, xfail_scylla_version_lt,
48-
requirescompactstorage)
48+
requirescompactstorage, get_tablets_disabled_ddl_suffix, execute_with_long_wait_retry)
4949

5050
from tests.util import wait_until, assertRegex, assertDictEqual, assertListEqual, assert_startswith_diff
5151

@@ -141,6 +141,12 @@ def test_bad_contact_point(self):
141141

142142
class SchemaMetadataTests(BasicSegregatedKeyspaceUnitTestCase):
143143

144+
@classmethod
145+
def create_keyspace(cls, rf):
146+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}{2}".format(
147+
cls.ks_name, rf, get_tablets_disabled_ddl_suffix())
148+
execute_with_long_wait_retry(cls.session, ddl)
149+
144150
def test_schema_metadata_disable(self):
145151
"""
146152
Checks to ensure that schema metadata_enabled, and token_metadata_enabled
@@ -448,8 +454,6 @@ def test_dense_compact_storage(self):
448454
tablemeta = self.get_table_metadata()
449455
self.check_create_statement(tablemeta, create_statement)
450456

451-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Counters are not yet supported with tablets',
452-
scylla_version="2026.1")
453457
def test_counter(self):
454458
create_statement = (
455459
"CREATE TABLE {keyspace}.{table} ("
@@ -724,8 +728,6 @@ def test_refresh_table_metadata(self):
724728
cluster2.shutdown()
725729

726730
@greaterthanorequalcass30
727-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
728-
scylla_version="2026.1")
729731
def test_refresh_metadata_for_mv(self):
730732
"""
731733
test for synchronously refreshing materialized view metadata
@@ -935,8 +937,6 @@ def test_refresh_user_aggregate_metadata(self):
935937

936938
@greaterthanorequalcass30
937939
@requires_collection_indexes
938-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
939-
scylla_version="2026.1")
940940
def test_multiple_indices(self):
941941
"""
942942
test multiple indices on the same column.
@@ -970,8 +970,6 @@ def test_multiple_indices(self):
970970
assert index_2.keyspace_name == "schemametadatatests"
971971

972972
@greaterthanorequalcass30
973-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
974-
scylla_version="2026.1")
975973
def test_table_extensions(self):
976974
s = self.session
977975
ks = self.keyspace_name
@@ -1204,8 +1202,6 @@ def test_export_keyspace_schema_udts(self):
12041202
cluster.shutdown()
12051203

12061204
@greaterthancass21
1207-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
1208-
scylla_version="2026.1")
12091205
def test_case_sensitivity(self):
12101206
"""
12111207
Test that names that need to be escaped in CREATE statements are
@@ -1218,10 +1214,9 @@ def test_case_sensitivity(self):
12181214
cfname = 'AnInterestingTable'
12191215

12201216
session.execute("DROP KEYSPACE IF EXISTS {0}".format(ksname))
1221-
session.execute("""
1222-
CREATE KEYSPACE "%s"
1223-
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}
1224-
""" % (ksname,))
1217+
session.execute(
1218+
("CREATE KEYSPACE \"%s\" WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" +
1219+
get_tablets_disabled_ddl_suffix()) % (ksname,))
12251220
session.execute("""
12261221
CREATE TABLE "%s"."%s" (
12271222
k int,
@@ -1442,11 +1437,9 @@ def setup_class(cls):
14421437
if cls.keyspace_name in cls.cluster.metadata.keyspaces:
14431438
cls.session.execute("DROP KEYSPACE %s" % cls.keyspace_name)
14441439

1445-
cls.session.execute(
1446-
"""
1447-
CREATE KEYSPACE %s
1448-
WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'};
1449-
""" % cls.keyspace_name)
1440+
ddl = ("CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" +
1441+
get_tablets_disabled_ddl_suffix())
1442+
cls.session.execute(ddl % cls.keyspace_name)
14501443
cls.session.set_keyspace(cls.keyspace_name)
14511444
except Exception:
14521445
cls.cluster.shutdown()
@@ -1465,8 +1458,6 @@ def create_basic_table(self):
14651458
def drop_basic_table(self):
14661459
self.session.execute("DROP TABLE %s" % self.table_name)
14671460

1468-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
1469-
scylla_version="2026.1")
14701461
def test_index_updates(self):
14711462
self.create_basic_table()
14721463

@@ -1508,8 +1499,6 @@ def test_index_updates(self):
15081499
assert 'a_idx' not in ks_meta.indexes
15091500
assert 'b_idx' not in ks_meta.indexes
15101501

1511-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
1512-
scylla_version="2026.1")
15131502
def test_index_follows_alter(self):
15141503
self.create_basic_table()
15151504

@@ -2019,7 +2008,8 @@ def setup_class(cls):
20192008
cls.cluster = TestCluster()
20202009
cls.keyspace_name = cls.__name__.lower()
20212010
cls.session = cls.cluster.connect()
2022-
cls.session.execute("CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" % cls.keyspace_name)
2011+
ddl = "CREATE KEYSPACE %s WITH replication = {'class': 'NetworkTopologyStrategy', 'replication_factor': '1'}" + get_tablets_disabled_ddl_suffix()
2012+
cls.session.execute(ddl % cls.keyspace_name)
20232013
cls.session.set_keyspace(cls.keyspace_name)
20242014
connection = cls.cluster.control_connection._connection
20252015

@@ -2051,8 +2041,6 @@ def test_bad_table(self):
20512041
assert m._exc_info[0] is self.BadMetaException
20522042
assert "/*\nWarning:" in m.export_as_string()
20532043

2054-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
2055-
scylla_version="2026.1")
20562044
def test_bad_index(self):
20572045
self.session.execute('CREATE TABLE %s (k int PRIMARY KEY, v int)' % self.function_name)
20582046
self.session.execute('CREATE INDEX ON %s(v)' % self.function_name)
@@ -2144,10 +2132,15 @@ def test_dct_alias(self):
21442132

21452133

21462134
@greaterthanorequalcass30
2147-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
2148-
scylla_version="2026.1")
21492135
class MaterializedViewMetadataTestSimple(BasicSharedKeyspaceUnitTestCase):
21502136

2137+
@classmethod
2138+
def create_keyspace(cls, rf):
2139+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}{2}".format(
2140+
cls.ks_name, rf, get_tablets_disabled_ddl_suffix())
2141+
execute_with_long_wait_retry(cls.session, ddl)
2142+
2143+
21512144
def setUp(self):
21522145
self.session.execute("CREATE TABLE {0}.{1} (pk int PRIMARY KEY, c int)".format(self.keyspace_name, self.function_table_name))
21532146
self.session.execute(
@@ -2234,9 +2227,14 @@ def test_materialized_view_metadata_drop(self):
22342227

22352228

22362229
@greaterthanorequalcass30
2237-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Secondary indexes are not supported on base tables with tablets',
2238-
scylla_version="2026.1")
22392230
class MaterializedViewMetadataTestComplex(BasicSegregatedKeyspaceUnitTestCase):
2231+
2232+
@classmethod
2233+
def create_keyspace(cls, rf):
2234+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}{2}".format(
2235+
cls.ks_name, rf, get_tablets_disabled_ddl_suffix())
2236+
execute_with_long_wait_retry(cls.session, ddl)
2237+
22402238
def test_create_view_metadata(self):
22412239
"""
22422240
test to ensure that materialized view metadata is properly constructed

tests/integration/standard/test_query.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626
from cassandra.policies import HostDistance, RoundRobinPolicy, WhiteListRoundRobinPolicy
2727
from tests.integration import use_singledc, PROTOCOL_VERSION, BasicSharedKeyspaceUnitTestCase, \
2828
greaterthanprotocolv3, MockLoggingHandler, get_supported_protocol_versions, local, get_cluster, setup_keyspace, \
29-
USE_CASS_EXTERNAL, greaterthanorequalcass40, TestCluster, xfail_scylla, xfail_scylla_version_lt
29+
USE_CASS_EXTERNAL, greaterthanorequalcass40, TestCluster, xfail_scylla, xfail_scylla_version_lt, \
30+
get_tablets_disabled_ddl_suffix, execute_with_long_wait_retry
3031
from tests import notwindows
3132
from tests.integration import greaterthanorequalcass30, get_node
3233
from tests.util import assertListEqual, wait_until
@@ -1166,10 +1167,14 @@ def test_inherit_first_rk_prepared_param(self):
11661167

11671168

11681169
@greaterthanorequalcass30
1169-
@xfail_scylla_version_lt(reason='scylladb/scylladb#22677 - Materialized views and secondary indexes are not supported on base tables with tablets.',
1170-
scylla_version='2026.1')
11711170
class MaterializedViewQueryTest(BasicSharedKeyspaceUnitTestCase):
11721171

1172+
@classmethod
1173+
def create_keyspace(cls, rf):
1174+
ddl = "CREATE KEYSPACE {0} WITH replication = {{'class': 'NetworkTopologyStrategy', 'replication_factor': '{1}'}}{2}".format(
1175+
cls.ks_name, rf, get_tablets_disabled_ddl_suffix())
1176+
execute_with_long_wait_retry(cls.session, ddl)
1177+
11731178
def test_mv_filtering(self):
11741179
"""
11751180
Test to ensure that cql filtering where clauses are properly supported in the python driver.

0 commit comments

Comments
 (0)