forked from apache/cassandra-python-driver
-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathconftest.py
More file actions
67 lines (59 loc) · 2.47 KB
/
conftest.py
File metadata and controls
67 lines (59 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import pytest
import logging
# Cluster topology groups for test ordering.
# Tests are sorted so that modules sharing the same CCM cluster run
# together, minimising expensive cluster teardown/restart cycles.
# Lower number = runs first. Modules not listed get a high default.
_MODULE_CLUSTER_ORDER = {
# Group 0: default 3-node singledc (CLUSTER_NAME = 'test_cluster')
"test_metadata": 0,
"test_policies": 0,
"test_control_connection": 0,
"test_routing": 0,
"test_prepared_statements": 0,
"test_metrics": 0,
"test_connection": 0,
"test_concurrent": 0,
"test_custom_payload": 0,
"test_query_paging": 0,
"test_single_interface": 0,
# Group 1: 'cluster_tests' (--smp 2, 3 nodes)
"test_cluster": 1,
"test_shard_aware": 1,
# Group 2: 'shared_aware' (--smp 2 --memory 2048M, 3 nodes)
"test_use_keyspace": 2,
"test_client_routes": 2,
# Group 3: single-node cluster
"test_types": 3,
"test_cython_protocol_handlers": 3,
"test_custom_protocol_handler": 3,
"test_row_factories": 3,
"test_udts": 3,
"test_client_warnings": 3,
# Group 4: destructive / special clusters (run last)
"test_ip_change": 4,
"test_authentication": 4,
"test_custom_cluster": 4,
"test_query": 4,
}
def pytest_collection_modifyitems(items):
"""Sort tests so modules with the same cluster topology are adjacent.
Uses the original collection index as tie-breaker so that the
definition order inside each file is preserved (important for tests
that depend on running order, e.g. destructive tablet tests).
"""
orig_order = {id(item): idx for idx, item in enumerate(items)}
def _sort_key(item):
module_name = item.module.__name__.rsplit(".", 1)[-1]
return (_MODULE_CLUSTER_ORDER.get(module_name, 99), item.fspath, orig_order[id(item)])
items[:] = sorted(items, key=_sort_key)
# from https://github.com/streamlit/streamlit/pull/5047/files
def pytest_sessionfinish():
# We're not waiting for scriptrunner threads to cleanly close before ending the PyTest,
# which results in raised exception ValueError: I/O operation on closed file.
# This is well known issue in PyTest, check out these discussions for more:
# * https://github.com/pytest-dev/pytest/issues/5502
# * https://github.com/pytest-dev/pytest/issues/5282
# To prevent the exception from being raised on pytest_sessionfinish
# we disable exception raising in logging module
logging.raiseExceptions = False