Skip to content

Commit 41ad3d0

Browse files
fruchdkropachev
authored andcommitted
tests/integration: introduced @xfail_scylla_version_lt
some test that was marked with @xfail_scylla, are now passing with newer release, i.e. some issue were fixed. so this new decorator can xfail up to a certion scylla_version note that it support both a oss version, and enterprise version
1 parent 679a79c commit 41ad3d0

File tree

3 files changed

+45
-6
lines changed

3 files changed

+45
-6
lines changed

tests/integration/__init__.py

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
# limitations under the License.
1414

1515
import os
16+
from distutils.log import fatal
17+
1618
from cassandra.cluster import Cluster
1719

1820
from tests import connection_class, EVENT_LOOP_MANAGER
@@ -299,6 +301,8 @@ def get_unsupported_lower_protocol():
299301
This is used to determine the lowest protocol version that is NOT
300302
supported by the version of C* running
301303
"""
304+
if SCYLLA_VERSION is not None:
305+
return 2
302306
if CASSANDRA_VERSION >= Version('3.0'):
303307
return 2
304308
else:
@@ -310,7 +314,8 @@ def get_unsupported_upper_protocol():
310314
This is used to determine the highest protocol version that is NOT
311315
supported by the version of C* running
312316
"""
313-
317+
if SCYLLA_VERSION is not None:
318+
return 5
314319
if CASSANDRA_VERSION >= Version('4.0-a'):
315320
if DSE_VERSION:
316321
return None
@@ -389,6 +394,39 @@ def _id_and_mark(f):
389394
requires_custom_payload = pytest.mark.skipif(SCYLLA_VERSION is not None or PROTOCOL_VERSION < 4,
390395
reason='Scylla does not support custom payloads. Cassandra requires native protocol v4.0+')
391396
xfail_scylla = lambda reason, *args, **kwargs: pytest.mark.xfail(SCYLLA_VERSION is not None, reason=reason, *args, **kwargs)
397+
398+
def is_scylla_enterprise(version: Version) -> bool:
399+
return version > Version('2000.1.1')
400+
401+
def xfail_scylla_version_lt(reason, oss_scylla_version, ent_scylla_version, *args, **kwargs):
402+
"""
403+
It is used to mark tests that are going to fail on certain scylla versions.
404+
405+
:param reason: message to fail test with
406+
:param oss_scylla_version: str, oss version from which test supposed to succeed
407+
:param ent_scylla_version: str, enterprise version from which test supposed to succeed. It should end with `.1.1`
408+
"""
409+
if not reason.startswith("scylladb/scylladb#"):
410+
raise ValueError('reason should start with scylladb/scylladb#<issue-id> to reference issue in scylla repo')
411+
412+
if not isinstance(ent_scylla_version, str):
413+
raise ValueError('ent_scylla_version should be a str')
414+
415+
if not ent_scylla_version.endswith("1.1"):
416+
raise ValueError('ent_scylla_version should end with "1.1"')
417+
418+
if SCYLLA_VERSION is None:
419+
return pytest.mark.skipif(False, reason="It is just a NoOP Decor, should not skip anything")
420+
421+
current_version = Version(get_scylla_version(SCYLLA_VERSION))
422+
423+
if is_scylla_enterprise(current_version):
424+
return pytest.mark.xfail(current_version < Version(ent_scylla_version),
425+
reason=reason, *args, **kwargs)
426+
427+
return pytest.mark.xfail(current_version < Version(oss_scylla_version), reason=reason, *args, **kwargs)
428+
429+
392430
incorrect_test = lambda reason='This test seems to be incorrect and should be fixed', *args, **kwargs: pytest.mark.xfail(reason=reason, *args, **kwargs)
393431

394432
pypy = unittest.skipUnless(platform.python_implementation() == "PyPy", "Test is skipped unless it's on PyPy")

tests/integration/standard/test_cluster.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from tests.integration import use_cluster, get_server_versions, CASSANDRA_VERSION, \
4343
execute_until_pass, execute_with_long_wait_retry, get_node, MockLoggingHandler, get_unsupported_lower_protocol, \
4444
get_unsupported_upper_protocol, lessthanprotocolv3, protocolv6, local, CASSANDRA_IP, greaterthanorequalcass30, \
45-
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, xfail_scylla, incorrect_test
45+
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, incorrect_test
4646
from tests.integration.util import assert_quiescent_pool_state
4747
import sys
4848

@@ -288,7 +288,6 @@ def test_protocol_negotiation(self):
288288

289289
cluster.shutdown()
290290

291-
@xfail_scylla("Failing with scylla because there is option to create a cluster with 'lower bound' protocol")
292291
def test_invalid_protocol_negotation(self):
293292
"""
294293
Test for protocol negotiation when explicit versions are set

tests/integration/standard/test_metadata.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
greaterthancass21, assert_startswith, greaterthanorequalcass40,
4343
greaterthanorequaldse67, lessthancass40,
4444
TestCluster, DSE_VERSION, requires_java_udf, requires_composite_type,
45-
requires_collection_indexes, SCYLLA_VERSION)
45+
requires_collection_indexes, SCYLLA_VERSION, xfail_scylla_version_lt)
4646

4747
from tests.util import wait_until
4848

@@ -504,7 +504,8 @@ def test_indexes(self):
504504
self.assertIn('CREATE INDEX e_index', statement)
505505

506506
@greaterthancass21
507-
@requires_collection_indexes
507+
@xfail_scylla_version_lt('scylladb/scylladb#19278 - index functions are not included to DESCRIBE',
508+
oss_scylla_version='6.0.3', ent_scylla_version='2025.1.1')
508509
def test_collection_indexes(self):
509510

510511
self.session.execute("CREATE TABLE %s.%s (a int PRIMARY KEY, b map<text, text>)"
@@ -1207,7 +1208,8 @@ def test_export_keyspace_schema_udts(self):
12071208
cluster.shutdown()
12081209

12091210
@greaterthancass21
1210-
@pytest.mark.xfail(reason='Column name in CREATE INDEX is not quoted. It\'s a bug in driver or in Scylla')
1211+
@xfail_scylla_version_lt(reason='scylladb/scylladb#10707 - Column name in CREATE INDEX is not quoted',
1212+
oss_scylla_version="5.2", ent_scylla_version="2023.1.1")
12111213
def test_case_sensitivity(self):
12121214
"""
12131215
Test that names that need to be escaped in CREATE statements are

0 commit comments

Comments
 (0)