Skip to content

Commit def770c

Browse files
committed
Integration test: clearer skip/xfail labels
Many tests failing on Scylla were labeled with unconditional xfail. This has some problems: - It's hard to tell why a test was marked. - When some functionality is implemented in Scylla, we don't have an easy way to reenable tests that use this functionality. - Test is skipped also when testing with Cassandra This commit introduces more labels for failing tests. It fixes those problems: - Label name and reason string explain why test is disabled - We can edit label definition to enable tests on newer Scylla version - Tests are only skipped in environment where they are expected to fail
1 parent 45c4f50 commit def770c

File tree

7 files changed

+41
-41
lines changed

7 files changed

+41
-41
lines changed

tests/integration/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ def _id_and_mark(f):
344344
local = local_decorator_creator()
345345
notprotocolv1 = unittest.skipUnless(PROTOCOL_VERSION > 1, 'Protocol v1 not supported')
346346
lessthenprotocolv4 = unittest.skipUnless(PROTOCOL_VERSION < 4, 'Protocol versions 4 or greater not supported')
347+
lessthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION < 3, 'Protocol versions 3 or greater not supported')
347348
greaterthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION >= 4, 'Protocol versions less than 4 are not supported')
348349
protocolv6 = unittest.skipUnless(6 in get_supported_protocol_versions(), 'Protocol versions less than 6 are not supported')
349350

@@ -375,6 +376,14 @@ def _id_and_mark(f):
375376
reason='Scylla supports collection indexes from 5.2 onwards')
376377
requires_custom_indexes = pytest.mark.xfail(SCYLLA_VERSION is not None,
377378
reason='Scylla does not support SASI or any other CUSTOM INDEX class')
379+
requires_java_udf = pytest.mark.xfail(SCYLLA_VERSION is not None,
380+
reason='Scylla does not support UDFs written in Java')
381+
requires_composite_type = pytest.mark.xfail(SCYLLA_VERSION is not None,
382+
reason='Scylla does not support composite types')
383+
requires_custom_payload = pytest.mark.xfail(SCYLLA_VERSION is not None or PROTOCOL_VERSION < 4,
384+
reason='Scylla does not support custom payloads. Cassandra requires native protocol v4.0+')
385+
xfail_scylla = lambda reason, *args, **kwargs: pytest.mark.xfail(SCYLLA_VERSION is not None, reason=reason, *args, **kwargs)
386+
incorrect_test = lambda reason='This test seems to be incorrect and should be fixed', *args, **kwargs: pytest.mark.xfail(reason=reason, *args, **kwargs)
378387

379388
pypy = unittest.skipUnless(platform.python_implementation() == "PyPy", "Test is skipped unless it's on PyPy")
380389
notpy3 = unittest.skipIf(sys.version_info >= (3, 0), "Test not applicable for Python 3.x runtime")

tests/integration/standard/test_client_warnings.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
import six
1919
from cassandra.query import BatchStatement
2020

21-
from tests.integration import use_singledc, PROTOCOL_VERSION, local, TestCluster
21+
from tests.integration import (use_singledc, PROTOCOL_VERSION, local, TestCluster,
22+
requires_custom_payload, xfail_scylla)
2223

2324

2425
def setup_module():
@@ -27,7 +28,7 @@ def setup_module():
2728

2829
# Failing with scylla because there is no warning message when changing the value of 'batch_size_warn_threshold_in_kb'
2930
# config")
30-
@unittest.expectedFailure
31+
@xfail_scylla('Empty warnings: TypeError: object of type \'NoneType\' has no len()')
3132
class ClientWarningTests(unittest.TestCase):
3233

3334
@classmethod
@@ -94,6 +95,7 @@ def test_warning_with_trace(self):
9495
self.assertIsNotNone(future.get_query_trace())
9596

9697
@local
98+
@requires_custom_payload
9799
def test_warning_with_custom_payload(self):
98100
"""
99101
Test to validate client warning with custom payload
@@ -113,6 +115,7 @@ def test_warning_with_custom_payload(self):
113115
self.assertDictEqual(future.custom_payload, payload)
114116

115117
@local
118+
@requires_custom_payload
116119
def test_warning_with_trace_and_custom_payload(self):
117120
"""
118121
Test to validate client warning with tracing and client warning

tests/integration/standard/test_cluster.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@
4242
from tests import notwindows
4343
from tests.integration import use_singledc, get_server_versions, CASSANDRA_VERSION, \
4444
execute_until_pass, execute_with_long_wait_retry, get_node, MockLoggingHandler, get_unsupported_lower_protocol, \
45-
get_unsupported_upper_protocol, protocolv6, local, CASSANDRA_IP, greaterthanorequalcass30, lessthanorequalcass40, \
46-
DSE_VERSION, TestCluster, PROTOCOL_VERSION
45+
get_unsupported_upper_protocol, lessthanprotocolv3, protocolv6, local, CASSANDRA_IP, greaterthanorequalcass30, \
46+
lessthanorequalcass40, DSE_VERSION, TestCluster, PROTOCOL_VERSION, xfail_scylla, incorrect_test
4747
from tests.integration.util import assert_quiescent_pool_state
4848
import sys
4949

@@ -289,8 +289,7 @@ def test_protocol_negotiation(self):
289289

290290
cluster.shutdown()
291291

292-
# "Failing with scylla because there is option to create a cluster with 'lower bound' protocol
293-
@unittest.expectedFailure
292+
@xfail_scylla("Failing with scylla because there is option to create a cluster with 'lower bound' protocol")
294293
def test_invalid_protocol_negotation(self):
295294
"""
296295
Test for protocol negotiation when explicit versions are set
@@ -411,12 +410,11 @@ def test_connect_to_bad_hosts(self):
411410
protocol_version=PROTOCOL_VERSION)
412411
self.assertRaises(NoHostAvailable, cluster.connect)
413412

413+
@lessthanprotocolv3
414414
def test_cluster_settings(self):
415415
"""
416416
Test connection setting getters and setters
417417
"""
418-
if PROTOCOL_VERSION >= 3:
419-
raise unittest.SkipTest("min/max requests and core/max conns aren't used with v3 protocol")
420418

421419
cluster = TestCluster()
422420

@@ -1228,8 +1226,7 @@ def test_replicas_are_queried(self):
12281226

12291227
@greaterthanorequalcass30
12301228
@lessthanorequalcass40
1231-
# The scylla failed because 'Unknown identifier column1'
1232-
@unittest.expectedFailure
1229+
@incorrect_test()
12331230
def test_compact_option(self):
12341231
"""
12351232
Test the driver can connect with the no_compact option and the results

tests/integration/standard/test_custom_payload.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
from cassandra.query import (SimpleStatement, BatchStatement, BatchType)
2121

22-
from tests.integration import use_singledc, PROTOCOL_VERSION, local, TestCluster
22+
from tests.integration import (use_singledc, PROTOCOL_VERSION, local, TestCluster,
23+
requires_custom_payload)
2324

2425

2526
def setup_module():
@@ -28,13 +29,10 @@ def setup_module():
2829
#These test rely on the custom payload being returned but by default C*
2930
#ignores all the payloads.
3031
@local
32+
@requires_custom_payload
3133
class CustomPayloadTests(unittest.TestCase):
3234

3335
def setUp(self):
34-
if PROTOCOL_VERSION < 4:
35-
raise unittest.SkipTest(
36-
"Native protocol 4,0+ is required for custom payloads, currently using %r"
37-
% (PROTOCOL_VERSION,))
3836
self.cluster = TestCluster()
3937
self.session = self.cluster.connect()
4038

@@ -43,7 +41,6 @@ def tearDown(self):
4341
self.cluster.shutdown()
4442

4543
# Scylla error: 'truncated frame: expected 65540 bytes, length is 64'
46-
@unittest.expectedFailure
4744
def test_custom_query_basic(self):
4845
"""
4946
Test to validate that custom payloads work with simple queries
@@ -67,7 +64,6 @@ def test_custom_query_basic(self):
6764
self.validate_various_custom_payloads(statement=statement)
6865

6966
# Scylla error: 'Invalid query kind in BATCH messages. Must be 0 or 1 but got 4'"
70-
@unittest.expectedFailure
7167
def test_custom_query_batching(self):
7268
"""
7369
Test to validate that custom payloads work with batch queries
@@ -94,7 +90,6 @@ def test_custom_query_batching(self):
9490

9591
# Scylla error: 'Got different query ID in server response (b'\x00') than we had before
9692
# (b'\x84P\xd0K0\xe2=\x11\xba\x02\x16W\xfatN\xf1')'")
97-
@unittest.expectedFailure
9893
def test_custom_query_prepared(self):
9994
"""
10095
Test to validate that custom payloads work with prepared queries

tests/integration/standard/test_metadata.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
get_supported_protocol_versions, greaterthancass20,
4040
greaterthancass21, assert_startswith, greaterthanorequalcass40,
4141
greaterthanorequaldse67, lessthancass40,
42-
TestCluster, DSE_VERSION)
42+
TestCluster, DSE_VERSION, requires_java_udf, requires_composite_type,
43+
requires_collection_indexes, xfail_scylla)
4344

4445
from tests.util import wait_until
4546

@@ -474,7 +475,7 @@ def test_counter_with_dense_compact_storage(self):
474475
tablemeta = self.get_table_metadata()
475476
self.check_create_statement(tablemeta, create_statement)
476477

477-
@unittest.expectedFailure
478+
@xfail_scylla('https://github.com/scylladb/scylladb/issues/6058')
478479
def test_indexes(self):
479480
create_statement = self.make_create_statement(["a"], ["b", "c"], ["d", "e", "f"])
480481
create_statement += " WITH CLUSTERING ORDER BY (b ASC, c ASC)"
@@ -500,7 +501,7 @@ def test_indexes(self):
500501
self.assertIn('CREATE INDEX e_index', statement)
501502

502503
@greaterthancass21
503-
@unittest.expectedFailure
504+
@requires_collection_indexes
504505
def test_collection_indexes(self):
505506

506507
self.session.execute("CREATE TABLE %s.%s (a int PRIMARY KEY, b map<text, text>)"
@@ -530,7 +531,8 @@ def test_collection_indexes(self):
530531
tablemeta = self.get_table_metadata()
531532
self.assertIn('(full(b))', tablemeta.export_as_string())
532533

533-
@unittest.expectedFailure
534+
#TODO: Fix Scylla or test
535+
@xfail_scylla('Scylla prints `compression = {}` instead of `compression = {\'enabled\': \'false\'}`.')
534536
def test_compression_disabled(self):
535537
create_statement = self.make_create_statement(["a"], ["b"], ["c"])
536538
create_statement += " WITH compression = {}"
@@ -565,7 +567,7 @@ def test_non_size_tiered_compaction(self):
565567
self.assertNotIn("min_threshold", cql)
566568
self.assertNotIn("max_threshold", cql)
567569

568-
@unittest.expectedFailure
570+
@requires_java_udf
569571
def test_refresh_schema_metadata(self):
570572
"""
571573
test for synchronously refreshing all cluster metadata
@@ -838,7 +840,7 @@ def test_refresh_user_type_metadata_proto_2(self):
838840
self.assertEqual(cluster.metadata.keyspaces[self.keyspace_name].user_types, {})
839841
cluster.shutdown()
840842

841-
@unittest.expectedFailure
843+
@requires_java_udf
842844
def test_refresh_user_function_metadata(self):
843845
"""
844846
test for synchronously refreshing UDF metadata in keyspace
@@ -875,7 +877,7 @@ def test_refresh_user_function_metadata(self):
875877

876878
cluster2.shutdown()
877879

878-
@unittest.expectedFailure
880+
@requires_java_udf
879881
def test_refresh_user_aggregate_metadata(self):
880882
"""
881883
test for synchronously refreshing UDA metadata in keyspace
@@ -919,7 +921,7 @@ def test_refresh_user_aggregate_metadata(self):
919921
cluster2.shutdown()
920922

921923
@greaterthanorequalcass30
922-
@unittest.expectedFailure
924+
@requires_collection_indexes
923925
def test_multiple_indices(self):
924926
"""
925927
test multiple indices on the same column.
@@ -1544,7 +1546,7 @@ def __init__(self, test_case, **kwargs):
15441546
super(FunctionTest.VerifiedAggregate, self).__init__(test_case, Aggregate, test_case.keyspace_aggregate_meta, **kwargs)
15451547

15461548

1547-
@unittest.expectedFailure
1549+
@requires_java_udf
15481550
class FunctionMetadata(FunctionTest):
15491551

15501552
def make_function_kwargs(self, called_on_null=True):
@@ -1699,6 +1701,7 @@ def test_function_cql_called_on_null(self):
16991701
self.assertRegex(fn_meta.as_cql_query(), "CREATE FUNCTION.*\) RETURNS NULL ON NULL INPUT RETURNS .*")
17001702

17011703

1704+
@requires_java_udf
17021705
class AggregateMetadata(FunctionTest):
17031706

17041707
@classmethod
@@ -1743,7 +1746,6 @@ def make_aggregate_kwargs(self, state_func, state_type, final_func=None, init_co
17431746
'return_type': "does not matter for creation",
17441747
'deterministic': False}
17451748

1746-
@unittest.expectedFailure
17471749
def test_return_type_meta(self):
17481750
"""
17491751
Test to verify to that the return type of a an aggregate is honored in the metadata
@@ -1761,7 +1763,6 @@ def test_return_type_meta(self):
17611763
with self.VerifiedAggregate(self, **self.make_aggregate_kwargs('sum_int', 'int', init_cond='1')) as va:
17621764
self.assertEqual(self.keyspace_aggregate_meta[va.signature].return_type, 'int')
17631765

1764-
@unittest.expectedFailure
17651766
def test_init_cond(self):
17661767
"""
17671768
Test to verify that various initial conditions are correctly surfaced in various aggregate functions
@@ -1812,7 +1813,6 @@ def test_init_cond(self):
18121813
self.assertDictContainsSubset(init_not_updated, map_res)
18131814
c.shutdown()
18141815

1815-
@unittest.expectedFailure
18161816
def test_aggregates_after_functions(self):
18171817
"""
18181818
Test to verify that aggregates are listed after function in metadata
@@ -1835,7 +1835,6 @@ def test_aggregates_after_functions(self):
18351835
self.assertNotIn(-1, (aggregate_idx, func_idx), "AGGREGATE or FUNCTION not found in keyspace_cql: " + keyspace_cql)
18361836
self.assertGreater(aggregate_idx, func_idx)
18371837

1838-
@unittest.expectedFailure
18391838
def test_same_name_diff_types(self):
18401839
"""
18411840
Test to verify to that aggregates with different signatures are differentiated in metadata
@@ -1858,7 +1857,6 @@ def test_same_name_diff_types(self):
18581857
self.assertEqual(len(aggregates), 2)
18591858
self.assertNotEqual(aggregates[0].argument_types, aggregates[1].argument_types)
18601859

1861-
@unittest.expectedFailure
18621860
def test_aggregates_follow_keyspace_alter(self):
18631861
"""
18641862
Test to verify to that aggregates maintain equality after a keyspace is altered
@@ -1883,7 +1881,6 @@ def test_aggregates_follow_keyspace_alter(self):
18831881
finally:
18841882
self.session.execute('ALTER KEYSPACE %s WITH durable_writes = true' % self.keyspace_name)
18851883

1886-
@unittest.expectedFailure
18871884
def test_cql_optional_params(self):
18881885
"""
18891886
Test to verify that the initial_cond and final_func parameters are correctly honored
@@ -2018,7 +2015,7 @@ def test_bad_user_type(self):
20182015
self.assertIn("/*\nWarning:", m.export_as_string())
20192016

20202017
@greaterthancass21
2021-
@unittest.expectedFailure
2018+
@requires_java_udf
20222019
def test_bad_user_function(self):
20232020
self.session.execute("""CREATE FUNCTION IF NOT EXISTS %s (key int, val int)
20242021
RETURNS NULL ON NULL INPUT
@@ -2037,7 +2034,7 @@ def test_bad_user_function(self):
20372034
self.assertIn("/*\nWarning:", m.export_as_string())
20382035

20392036
@greaterthancass21
2040-
@unittest.expectedFailure
2037+
@requires_java_udf
20412038
def test_bad_user_aggregate(self):
20422039
self.session.execute("""CREATE FUNCTION IF NOT EXISTS sum_int (key int, val int)
20432040
RETURNS NULL ON NULL INPUT
@@ -2058,7 +2055,7 @@ def test_bad_user_aggregate(self):
20582055

20592056
class DynamicCompositeTypeTest(BasicSharedKeyspaceUnitTestCase):
20602057

2061-
@unittest.expectedFailure
2058+
@requires_composite_type
20622059
def test_dct_alias(self):
20632060
"""
20642061
Tests to make sure DCT's have correct string formatting

tests/integration/standard/test_query.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from cassandra.policies import HostDistance, RoundRobinPolicy, WhiteListRoundRobinPolicy
2626
from tests.integration import use_singledc, PROTOCOL_VERSION, BasicSharedKeyspaceUnitTestCase, \
2727
greaterthanprotocolv3, MockLoggingHandler, get_supported_protocol_versions, local, get_cluster, setup_keyspace, \
28-
USE_CASS_EXTERNAL, greaterthanorequalcass40, DSE_VERSION, TestCluster, requirecassandra
28+
USE_CASS_EXTERNAL, greaterthanorequalcass40, DSE_VERSION, TestCluster, requirecassandra, xfail_scylla
2929
from tests import notwindows
3030
from tests.integration import greaterthanorequalcass30, get_node
3131

@@ -950,8 +950,7 @@ def test_no_connection_refused_on_timeout(self):
950950
# Make sure test passed
951951
self.assertTrue(received_timeout)
952952

953-
# Failed on Scylla because error `SERIAL/LOCAL_SERIAL consistency may only be requested for one partition at a time`
954-
@unittest.expectedFailure
953+
@xfail_scylla('Fails on Scylla with error `SERIAL/LOCAL_SERIAL consistency may only be requested for one partition at a time`')
955954
def test_was_applied_batch_stmt(self):
956955
"""
957956
Test to ensure `:attr:cassandra.cluster.ResultSet.was_applied` works as expected

tests/integration/standard/test_types.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
from tests.integration import use_singledc, execute_until_pass, notprotocolv1, \
3333
BasicSharedKeyspaceUnitTestCase, greaterthancass21, lessthancass30, greaterthanorequaldse51, \
34-
DSE_VERSION, greaterthanorequalcass3_10, requiredse, TestCluster
34+
DSE_VERSION, greaterthanorequalcass3_10, requiredse, TestCluster, requires_composite_type
3535
from tests.integration.datatype_utils import update_datatypes, PRIMITIVE_DATATYPES, COLLECTION_TYPES, PRIMITIVE_DATATYPES_KEYS, \
3636
get_sample, get_all_samples, get_collection_sample
3737

@@ -731,7 +731,7 @@ def test_can_insert_unicode_query_string(self):
731731
s.execute(u"SELECT * FROM system.local WHERE key = 'ef\u2052ef'")
732732
s.execute(u"SELECT * FROM system.local WHERE key = %s", (u"fe\u2051fe",))
733733

734-
@unittest.expectedFailure
734+
@requires_composite_type
735735
def test_can_read_composite_type(self):
736736
"""
737737
Test to ensure that CompositeTypes can be used in a query

0 commit comments

Comments
 (0)