13
13
# limitations under the License.
14
14
15
15
import os
16
+ from distutils .log import fatal
17
+
16
18
from cassandra .cluster import Cluster
17
19
18
20
from tests import connection_class , EVENT_LOOP_MANAGER
@@ -299,6 +301,8 @@ def get_unsupported_lower_protocol():
299
301
This is used to determine the lowest protocol version that is NOT
300
302
supported by the version of C* running
301
303
"""
304
+ if SCYLLA_VERSION is not None :
305
+ return 2
302
306
if CASSANDRA_VERSION >= Version ('3.0' ):
303
307
return 2
304
308
else :
@@ -310,7 +314,8 @@ def get_unsupported_upper_protocol():
310
314
This is used to determine the highest protocol version that is NOT
311
315
supported by the version of C* running
312
316
"""
313
-
317
+ if SCYLLA_VERSION is not None :
318
+ return 5
314
319
if CASSANDRA_VERSION >= Version ('4.0-a' ):
315
320
if DSE_VERSION :
316
321
return None
@@ -389,6 +394,62 @@ def _id_and_mark(f):
389
394
requires_custom_payload = pytest .mark .skipif (SCYLLA_VERSION is not None or PROTOCOL_VERSION < 4 ,
390
395
reason = 'Scylla does not support custom payloads. Cassandra requires native protocol v4.0+' )
391
396
xfail_scylla = lambda reason , * args , ** kwargs : pytest .mark .xfail (SCYLLA_VERSION is not None , reason = reason , * args , ** kwargs )
397
+
398
+
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
+ :param reason: message to fail test with
404
+ :param oss_scylla_version: str, oss version from which test supposed to succeed
405
+ :param ent_scylla_version: str|list<str>|tuple<str>, enterprise versions from which test supposed to succeed.
406
+ Should contain at least first major: `x.1.1` or `x.1` or `x`.
407
+ If current version is lower than `first major` it expects it to fail
408
+ For rest versions it looks for a version with same `major` and `minor` if records exists and `micro` is less,
409
+ it expects it to fail, otherwise expects it to succeed.
410
+ """
411
+ if not reason .startswith ("scylladb/scylladb#" ):
412
+ raise ValueError ('reason should start with scylladb/scylladb#<issue-id> to reference issue in scylla repo' )
413
+
414
+ if not isinstance (ent_scylla_version , (tuple , list )):
415
+ ent_scylla_version = (ent_scylla_version ,)
416
+ first_major = None
417
+ ent_scylla_version = [Version (v ) for v in ent_scylla_version ]
418
+
419
+ # Enterprise releases are tricky, here are the rules:
420
+ # 1. If something is fixed in `a.b.c` it is also fixed in `a.b.d` where `c <= d`
421
+ # 2. If something is fixed in `a.1.1` it is also fixed in `c.d.f` where `Version(a.1.1)` <= `Version(c.d.f`)`
422
+ # To make version matching work properly of enterprise we need to have a first major version `x.1.1` where it was fixed.
423
+ for ent_v in ent_scylla_version :
424
+ if ent_v .minor in (1 ,0 ) and ent_v .micro in (1 ,0 ):
425
+ first_major = Version (str (ent_v .major )+ "0.0" )
426
+
427
+ if not first_major :
428
+ raise ValueError ("ent_scylla_version should contain first major LTS: `x.1.1`" )
429
+
430
+ if SCYLLA_VERSION is None :
431
+ return pytest .mark .skipif (False , reason = "It is just a NoOP Decor, should not skip anything" )
432
+
433
+ current_version = Version (get_scylla_version (SCYLLA_VERSION ) if SCYLLA_VERSION is not None else '0.0.0' )
434
+ is_enterprise = current_version > Version ("2018.1" )
435
+ if not is_enterprise :
436
+ return pytest .mark .xfail (current_version < Version (oss_scylla_version ),
437
+ reason = reason , * args , ** kwargs )
438
+
439
+ if first_major < current_version :
440
+ # Expect test to fail if it is less then first major
441
+ return pytest .mark .xfail (False , reason = reason , * args , ** kwargs )
442
+
443
+ for ent_v in ent_scylla_version :
444
+ # Expect test to fail if there is any record with same major and minor and micro is higher
445
+ if ent_v .major == current_version .major and ent_v .minor == current_version .minor :
446
+ return pytest .mark .xfail (current_version < ent_v , reason = reason , * args , ** kwargs )
447
+
448
+ # Noop
449
+ # Expect test to complete successfully
450
+ return pytest .mark .xfail (True , reason = reason , * args , ** kwargs )
451
+
452
+
392
453
incorrect_test = lambda reason = 'This test seems to be incorrect and should be fixed' , * args , ** kwargs : pytest .mark .xfail (reason = reason , * args , ** kwargs )
393
454
394
455
pypy = unittest .skipUnless (platform .python_implementation () == "PyPy" , "Test is skipped unless it's on PyPy" )
0 commit comments