Skip to content

Commit 5afb73d

Browse files
authored
Merge pull request #219 from Lorak-mmk/fix-integration-standard
Enable tests/integration/standard
2 parents 5761efc + 40120f2 commit 5afb73d

17 files changed

+158
-161
lines changed

.github/workflows/integration-tests.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,4 @@ jobs:
2121

2222
- name: Test with pytest
2323
run: |
24-
./ci/run_integration_test.sh tests/integration/standard/test_authentication.py tests/integration/standard/test_cluster.py tests/integration/standard/test_concurrent.py tests/integration/standard/test_connection.py tests/integration/standard/test_control_connection.py tests/integration/standard/test_custom_payload.py tests/integration/standard/test_custom_protocol_handler.py tests/integration/standard/test_cython_protocol_handlers.py tests/integration/standard/test_scylla_cloud.py tests/integration/standard/test_use_keyspace.py tests/integration/standard/test_ip_change.py tests/integration/cqlengine/
25-
# can't run this, cause only 2 cpus on github actions: tests/integration/standard/test_shard_aware.py
24+
./ci/run_integration_test.sh tests/integration/standard/ tests/integration/cqlengine/

ci/run_integration_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ pip install -U pip wheel setuptools
2323

2424
# install driver wheel
2525
pip install --ignore-installed -r test-requirements.txt pytest
26-
pip install .
26+
pip install -e .
2727

2828
# download awscli
2929
pip install awscli

pytest.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[pytest]
22
log_format = %(asctime)s.%(msecs)03d %(levelname)s [%(module)s:%(lineno)s]: %(message)s
33
log_level = DEBUG
4-
log_date_format = %Y-%m-%d %H:%M:%S
4+
log_date_format = %Y-%m-%d %H:%M:%S
5+
xfail_strict=true

tests/integration/__init__.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from itertools import groupby
3535
import six
3636
import shutil
37+
import pytest
3738

3839

3940
from cassandra import OperationTimedOut, ReadTimeout, ReadFailure, WriteTimeout, WriteFailure, AlreadyExists,\
@@ -343,6 +344,7 @@ def _id_and_mark(f):
343344
local = local_decorator_creator()
344345
notprotocolv1 = unittest.skipUnless(PROTOCOL_VERSION > 1, 'Protocol v1 not supported')
345346
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')
346348
greaterthanprotocolv3 = unittest.skipUnless(PROTOCOL_VERSION >= 4, 'Protocol versions less than 4 are not supported')
347349
protocolv6 = unittest.skipUnless(6 in get_supported_protocol_versions(), 'Protocol versions less than 6 are not supported')
348350

@@ -366,8 +368,22 @@ def _id_and_mark(f):
366368
lessthandse51 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('5.1'), "DSE version less than 5.1 required")
367369
lessthandse60 = unittest.skipUnless(DSE_VERSION and DSE_VERSION < Version('6.0'), "DSE version less than 6.0 required")
368370

369-
requirescollectionindexes = unittest.skipUnless(SCYLLA_VERSION is None or Version(SCYLLA_VERSION.split(':')[1]) >= Version('5.2'), 'Test requires Scylla >= 5.2 or Cassandra')
370-
requirescustomindexes = unittest.skipUnless(SCYLLA_VERSION is None, 'Currently, Scylla does not support SASI or any other CUSTOM INDEX class.')
371+
# pytest.mark.xfail instead of unittest.expectedFailure because
372+
# 1. unittest doesn't skip setUpClass when used on class and we need it sometimes
373+
# 2. unittest doesn't have conditional xfail, and I prefer to use pytest than custom decorator
374+
# 3. unittest doesn't have a reason argument, so you don't see the reason in pytest report
375+
requires_collection_indexes = pytest.mark.xfail(SCYLLA_VERSION is not None and Version(SCYLLA_VERSION.split(':')[1]) < Version('5.2'),
376+
reason='Scylla supports collection indexes from 5.2 onwards')
377+
requires_custom_indexes = pytest.mark.xfail(SCYLLA_VERSION is not None,
378+
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)
371387

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

tests/integration/cqlengine/management/test_management.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from cassandra.cqlengine.models import Model
2525
from cassandra.cqlengine import columns
2626

27-
from tests.integration import DSE_VERSION, PROTOCOL_VERSION, greaterthancass20, requirescollectionindexes, MockLoggingHandler, CASSANDRA_VERSION
27+
from tests.integration import DSE_VERSION, PROTOCOL_VERSION, greaterthancass20, requires_collection_indexes, MockLoggingHandler, CASSANDRA_VERSION
2828
from tests.integration.cqlengine.base import BaseCassEngTestCase
2929
from tests.integration.cqlengine.query.test_queryset import TestModel
3030
from cassandra.cqlengine.usertype import UserType
@@ -427,7 +427,7 @@ def test_sync_index_case_sensitive(self):
427427
self.assertIsNotNone(management._get_index_name_by_column(table_meta, 'second_key'))
428428

429429
@greaterthancass20
430-
@requirescollectionindexes
430+
@requires_collection_indexes
431431
def test_sync_indexed_set(self):
432432
"""
433433
Tests that models that have container types with indices can be synced.

tests/integration/cqlengine/query/test_named.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from tests.integration.cqlengine.query.test_queryset import BaseQuerySetUsage
2828

2929

30-
from tests.integration import BasicSharedKeyspaceUnitTestCase, greaterthanorequalcass30, requirescollectionindexes
30+
from tests.integration import BasicSharedKeyspaceUnitTestCase, greaterthanorequalcass30, requires_collection_indexes
3131

3232

3333
class TestQuerySetOperation(BaseCassEngTestCase):
@@ -118,7 +118,7 @@ def test_query_expression_where_clause_generation(self):
118118
self.assertIsInstance(where.operator, GreaterThanOrEqualOperator)
119119
self.assertEqual(where.value, 1)
120120

121-
@requirescollectionindexes
121+
@requires_collection_indexes
122122
class TestQuerySetCountSelectionAndIteration(BaseQuerySetUsage):
123123

124124
@classmethod

tests/integration/cqlengine/query/test_queryset.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from cassandra.util import uuid_from_time
4040
from cassandra.cqlengine.connection import get_session
4141
from tests.integration import PROTOCOL_VERSION, CASSANDRA_VERSION, greaterthancass20, greaterthancass21, \
42-
greaterthanorequalcass30, TestCluster, requirescollectionindexes
42+
greaterthanorequalcass30, TestCluster, requires_collection_indexes
4343
from tests.integration.cqlengine import execute_count, DEFAULT_KEYSPACE
4444

4545

@@ -384,7 +384,7 @@ def tearDownClass(cls):
384384
drop_table(CustomIndexedTestModel)
385385
drop_table(TestMultiClusteringModel)
386386

387-
@requirescollectionindexes
387+
@requires_collection_indexes
388388
class TestQuerySetCountSelectionAndIteration(BaseQuerySetUsage):
389389

390390
@execute_count(2)
@@ -558,7 +558,7 @@ class NonEqualityFilteringModel(Model):
558558
num = qa.count()
559559
assert num == 1, num
560560

561-
@requirescollectionindexes
561+
@requires_collection_indexes
562562
class TestQuerySetDistinct(BaseQuerySetUsage):
563563

564564
@execute_count(1)
@@ -597,7 +597,7 @@ def test_distinct_with_explicit_count(self):
597597
self.assertEqual(q.count(), 2)
598598

599599

600-
@requirescollectionindexes
600+
@requires_collection_indexes
601601
class TestQuerySetOrdering(BaseQuerySetUsage):
602602
@execute_count(2)
603603
def test_order_by_success_case(self):
@@ -646,7 +646,7 @@ def test_ordering_on_multiple_clustering_columns(self):
646646
assert [r.three for r in results] == [1, 2, 3, 4, 5]
647647

648648

649-
@requirescollectionindexes
649+
@requires_collection_indexes
650650
class TestQuerySetSlicing(BaseQuerySetUsage):
651651

652652
@execute_count(1)
@@ -701,7 +701,7 @@ def test_negative_slicing(self):
701701
self.assertEqual(model.attempt_id, expect)
702702

703703

704-
@requirescollectionindexes
704+
@requires_collection_indexes
705705
class TestQuerySetValidation(BaseQuerySetUsage):
706706

707707
def test_primary_key_or_index_must_be_specified(self):
@@ -783,7 +783,7 @@ def test_custom_indexed_field_can_be_queried(self):
783783
list(CustomIndexedTestModel.objects.filter(test_id=1, description='test'))
784784

785785

786-
@requirescollectionindexes
786+
@requires_collection_indexes
787787
class TestQuerySetDelete(BaseQuerySetUsage):
788788

789789
@execute_count(9)
@@ -942,7 +942,7 @@ def test_success_case(self):
942942
assert '4' in datas
943943

944944

945-
@requirescollectionindexes
945+
@requires_collection_indexes
946946
class TestInOperator(BaseQuerySetUsage):
947947
@execute_count(1)
948948
def test_kwarg_success_case(self):
@@ -1003,7 +1003,7 @@ class bool_model2(Model):
10031003

10041004

10051005
@greaterthancass20
1006-
@requirescollectionindexes
1006+
@requires_collection_indexes
10071007
class TestContainsOperator(BaseQuerySetUsage):
10081008

10091009
@execute_count(6)
@@ -1069,7 +1069,7 @@ def test_query_expression_success_case(self):
10691069
self.assertEqual(q.count(), 0)
10701070

10711071

1072-
@requirescollectionindexes
1072+
@requires_collection_indexes
10731073
class TestValuesList(BaseQuerySetUsage):
10741074

10751075
@execute_count(2)
@@ -1082,7 +1082,7 @@ def test_values_list(self):
10821082
assert item == 10
10831083

10841084

1085-
@requirescollectionindexes
1085+
@requires_collection_indexes
10861086
class TestObjectsProperty(BaseQuerySetUsage):
10871087
@execute_count(1)
10881088
def test_objects_property_returns_fresh_queryset(self):
@@ -1113,7 +1113,7 @@ class PagingTest(Model):
11131113
assert len(results) == 2
11141114

11151115

1116-
@requirescollectionindexes
1116+
@requires_collection_indexes
11171117
class ModelQuerySetTimeoutTestCase(BaseQuerySetUsage):
11181118
def test_default_timeout(self):
11191119
with mock.patch.object(Session, 'execute') as mock_execute:
@@ -1131,7 +1131,7 @@ def test_none_timeout(self):
11311131
self.assertEqual(mock_execute.call_args[-1]['timeout'], None)
11321132

11331133

1134-
@requirescollectionindexes
1134+
@requires_collection_indexes
11351135
class DMLQueryTimeoutTestCase(BaseQuerySetUsage):
11361136
def setUp(self):
11371137
self.model = TestModel(test_id=1, attempt_id=1, description='timeout test')

tests/integration/cqlengine/statements/test_base_statement.py

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

2727
from tests.integration.cqlengine.base import BaseCassEngTestCase, TestQueryUpdateModel
2828
from tests.integration.cqlengine import DEFAULT_KEYSPACE
29-
from tests.integration import greaterthanorequalcass3_10, requirescustomindexes, TestCluster
29+
from tests.integration import greaterthanorequalcass3_10, requires_custom_indexes, TestCluster
3030

3131
from cassandra.cqlengine.connection import execute
3232

@@ -102,7 +102,7 @@ def test_insert_statement_execute(self):
102102
self.assertEqual(TestQueryUpdateModel.objects.count(), 0)
103103

104104
@greaterthanorequalcass3_10
105-
@requirescustomindexes
105+
@requires_custom_indexes
106106
def test_like_operator(self):
107107
"""
108108
Test to verify the like operator works appropriately

tests/integration/standard/test_authentication_misconfiguration.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@
1919

2020
class MisconfiguredAuthenticationTests(unittest.TestCase):
2121
""" One node (not the contact point) has password auth. The rest of the nodes have no auth """
22-
# TODO: Fix ccm to apply following options to scylla.yaml
23-
# node3.set_configuration_options(values={
24-
# 'authenticator': 'PasswordAuthenticator',
25-
# 'authorizer': 'CassandraAuthorizer',
26-
# })
27-
# To make it working for scylla
2822
@classmethod
2923
def setUpClass(cls):
3024
if not USE_CASS_EXTERNAL:
@@ -38,7 +32,6 @@ def setUpClass(cls):
3832

3933
cls.ccm_cluster = ccm_cluster
4034

41-
@unittest.expectedFailure
4235
def test_connect_no_auth_provider(self):
4336
cluster = TestCluster()
4437
cluster.connect()

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

0 commit comments

Comments
 (0)