elastic / elastic/apm-agent-python

Flaky test on windows / python 3.9

Offen
#2,513 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
agent-python
Vorherrschende Sprache
Python
Sterne
431
Forks
239
Ø Merge
5 T. 10 Std.
Gemergte PRs (30 T.)
7

Beschreibung

```
________ test_send_remote_failover_sync_non_transport_exception_error _________

should_try =
caplog = <_pytest.logging.LogCaptureFixture object at 0x0000019D45CCBE80>

@mock.patch("elasticapm.transport.base.TransportState.should_try", return_value=True)
def test_send_remote_failover_sync_non_transport_exception_error(should_try, caplog):
client = Client(
server_url="http://example.com/",
service_name="app_name",
secret_token="secret",
transport_class="tests.fixtures.MockSendHTTPTransport",
metrics_interval="0ms",
metrics_sets=[],
)

# test error
client._transport.send_mock.side_effect = ValueError("oopsie")
with caplog.at_level("ERROR", "elasticapm.transport"):
client.capture_message("foo", handled=False)
try:
client._transport.flush()
except ValueError:
# give flush a bit more room because we may take a bit more than the max timeout to flush
client._transport._flushed.wait(timeout=1)
> assert client._transport.state.did_fail()
E assert False
E + where False = >()
E + where > = .did_fail
E + where = .state
E + where = ._transport

tests\client\client_tests.py:297: AssertionError
---------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-12-16T02:38:16.408Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError(\"HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)\")': /","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError(\"HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)\")': /"},"process":{"name":"MainProcess","pid":3960,"thread":{"id":6368,"name":"eapm event processor thread"}},"service":{"name":"app_name"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPConnectionPool(host='example.com', port=80): Read timed out. (read timeout=5)")': /
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit test_send_remote_failover_sync_non_transport_exception_error in tests/client/client_tests.py und untersuche den Transportstatus sowie das Flush-Timing rund um die fehlschlagende Assertion. Reproduziere den Test unter Windows mit Python 3.9 und überprüfe anschließend, dass der Test den erwarteten fehlgeschlagenen Zustand zuverlässig erkennt, ohne plattformspezifische Flakiness einzuführen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
testing-qa
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.