Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dkropachev committed Aug 15, 2024
1 parent 0178bb6 commit 2479b98
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 16 deletions.
52 changes: 44 additions & 8 deletions tests/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# limitations under the License.

import os
from distutils.log import fatal

from cassandra.cluster import Cluster

from tests import connection_class, EVENT_LOOP_MANAGER
Expand Down Expand Up @@ -299,6 +301,8 @@ def get_unsupported_lower_protocol():
This is used to determine the lowest protocol version that is NOT
supported by the version of C* running
"""
if SCYLLA_VERSION is not None:
return 2
if CASSANDRA_VERSION >= Version('3.0'):
return 2
else:
Expand All @@ -310,7 +314,8 @@ def get_unsupported_upper_protocol():
This is used to determine the highest protocol version that is NOT
supported by the version of C* running
"""

if SCYLLA_VERSION is not None:
return 5
if CASSANDRA_VERSION >= Version('4.0-a'):
if DSE_VERSION:
return None
Expand Down Expand Up @@ -391,14 +396,45 @@ def _id_and_mark(f):
xfail_scylla = lambda reason, *args, **kwargs: pytest.mark.xfail(SCYLLA_VERSION is not None, reason=reason, *args, **kwargs)


def xfail_scylla_version(reason, oss_scylla_version, ent_scylla_version, *args, **kwargs):
def xfail_scylla_version_lt(reason, oss_scylla_version, ent_scylla_version, *args, **kwargs):
"""
It is used to mark tests that are going to fail on certain scylla versions.
ent_scylla_version should contain at least first major: `x.1.1` or `x.1` or `x`
"""
if not isinstance(ent_scylla_version, (tuple, list)):
ent_scylla_version = (ent_scylla_version,)
first_major = None
ent_scylla_version = [Version(v) for v in ent_scylla_version]

# Enterprise releases are tricky, here are the rules:
# 1. If something is fixed in `a.b.c` it is also fixed in `a.b.d` where c < d
# 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`)
# 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.
for ent_v in ent_scylla_version:
if ent_v.minor in (1,0) and ent_v.micro in (1,0):
first_major = ent_v

if not first_major:
raise ValueError("ent_scylla_version should contain not only exact version where issue has been fixed, but also first major: `x.1.1`")

if SCYLLA_VERSION is None:
return pytest.mark.skipif(False, reason="It is just a NoOP Decor, should not skip anything")

current_version = Version(get_scylla_version(SCYLLA_VERSION) if SCYLLA_VERSION is not None else '0.0.0')
if current_version > Version("2018.1"):
lt_scylla_version = Version(ent_scylla_version)
else:
lt_scylla_version = Version(oss_scylla_version)
return pytest.mark.xfail(current_version < lt_scylla_version,
reason=reason, *args, **kwargs)
is_enterprise = current_version > Version("2018.1")
if not is_enterprise:
return pytest.mark.xfail(current_version < Version(oss_scylla_version),
reason=reason, *args, **kwargs)

if first_major <= current_version:
return pytest.mark.xfail(False, reason=reason, *args, **kwargs)

for ent_v in ent_scylla_version:
if ent_v.major == current_version.major and ent_v.minor == current_version.minor:
return pytest.mark.xfail(current_version < ent_v, reason=reason, *args, **kwargs)
return pytest.mark.xfail(True, reason=reason, *args, **kwargs)


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

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/simulacron/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import unittest

import logging
from packaging.version import Version
from packaging.version import Version, VersionComparisonMethod

import cassandra
from tests.integration.simulacron import SimulacronCluster, SimulacronBase
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/standard/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from tests.integration import use_cluster, get_server_versions, CASSANDRA_VERSION, \
execute_until_pass, execute_with_long_wait_retry, get_node, MockLoggingHandler, get_unsupported_lower_protocol, \
get_unsupported_upper_protocol, lessthanprotocolv3, protocolv6, local, CASSANDRA_IP, greaterthanorequalcass30, \
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, xfail_scylla_version, incorrect_test
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, xfail_scylla_version_lt, incorrect_test
from tests.integration.util import assert_quiescent_pool_state
import sys

Expand Down Expand Up @@ -288,8 +288,6 @@ def test_protocol_negotiation(self):

cluster.shutdown()

@xfail_scylla_version("Failing with scylla because there is option to create a cluster with 'lower bound' protocol",
oss_scylla_version="5.2", ent_scylla_version="2023.1")
def test_invalid_protocol_negotation(self):
"""
Test for protocol negotiation when explicit versions are set
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/standard/test_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
greaterthancass21, assert_startswith, greaterthanorequalcass40,
greaterthanorequaldse67, lessthancass40,
TestCluster, DSE_VERSION, requires_java_udf, requires_composite_type,
requires_collection_indexes, xfail_scylla, xfail_scylla_version)
requires_collection_indexes, xfail_scylla, xfail_scylla_version_lt)

from tests.util import wait_until

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

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

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

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

0 comments on commit 2479b98

Please sign in to comment.