elastic / elastic/apm-agent-python
flaky test test_send_remote_failover_sync_non_transport_exception_error
- Lingua principale
- Python
- Stelle
- 431
- Fork
- 239
- Merge medio
- 5g 10h
- PR unite (30g)
- 7
Descrizione
**Describe the bug**:
Cannot reproduce reliably still may be useful to fix:
```
=================================== FAILURES ===================================
_________ test_send_remote_failover_sync_non_transport_exception_error _________
should_try =
http_send =
caplog = <_pytest.logging.LogCaptureFixture object at 0x7f943c8a5c90>
@mock.patch("elasticapm.transport.http.Transport.send")
@mock.patch("elasticapm.transport.base.TransportState.should_try")
def test_send_remote_failover_sync_non_transport_exception_error(should_try, http_send, caplog):
should_try.return_value = True
client = Client(
server_url="http://example.com",
service_name="app_name",
secret_token="secret",
transport_class="elasticapm.transport.http.Transport",
metrics_interval="0ms",
metrics_sets=[],
)
# test error
http_send.side_effect = ValueError("oopsie")
with caplog.at_level("ERROR", "elasticapm.transport"):
client.capture_message("foo", handled=False)
client._transport.flush()
assert client._transport.state.did_fail()
assert_any_record_contains(caplog.records, "oopsie", "elasticapm.transport")
# test recovery
http_send.side_effect = None
client.capture_message("foo", handled=False)
client.close()
> assert not client._transport.state.did_fail()
E assert not True
E + where True = >()
E + where > = .did_fail
E + where = .state
E + where = ._transport
tests/client/client_tests.py:288: AssertionError
----------------------------- Captured stderr call -----------------------------
{"@timestamp":"2024-03-06T16:09:14.917Z","log.level":"error","message":"Failed to submit message: 'oopsie'","ecs":{"version":"1.6.0"},"log":{"logger":"elasticapm.transport","origin":{"file":{"line":318,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'oopsie'"},"process":{"name":"MainProcess","pid":905083,"thread":{"id":140274711856704,"name":"eapm event processor thread"}},"service":{"name":"app_name"}}
{"@timestamp":"2024-03-06T16:09:14.917Z","log.level":"error","message":"Failed to submit message: 'oopsie'","ecs":{"version":"1.6.0"},"log":{"logger":"elasticapm.transport","origin":{"file":{"line":318,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'oopsie'"},"process":{"name":"MainProcess","pid":905083,"thread":{"id":140274711856704,"name":"eapm event processor thread"}},"service":{"name":"app_name"}}
------------------------------ Captured log call -------------------------------
{"@timestamp":"2024-03-06T16:09:14.917Z","log.level":"error","message":"Failed to submit message: 'oopsie'","ecs":{"version":"1.6.0"},"log":{"logger":"elasticapm.transport","origin":{"file":{"line":318,"name":"base.py"},"function":"handle_transport_fail"},"original":"Failed to submit message: 'oopsie'"},"process":{"name":"MainProcess","pid":905083,"thread":{"id":140274711856704,"name":"eapm event processor thread"}},"service":{"name":"app_name"}}
=============================== warnings summary ===============================
```
**To Reproduce**
1. pytest
**Environment (please complete the following information)**
- OS: [e.g. Linux] Linux
- Python version: 3.10.12
- Framework and version [e.g. Django 2.1]:
- APM Server version:
- Agent version:
**Additional context**
None
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da tests/client/client_tests.py, in particolare da test_send_remote_failover_sync_non_transport_exception_error, e analizza la gestione dei fallimenti di trasporto a cui si fa riferimento in base.py. Esegui ripetutamente il test indicato per comprendere il fallimento dipendente dalla temporizzazione. Il lavoro è concluso quando il test supera il controllo in modo affidabile continuando a verificare l’invio non riuscito, l’eccezione registrata e il successivo recupero.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python
- Ambito
- backend, testing-qa
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100