From c68f40c7320be4785d795b43625566a2a6931e11 Mon Sep 17 00:00:00 2001 From: Israel Fruchter Date: Thu, 4 Jul 2024 13:40:51 +0300 Subject: [PATCH] tests: mark test which are scylla specific those test can't be run ontop of cassandra and we should mark them in a why we can skip them --- tests/integration/__init__.py | 3 ++- .../standard/test_custom_protocol_handler.py | 3 --- tests/integration/standard/test_ip_change.py | 3 ++- tests/integration/standard/test_metadata.py | 10 +++++----- tests/integration/standard/test_rate_limit_exceeded.py | 3 ++- tests/integration/standard/test_scylla_cloud.py | 4 ++-- tests/integration/standard/test_shard_aware.py | 3 ++- tests/integration/standard/test_types.py | 3 ++- 8 files changed, 17 insertions(+), 15 deletions(-) diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py index bc60bc1b75..014ab9950b 100644 --- a/tests/integration/__init__.py +++ b/tests/integration/__init__.py @@ -390,12 +390,13 @@ def _id_and_mark(f): reason='Scylla does not support custom payloads. Cassandra requires native protocol v4.0+') xfail_scylla = lambda reason, *args, **kwargs: pytest.mark.xfail(SCYLLA_VERSION is not None, 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) +scylla_only = pytest.mark.skipif(SCYLLA_VERSION is None, reason='Scylla only test') pypy = unittest.skipUnless(platform.python_implementation() == "PyPy", "Test is skipped unless it's on PyPy") requiresmallclockgranularity = unittest.skipIf("Windows" in platform.system() or "asyncore" in EVENT_LOOP_MANAGER, "This test is not suitible for environments with large clock granularity") requiressimulacron = unittest.skipIf(SIMULACRON_JAR is None or CASSANDRA_VERSION < Version("2.1"), "Simulacron jar hasn't been specified or C* version is 2.0") -requirecassandra = unittest.skipIf(DSE_VERSION, "Cassandra required") +requirecassandra = unittest.skipIf(DSE_VERSION or SCYLLA_VERSION, "Cassandra required") notdse = unittest.skipIf(DSE_VERSION, "DSE not supported") requiredse = unittest.skipUnless(DSE_VERSION, "DSE required") requirescloudproxy = unittest.skipIf(CLOUD_PROXY_PATH is None, "Cloud Proxy path hasn't been specified") diff --git a/tests/integration/standard/test_custom_protocol_handler.py b/tests/integration/standard/test_custom_protocol_handler.py index 9f3a52e256..a84b6b64cd 100644 --- a/tests/integration/standard/test_custom_protocol_handler.py +++ b/tests/integration/standard/test_custom_protocol_handler.py @@ -120,7 +120,6 @@ def test_custom_raw_row_results_all_types(self): self.assertEqual(len(CustomResultMessageTracked.checked_rev_row_set), len(PRIMITIVE_DATATYPES)-1) cluster.shutdown() - @unittest.expectedFailure @requirecassandra @greaterthanorequalcass40 def test_protocol_divergence_v5_fail_by_continuous_paging(self): @@ -168,7 +167,6 @@ def test_protocol_divergence_v4_fail_by_flag_uses_int(self): self._protocol_divergence_fail_by_flag_uses_int(ProtocolVersion.V4, uses_int_query_flag=False, int_flag=True) - @unittest.expectedFailure @requirecassandra @greaterthanorequalcass40 def test_protocol_v5_uses_flag_int(self): @@ -196,7 +194,6 @@ def test_protocol_dsev1_uses_flag_int(self): self._protocol_divergence_fail_by_flag_uses_int(ProtocolVersion.DSE_V1, uses_int_query_flag=True, int_flag=True) - @unittest.expectedFailure @requirecassandra @greaterthanorequalcass40 def test_protocol_divergence_v5_fail_by_flag_uses_int(self): diff --git a/tests/integration/standard/test_ip_change.py b/tests/integration/standard/test_ip_change.py index e87c14a1df..723a16336c 100644 --- a/tests/integration/standard/test_ip_change.py +++ b/tests/integration/standard/test_ip_change.py @@ -5,7 +5,7 @@ from cassandra.cluster import ExecutionProfile from cassandra.policies import WhiteListRoundRobinPolicy -from tests.integration import use_cluster, get_node, get_cluster, local, TestCluster +from tests.integration import use_cluster, get_node, get_cluster, local, TestCluster, scylla_only from tests.util import wait_until_not_raised LOGGER = logging.getLogger(__name__) @@ -16,6 +16,7 @@ def setup_module(): use_cluster('test_ip_change', [3], start=True) @local +@scylla_only class TestIpAddressChange(unittest.TestCase): @classmethod def setup_class(cls): diff --git a/tests/integration/standard/test_metadata.py b/tests/integration/standard/test_metadata.py index 944dd8ab20..d3ae465153 100644 --- a/tests/integration/standard/test_metadata.py +++ b/tests/integration/standard/test_metadata.py @@ -26,13 +26,13 @@ from cassandra import AlreadyExists, SignatureDescriptor, UserFunctionDescriptor, UserAggregateDescriptor from cassandra.connection import Connection - from cassandra.encoder import Encoder from cassandra.metadata import (IndexMetadata, Token, murmur3, Function, Aggregate, protect_name, protect_names, RegisteredTableExtension, _RegisteredExtensionType, get_schema_parser, group_keys_by_replica, NO_VALID_REPLICA) from cassandra.protocol import QueryMessage, ProtocolHandler from cassandra.util import SortedSet +from ccmlib.scylla_cluster import ScyllaCluster from tests.integration import (get_cluster, use_singledc, PROTOCOL_VERSION, execute_until_pass, BasicSegregatedKeyspaceUnitTestCase, BasicSharedKeyspaceUnitTestCase, @@ -42,7 +42,7 @@ greaterthancass21, assert_startswith, greaterthanorequalcass40, greaterthanorequaldse67, lessthancass40, TestCluster, DSE_VERSION, requires_java_udf, requires_composite_type, - requires_collection_indexes, SCYLLA_VERSION) + requires_collection_indexes, SCYLLA_VERSION, xfail_scylla) from tests.util import wait_until @@ -1207,7 +1207,7 @@ def test_export_keyspace_schema_udts(self): cluster.shutdown() @greaterthancass21 - @pytest.mark.xfail(reason='Column name in CREATE INDEX is not quoted. It\'s a bug in driver or in Scylla') + @xfail_scylla(reason='Column name in CREATE INDEX is not quoted. It\'s a bug in driver or in Scylla') def test_case_sensitivity(self): """ Test that names that need to be escaped in CREATE statements are @@ -1277,13 +1277,13 @@ def test_already_exists_exceptions(self): cluster.shutdown() @local - @pytest.mark.xfail(reason='AssertionError: \'RAC1\' != \'r1\' - probably a bug in driver or in Scylla') def test_replicas(self): """ Ensure cluster.metadata.get_replicas return correctly when not attached to keyspace """ if murmur3 is None: raise unittest.SkipTest('the murmur3 extension is not available') + is_scylla = isinstance(get_cluster(), ScyllaCluster) cluster = TestCluster() self.assertEqual(cluster.metadata.get_replicas('test3rf', 'key'), []) @@ -1293,7 +1293,7 @@ def test_replicas(self): self.assertNotEqual(list(cluster.metadata.get_replicas('test3rf', b'key')), []) host = list(cluster.metadata.get_replicas('test3rf', b'key'))[0] self.assertEqual(host.datacenter, 'dc1') - self.assertEqual(host.rack, 'r1') + self.assertEqual(host.rack, 'RAC1' if is_scylla else 'r1') cluster.shutdown() def test_token_map(self): diff --git a/tests/integration/standard/test_rate_limit_exceeded.py b/tests/integration/standard/test_rate_limit_exceeded.py index 280d6426e1..03a1b13f3f 100644 --- a/tests/integration/standard/test_rate_limit_exceeded.py +++ b/tests/integration/standard/test_rate_limit_exceeded.py @@ -4,13 +4,14 @@ from cassandra.cluster import Cluster from cassandra.policies import ConstantReconnectionPolicy, RoundRobinPolicy, TokenAwarePolicy -from tests.integration import PROTOCOL_VERSION, use_cluster +from tests.integration import PROTOCOL_VERSION, use_cluster, scylla_only LOGGER = logging.getLogger(__name__) def setup_module(): use_cluster('rate_limit', [3], start=True) +@scylla_only class TestRateLimitExceededException(unittest.TestCase): @classmethod def setup_class(cls): diff --git a/tests/integration/standard/test_scylla_cloud.py b/tests/integration/standard/test_scylla_cloud.py index d1a22f8826..4dd5178e55 100644 --- a/tests/integration/standard/test_scylla_cloud.py +++ b/tests/integration/standard/test_scylla_cloud.py @@ -4,7 +4,7 @@ from ccmlib.utils.ssl_utils import generate_ssl_stores from ccmlib.utils.sni_proxy import refresh_certs, get_cluster_info, start_sni_proxy, create_cloud_config -from tests.integration import use_cluster +from tests.integration import use_cluster, scylla_only from cassandra.cluster import Cluster, TwistedConnection @@ -23,7 +23,7 @@ # need to run them with specific configuration like `gevent.monkey.patch_all()` or under async functions # unsupported_connection_classes = [GeventConnection, AsyncioConnection, EventletConnection] - +@scylla_only class ScyllaCloudConfigTests(TestCase): def start_cluster_with_proxy(self): ccm_cluster = self.ccm_cluster diff --git a/tests/integration/standard/test_shard_aware.py b/tests/integration/standard/test_shard_aware.py index cf8f17e209..b6aadc5c61 100644 --- a/tests/integration/standard/test_shard_aware.py +++ b/tests/integration/standard/test_shard_aware.py @@ -32,7 +32,7 @@ from cassandra.policies import TokenAwarePolicy, RoundRobinPolicy, ConstantReconnectionPolicy from cassandra import OperationTimedOut, ConsistencyLevel -from tests.integration import use_cluster, get_node, PROTOCOL_VERSION +from tests.integration import use_cluster, get_node, PROTOCOL_VERSION, scylla_only LOGGER = logging.getLogger(__name__) @@ -42,6 +42,7 @@ def setup_module(): use_cluster('shard_aware', [3], start=True) +@scylla_only class TestShardAwareIntegration(unittest.TestCase): @classmethod def setup_class(cls): diff --git a/tests/integration/standard/test_types.py b/tests/integration/standard/test_types.py index 2377129e9d..1264df8c65 100644 --- a/tests/integration/standard/test_types.py +++ b/tests/integration/standard/test_types.py @@ -31,7 +31,7 @@ from tests.integration import use_singledc, execute_until_pass, notprotocolv1, \ BasicSharedKeyspaceUnitTestCase, greaterthancass21, lessthancass30, greaterthanorequaldse51, \ - DSE_VERSION, greaterthanorequalcass3_10, requiredse, TestCluster, requires_composite_type + DSE_VERSION, greaterthanorequalcass3_10, requiredse, TestCluster, requires_composite_type, scylla_only from tests.integration.datatype_utils import update_datatypes, PRIMITIVE_DATATYPES, COLLECTION_TYPES, PRIMITIVE_DATATYPES_KEYS, \ get_sample, get_all_samples, get_collection_sample @@ -704,6 +704,7 @@ def test_can_insert_tuples_with_nulls(self): self.assertEqual(('', None, None, b''), result[0].t) self.assertEqual(('', None, None, b''), s.execute(read)[0].t) + @scylla_only def test_insert_collection_with_null_fails(self): """ NULLs in list / sets / maps are forbidden.