Skip to content

Commit 2479b98

Browse files
committed
fix
1 parent 0178bb6 commit 2479b98

File tree

4 files changed

+51
-16
lines changed

4 files changed

+51
-16
lines changed

tests/integration/__init__.py

Lines changed: 44 additions & 8 deletions
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
@@ -391,14 +396,45 @@ def _id_and_mark(f):
391396
xfail_scylla = lambda reason, *args, **kwargs: pytest.mark.xfail(SCYLLA_VERSION is not None, reason=reason, *args, **kwargs)
392397

393398

394-
def xfail_scylla_version(reason, oss_scylla_version, ent_scylla_version, *args, **kwargs):
399+
def xfail_scylla_version_lt(reason, oss_scylla_version, ent_scylla_version, *args, **kwargs):
400+
"""
401+
It is used to mark tests that are going to fail on certain scylla versions.
402+
403+
ent_scylla_version should contain at least first major: `x.1.1` or `x.1` or `x`
404+
"""
405+
if not isinstance(ent_scylla_version, (tuple, list)):
406+
ent_scylla_version = (ent_scylla_version,)
407+
first_major = None
408+
ent_scylla_version = [Version(v) for v in ent_scylla_version]
409+
410+
# Enterprise releases are tricky, here are the rules:
411+
# 1. If something is fixed in `a.b.c` it is also fixed in `a.b.d` where c < d
412+
# 2. If something is fixed in `a.1.1` it is also fixed in `c.d.f` where Version(a.b.1) < Version(`c.d.f`)
413+
# To make version matching work properly of enterprise we need to have a first major version (`x.1.1`) where it was fixed, in addition to exact version.
414+
for ent_v in ent_scylla_version:
415+
if ent_v.minor in (1,0) and ent_v.micro in (1,0):
416+
first_major = ent_v
417+
418+
if not first_major:
419+
raise ValueError("ent_scylla_version should contain not only exact version where issue has been fixed, but also first major: `x.1.1`")
420+
421+
if SCYLLA_VERSION is None:
422+
return pytest.mark.skipif(False, reason="It is just a NoOP Decor, should not skip anything")
423+
395424
current_version = Version(get_scylla_version(SCYLLA_VERSION) if SCYLLA_VERSION is not None else '0.0.0')
396-
if current_version > Version("2018.1"):
397-
lt_scylla_version = Version(ent_scylla_version)
398-
else:
399-
lt_scylla_version = Version(oss_scylla_version)
400-
return pytest.mark.xfail(current_version < lt_scylla_version,
401-
reason=reason, *args, **kwargs)
425+
is_enterprise = current_version > Version("2018.1")
426+
if not is_enterprise:
427+
return pytest.mark.xfail(current_version < Version(oss_scylla_version),
428+
reason=reason, *args, **kwargs)
429+
430+
if first_major <= current_version:
431+
return pytest.mark.xfail(False, reason=reason, *args, **kwargs)
432+
433+
for ent_v in ent_scylla_version:
434+
if ent_v.major == current_version.major and ent_v.minor == current_version.minor:
435+
return pytest.mark.xfail(current_version < ent_v, reason=reason, *args, **kwargs)
436+
return pytest.mark.xfail(True, reason=reason, *args, **kwargs)
437+
402438

403439
incorrect_test = lambda reason='This test seems to be incorrect and should be fixed', *args, **kwargs: pytest.mark.xfail(reason=reason, *args, **kwargs)
404440

tests/integration/simulacron/test_cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import unittest
1515

1616
import logging
17-
from packaging.version import Version
17+
from packaging.version import Version, VersionComparisonMethod
1818

1919
import cassandra
2020
from tests.integration.simulacron import SimulacronCluster, SimulacronBase

tests/integration/standard/test_cluster.py

Lines changed: 1 addition & 3 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_version, incorrect_test
45+
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, xfail_scylla_version_lt, incorrect_test
4646
from tests.integration.util import assert_quiescent_pool_state
4747
import sys
4848

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

289289
cluster.shutdown()
290290

291-
@xfail_scylla_version("Failing with scylla because there is option to create a cluster with 'lower bound' protocol",
292-
oss_scylla_version="5.2", ent_scylla_version="2023.1")
293291
def test_invalid_protocol_negotation(self):
294292
"""
295293
Test for protocol negotiation when explicit versions are set

tests/integration/standard/test_metadata.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
greaterthancass21, assert_startswith, greaterthanorequalcass40,
4141
greaterthanorequaldse67, lessthancass40,
4242
TestCluster, DSE_VERSION, requires_java_udf, requires_composite_type,
43-
requires_collection_indexes, xfail_scylla, xfail_scylla_version)
43+
requires_collection_indexes, xfail_scylla, xfail_scylla_version_lt)
4444

4545
from tests.util import wait_until
4646

@@ -501,7 +501,8 @@ def test_indexes(self):
501501
self.assertIn('CREATE INDEX e_index', statement)
502502

503503
@greaterthancass21
504-
@xfail_scylla_version('failing cause of scylladb/scylladb#19278', oss_scylla_version='6.1', ent_scylla_version='2025.1')
504+
@xfail_scylla_version_lt('scylladb/scylladb#19278 - index functions are not included to DESCRIBE',
505+
oss_scylla_version='6.0.3', ent_scylla_version='2025.1')
505506
def test_collection_indexes(self):
506507

507508
self.session.execute("CREATE TABLE %s.%s (a int PRIMARY KEY, b map<text, text>)"
@@ -1204,8 +1205,8 @@ def test_export_keyspace_schema_udts(self):
12041205
cluster.shutdown()
12051206

12061207
@greaterthancass21
1207-
@xfail_scylla_version(reason='Column name in CREATE INDEX is not quoted. It\'s a bug in driver or in Scylla',
1208-
oss_scylla_version="5.2", ent_scylla_version="2023.1")
1208+
@xfail_scylla_version_lt(reason='scylladb/scylladb#10707 - Column name in CREATE INDEX is not quoted',
1209+
oss_scylla_version="5.2", ent_scylla_version="2023.1")
12091210
def test_case_sensitivity(self):
12101211
"""
12111212
Test that names that need to be escaped in CREATE statements are

0 commit comments

Comments
 (0)