Skip to content

Commit 9cd503c

Browse files
committed
Add python 3.11 support
Patch by brandonwilliams; reviewed by bereng for CASSANDRA-18121
1 parent 36da75d commit 9cd503c

File tree

8 files changed

+45
-24
lines changed

8 files changed

+45
-24
lines changed

client_request_metrics_local_remote_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
class TestClientRequestMetricsLocalRemote(Tester):
1010

1111
def test_write_and_read(self):
12-
session, node = setup(self)
12+
session, node = setup_test(self)
1313

1414
read_metrics = ClientRequestMetricsContainer(node, 'Read')
1515
write_metrics = ClientRequestMetricsContainer(node, 'Write')
@@ -47,7 +47,7 @@ def test_write_and_read(self):
4747
assert 0 < (r3_r.remote_requests - r2_r.remote_requests)
4848

4949
def test_batch_and_slice(self):
50-
session, node = setup(self)
50+
session, node = setup_test(self)
5151

5252
read_metrics = ClientRequestMetricsContainer(node, 'Read')
5353
write_metrics = ClientRequestMetricsContainer(node, 'Write')
@@ -89,7 +89,7 @@ def test_batch_and_slice(self):
8989
assert 0 < (r3_r.remote_requests - r2_r.remote_requests)
9090

9191
def test_paxos(self):
92-
session, node = setup(self)
92+
session, node = setup_test(self)
9393

9494
read_metrics = ClientRequestMetricsContainer(node, 'Read')
9595
write_metrics = ClientRequestMetricsContainer(node, 'Write')
@@ -177,7 +177,7 @@ def setup_schema(session):
177177
session.execute("CREATE TABLE test (id int,ord int,val varchar,PRIMARY KEY (id, ord));""")
178178

179179

180-
def setup(obj):
180+
def setup_test(obj):
181181
cluster = obj.cluster
182182
cluster.populate(2)
183183

conftest.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import copy
2-
import collections
2+
try:
3+
import collections.abc as collections
4+
except ImportError:
5+
import collections
36
import logging
47
import os
58
import platform
@@ -149,7 +152,7 @@ class level seems to work, and I guess it's not that much extra overhead to setu
149152
log_level = logging.INFO
150153
try:
151154
# first see if logging level overridden by user as command line argument
152-
log_level_from_option = pytest.config.getoption("--log-level")
155+
log_level_from_option = request.config.getoption("--log-level")
153156
if log_level_from_option is not None:
154157
log_level = logging.getLevelName(log_level_from_option)
155158
else:
@@ -158,22 +161,22 @@ class level seems to work, and I guess it's not that much extra overhead to setu
158161
# nope, user didn't specify it as a command line argument to pytest, check if
159162
# we have a default in the loaded pytest.ini. Note: words are seperated in variables
160163
# in .ini land with a "_" while the command line arguments use "-"
161-
if pytest.config.inicfg.get("log_level") is not None:
162-
log_level = logging.getLevelName(pytest.config.inicfg.get("log_level"))
164+
if request.config.inicfg.get("log_level") is not None:
165+
log_level = logging.getLevelName(request.config.inicfg.get("log_level"))
163166

164167
logging.root.setLevel(log_level)
165168

166169
logging_format = None
167170
try:
168171
# first see if logging level overridden by user as command line argument
169-
log_format_from_option = pytest.config.getoption("--log-format")
172+
log_format_from_option = request.config.getoption("--log-format")
170173
if log_format_from_option is not None:
171174
logging_format = log_format_from_option
172175
else:
173176
raise ValueError
174177
except ValueError:
175-
if pytest.config.inicfg.get("log_format") is not None:
176-
logging_format = pytest.config.inicfg.get("log_format")
178+
if request.config.inicfg.get("log_format") is not None:
179+
logging_format = request.config.inicfg.get("log_format")
177180

178181
logging.basicConfig(level=log_level,
179182
format=logging_format)
@@ -192,8 +195,8 @@ class level seems to work, and I guess it's not that much extra overhead to setu
192195

193196
@pytest.fixture(scope="session")
194197
def log_global_env_facts(fixture_dtest_config, fixture_logging_setup):
195-
if pytest.config.pluginmanager.hasplugin('junitxml'):
196-
my_junit = getattr(pytest.config, '_xml', None)
198+
if fixture_dtest_config.config.pluginmanager.hasplugin('junitxml'):
199+
my_junit = getattr(fixture_dtest_config.config, '_xml', None)
197200
my_junit.add_global_property('USE_VNODES', fixture_dtest_config.use_vnodes)
198201

199202

consistency_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ def run():
556556
logger.debug("Waiting for workers to complete")
557557
while exceptions_queue.empty():
558558
time.sleep(0.1)
559-
if len([t for t in threads if t.isAlive()]) == 0:
559+
if len([t for t in threads if t.is_alive()]) == 0:
560560
break
561561

562562
if not exceptions_queue.empty():

jmx_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_netstats(self):
4242
node1.flush()
4343
node1.stop(gently=False)
4444

45-
with pytest.raises(ToolError, message=r"ConnectException: 'Connection refused( \(Connection refused\))?'."):
45+
with pytest.raises(ToolError, match=r"ConnectException: 'Connection refused( \(Connection refused\))?'."):
4646
node1.nodetool('netstats')
4747

4848
# don't wait; we're testing for when nodetool is called on a node mid-startup

pytest.ini

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
[pytest]
2+
addopts = --show-capture=stdout
23
python_files = test_*.py *_test.py *_tests.py
34
junit_suite_name = Cassandra dtests
4-
log_print = True
55
log_level = INFO
66
log_format = %(asctime)s,%(msecs)d %(name)s %(levelname)s %(message)s
77
timeout = 900
8+
markers =
9+
since
10+
vnodes
11+
no_vnodes
12+
resource_intensive
13+
offheap_memtables
14+
no_offheap_memtables
15+
ported_to_in_jvm
16+
env
17+
skip_version
18+
upgrade_test
19+
depends_cqlshlib
20+
depends_driver

rebuild_test.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ def test_resumable_rebuild(self):
217217
node3.byteman_submit(script)
218218

219219
# First rebuild must fail and data must be incomplete
220-
with pytest.raises(ToolError, message='Unexpected: SUCCEED'):
220+
with pytest.raises(ToolError):
221221
logger.debug('Executing first rebuild -> '),
222222
node3.nodetool('rebuild dc1')
223-
logger.debug('Expected: FAILED')
223+
pytest.fail("Expected: FAILED")
224224

225225
session.execute('USE ks')
226-
with pytest.raises(AssertionError, message='Unexpected: COMPLETE'):
226+
with pytest.raises(AssertionError):
227227
logger.debug('Checking data is complete -> '),
228228
for i in range(0, 20000):
229229
query_c1c2(session, i, ConsistencyLevel.LOCAL_ONE)
230-
logger.debug('Expected: INCOMPLETE')
230+
pytest.fail('Expected: INCOMPLETE')
231231

232232
logger.debug('Executing second rebuild -> '),
233233
node3.nodetool('rebuild dc1')
@@ -336,8 +336,9 @@ def test_disallow_rebuild_nonlocal_range(self):
336336
session = self.patient_exclusive_cql_connection(node1)
337337
session.execute("CREATE KEYSPACE ks1 WITH replication = {'class':'SimpleStrategy', 'replication_factor':2};")
338338

339-
with pytest.raises(ToolError, match='is not a range that is owned by this node'):
339+
with pytest.raises(ToolError):
340340
node1.nodetool('rebuild -ks ks1 -ts (%s,%s]' % (node1_token, node2_token))
341+
pytest.fail("range should not be owned by this node")
341342

342343
@since('3.10')
343344
@pytest.mark.no_vnodes
@@ -372,8 +373,9 @@ def test_disallow_rebuild_from_nonreplica(self):
372373
session = self.patient_exclusive_cql_connection(node1)
373374
session.execute("CREATE KEYSPACE ks1 WITH replication = {'class':'SimpleStrategy', 'replication_factor':2};")
374375

375-
with pytest.raises(ToolError, message='Unable to find sufficient sources for streaming range'):
376+
with pytest.raises(ToolError):
376377
node1.nodetool('rebuild -ks ks1 -ts (%s,%s] -s %s' % (node3_token, node1_token, node3_address))
378+
pytest.fail("should not find sufficient sources")
377379

378380
@since('3.10')
379381
@pytest.mark.no_vnodes

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ docopt
1515
enum34
1616
flaky
1717
mock
18-
pytest==3.6.4
18+
pytest>=6.5.0
1919
pytest-timeout==1.4.2
2020
pytest-repeat
2121
parse

tools/misc.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55
import logging
66
import pytest
77

8-
from collections import Mapping
8+
try:
9+
from collections.abc import Mapping
10+
except ImportError:
11+
from collections import Mapping
912

1013
from ccmlib.node import Node
1114

0 commit comments

Comments
 (0)