Commit a5817f9
committed
test(e2e): disable telemetry process-wide to deflake retry tests
Follow-up to #822, which was insufficient.
The retry tests in PySQLRetryTestsMixin patch urllib3 globally
(HTTPSConnectionPool._get_conn / _validate_conn) and assert the
connection's own request was retried exactly N times. #822 disabled
telemetry on the retry tests' OWN connections, but the flake persisted:
under pytest-xdist, MANY other e2e tests run in the SAME worker process
before the retry tests, and each opens a connection with telemetry
enabled by default. Telemetry is a process-global singleton
(TelemetryClientFactory) with a shared executor and a daemon flush
thread, so those prior tests leave real TelemetryClient instances and
background threads/futures registered in the worker. When a retry test
installs its global urllib3 mock, an in-flight or subsequently-fired
telemetry POST to /telemetry-ext from a *previous* test's client goes
through the same mocked pool and inflates the mock call_count past the
expected value -> flaky AssertionError. CI logs on #825 show
/telemetry-ext retries firing inside the failing retry test even though
that test's own connection had telemetry disabled.
Fix: add an autouse, function-scoped fixture in a new tests/e2e/conftest.py
that force-installs NoopTelemetryClient for every e2e connection (and
drains the factory before/after each test). With no real TelemetryClient
ever created in the worker, there are no background telemetry threads or
futures to leak into any test's urllib3 mock. This removes the flake at
its source deterministically rather than draining racy background threads.
The telemetry suite (tests/e2e/test_telemetry_e2e.py) asserts real
telemetry behavior and is marked @pytest.mark.serial while managing its
own factory state, so the fixture explicitly skips serial-marked tests.
Verified against dogfood:
- A normal connection opened with telemetry defaulting ON gets a
NoopTelemetryClient (no real executor/flush thread).
- serial-marked tests keep the real initialize_telemetry_client;
non-serial tests get the no-op installer.
- test_telemetry_e2e.py still passes (12 tests, real telemetry).
- Full PySQLRetryTestsMixin passes (36 tests).
Co-authored-by: Isaac
Signed-off-by: Vikrant Puppala <vikrant.puppala@databricks.com>1 parent a2fe99f commit a5817f9
1 file changed
Lines changed: 107 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 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 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
0 commit comments