File tree 4 files changed +24
-14
lines changed
4 files changed +24
-14
lines changed Original file line number Diff line number Diff line change @@ -325,7 +325,7 @@ stages:
325
325
- *find_pytest
326
326
- cd bin/tests/system
327
327
- >
328
- "$PYTEST" --junit-xml="$CI_PROJECT_DIR"/junit.xml -n "$TEST_PARALLEL_JOBS" --dist loadscope | tee pytest.out.txt
328
+ "$PYTEST" --junit-xml="$CI_PROJECT_DIR"/junit.xml -n "$TEST_PARALLEL_JOBS" | tee pytest.out.txt
329
329
- ' ( ! grep -F "grep: warning:" pytest.out.txt )'
330
330
after_script :
331
331
- awk '/^=+ FAILURES =+/{flag=1;next}/^=+.*=+$/{flag=0}flag' bin/tests/system/pytest.out.txt || true
Original file line number Diff line number Diff line change @@ -97,12 +97,7 @@ Issuing plain `pytest` command without any argument will execute all tests
97
97
sequenatially. To execute them in parallel, ensure you have pytest-xdist
98
98
installed and run:
99
99
100
- pytest --dist loadscope -n <number-of-workers>
101
-
102
- It is vital to provide the `--dist loadscope` option when running the tests in
103
- parallel to ensure tests from a single module are executed from the same
104
- thread. Otherwise, there's a risk of port contention and inefficient use of
105
- resources.
100
+ pytest -n <number-of-workers>
106
101
107
102
108
103
Running the System Tests Using the Legacy Runner
@@ -704,11 +699,13 @@ collisions are likely to occur.
704
699
705
700
Pytest-xdist is used for executing pytest test cases in parallel using the `-n
706
701
N_WORKERS` option. By default, xdist will distribute any test case to any
707
- worker, which would lead to the issue described above. Therefore, it is vital
708
- to use the `--dist loadscope` option which ensures that test cases within the
709
- same (module) scope will be handled by the same worker.
702
+ worker, which would lead to the issue described above. Therefore, conftest.py
703
+ enforces equivalent of `--dist loadscope` option which ensures that test cases
704
+ within the same (module) scope will be handled by the same worker. Parallelism
705
+ is automatically disabled when xdist.scheduler.loadscope library is not
706
+ available.
710
707
711
- $ pytest -n auto --dist loadscope
708
+ $ pytest -n auto
712
709
713
710
Test selection
714
711
---
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ def pytest_addoption(parser):
130
130
help = "don't remove the temporary test directories with artifacts" ,
131
131
)
132
132
133
- def pytest_configure ():
133
+ def pytest_configure (config ):
134
134
# Ensure this hook only runs on the main pytest instance if xdist is
135
135
# used to spawn other workers.
136
136
if not XDIST_WORKER :
@@ -156,6 +156,20 @@ def pytest_configure():
156
156
raise exc
157
157
logging .debug (proc .stdout )
158
158
159
+ if config .pluginmanager .has_plugin ("xdist" ) and config .option .numprocesses :
160
+ # system tests depend on module scope for setup & teardown
161
+ # enforce use "loadscope" scheduler or disable paralelism
162
+ try :
163
+ import xdist .scheduler .loadscope # pylint: disable=unused-import
164
+ except ImportError :
165
+ logging .debug (
166
+ "xdist is too old and does not have "
167
+ "scheduler.loadscope, disabling parallelism"
168
+ )
169
+ config .option .dist = "no"
170
+ else :
171
+ config .option .dist = "loadscope"
172
+
159
173
def pytest_ignore_collect (path ):
160
174
# System tests are executed in temporary directories inside
161
175
# bin/tests/system. These temporary directories contain all files
Original file line number Diff line number Diff line change @@ -28,7 +28,6 @@ def into_pytest_args(in_args):
28
28
if in_args .expression is None :
29
29
# running all tests - execute in parallel
30
30
args .extend (["-n" , "auto" ])
31
- args .extend (["--dist" , "loadscope" ])
32
31
else :
33
32
args .extend (["-k" , in_args .expression ])
34
33
if in_args .noclean :
@@ -48,7 +47,7 @@ def main():
48
47
"Using pytest system test runner\n \n "
49
48
'Please consider invoking "pytest" directly for more control:\n '
50
49
" single test: pytest -k dns64\n "
51
- " parallel tests: pytest -n auto --dist loadscope \n \n "
50
+ " parallel tests: pytest -n auto\n \n "
52
51
"Alternately, use ./legacy.run.sh for the legacy system test runner.\n "
53
52
)
54
53
You can’t perform that action at this time.
0 commit comments