1313# limitations under the License.
1414
1515import os
16+ from distutils .log import fatal
17+
1618from cassandra .cluster import Cluster
1719
1820from 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):
389394requires_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+' )
391396xfail_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+
392430incorrect_test = lambda reason = 'This test seems to be incorrect and should be fixed' , * args , ** kwargs : pytest .mark .xfail (reason = reason , * args , ** kwargs )
393431
394432pypy = unittest .skipUnless (platform .python_implementation () == "PyPy" , "Test is skipped unless it's on PyPy" )
0 commit comments