elastic / elastic/apm-agent-python

More transport flaky tests

Offen
#2,382 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_flushed_arg_with_wait[sending_elasticapm_client0] ____________

sending_elasticapm_client =

@pytest.mark.skipif(platform.system() == "Windows", reason="Flaky test on windows")
@pytest.mark.flaky(reruns=3) # Trying to test automatic flushes is inherently flaky
@pytest.mark.parametrize("sending_elasticapm_client", [{"api_request_time": "100ms"}], indirect=True)
def test_flushed_arg_with_wait(sending_elasticapm_client):
sending_elasticapm_client.begin_transaction("test_type")
sending_elasticapm_client.end_transaction("test")
time.sleep(0.3)
sending_elasticapm_client._transport.flush()

> assert sending_elasticapm_client.httpserver.requests[1].args["flushed"] == "true"
E IndexError: list index out of range

sending_elasticapm_client =

tests/transports/test_base.py:289: IndexError
----------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-08-04T02:52:17.556Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
127.0.0.1 - - [04/Aug/2025 02:52:17] "POST /intake/v2/events HTTP/1.1" 202 -
------------------------------ Captured log call -------------------------------
{"@timestamp":"2025-08-04T02:52:17.556Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
--------------------------- Captured stderr teardown ---------------------------
{"@timestamp":"2025-08-04T02:52:17.761Z","log.level":"info","message":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events?flushed=true HTTP/1.1\u001b[0m\" 202 -","ecs.version":"1.6.0","log":{"logger":"werkzeug","origin":{"file":{"line":97,"name":"_internal.py"},"function":"_log"},"original":"127.0.0.1 - - [04/Aug/2025 02:52:17] \"\u001b[35m\u001b[1mPOST /intake/v2/events?flushed=true HTTP/1.1\u001b[0m\" 202 -"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544533587648,"name":""}},"service":{"name":"myapp"}}
127.0.0.1 - - [04/Aug/2025 02:52:17] "POST /intake/v2/events?flushed=true HTTP/1.1" 202 -
----------------------------- Captured stderr call -----------------------------
{"@timestamp":"2025-08-04T02:52:18.380Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","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 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.382Z","log.level":"warning","message":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.383Z","log.level":"warning","message":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events
{"@timestamp":"2025-08-04T02:52:18.384Z","log.level":"error","message":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'","ecs.version":"1.6.0","log":{"logger":"elasticapm.transport","origin":{"file":{"line":322,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'
{"@timestamp":"2025-08-04T02:52:18.579Z","log.level":"warning","message":"Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","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 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.580Z","log.level":"warning","message":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.582Z","log.level":"warning","message":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true","ecs.version":"1.6.0","log":{"logger":"urllib3.connectionpool","origin":{"file":{"line":868,"name":"connectionpool.py"},"function":"urlopen"},"original":"Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused')': /intake/v2/events?flushed=true
{"@timestamp":"2025-08-04T02:52:18.583Z","log.level":"error","message":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'","ecs.version":"1.6.0","log":{"logger":"elasticapm.transport","origin":{"file":{"line":322,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'"},"process":{"name":"MainProcess","pid":38,"thread":{"id":140544550368960,"name":"eapm event processor thread"}},"service":{"name":"myapp"}}
Failed to submit message: 'Connection to APM Server timed out (url: http://127.0.0.1:43915/intake/v2/events, timeout: 5 seconds)'
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Beginne mit tests/transports/test_base.py, insbesondere mit test_flushed_arg_with_wait und seinem sending_elasticapm_client-Fixture. Reproduziere den Fehler und untersuche das Timing der Transportanfrage rund um _transport.flush(); fertig ist es, wenn der Test zuverlässig die Anfrage mit flushed=true verifiziert, ohne sporadischen IndexError.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
testing
Issue-Typ
Bug
Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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