Skip to content

Commit f1bd331

Browse files
committed
Rename tests/parallel to tests/concurrency and add integration tests for Producer close()/transaction races
1 parent ce9edf5 commit f1bd331

4 files changed

Lines changed: 359 additions & 15 deletions

File tree

tests/parallel/_subprocess_isolation.py renamed to tests/concurrency/_subprocess_isolation.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,21 @@
1515
# limitations under the License.
1616

1717
"""
18-
Shared test infrastructure for tests/parallel/.
18+
Shared test infrastructure for tests/concurrency/.
1919
2020
Tests here deliberately race Producer/Consumer methods against each other,
2121
so a real regression can segfault the process instead of just failing an
2222
assertion. subprocess_isolated() below runs a decorated test in a fresh
2323
`python -m pytest` subprocess, so a crash only fails that one test instead
2424
of taking down the whole suite.
25-
26-
This is a plain module, not conftest.py: conftest.py is auto-loaded by
27-
pytest's own plugin machinery and isn't meant to be imported as a regular
28-
module -- doing so (`from tests.parallel.conftest import ...`) is not
29-
guaranteed to resolve the same way from a re-invoked subprocess as it does
30-
under pytest's own collection, and failed with
31-
"ModuleNotFoundError: No module named 'tests.parallel.conftest'" in
32-
exactly that scenario.
3325
"""
3426

3527
import functools
3628
import os
3729
import subprocess
3830
import sys
3931

40-
_SUBPROCESS_MARKER_ENV = "_PARALLEL_TESTS_SUBPROCESS"
32+
_SUBPROCESS_MARKER_ENV = "_CONCURRENCY_TESTS_SUBPROCESS"
4133
_SUBPROCESS_TIMEOUT_SECONDS = 120
4234

4335

tests/parallel/test_producer_close_race.py renamed to tests/concurrency/test_producer_close_race.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import time
1919

2020
from confluent_kafka import Consumer, Producer, TopicPartition
21-
from tests.parallel._subprocess_isolation import subprocess_isolated
21+
from tests.concurrency._subprocess_isolation import subprocess_isolated
2222

2323
###############################################################################
2424
# Tests for races between Producer.close() and concurrent calls to
@@ -287,10 +287,7 @@ def run_poll():
287287
assert poll_finished_at is not None, "poll() never finished"
288288

289289
# close() should have waited for close to the actual remaining poll()
290-
# duration, not a fixed guess -- a slower/loaded machine can take longer
291-
# to reach close_start, shrinking how much of poll_duration is actually
292-
# left to wait for, so we compare against what really happened instead
293-
# of a hardcoded constant.
290+
# duration
294291
close_duration = close_end - close_start
295292
remaining_poll_duration = poll_finished_at - close_start
296293
assert close_duration >= remaining_poll_duration * 0.9, (

0 commit comments

Comments
 (0)