|
1 | 1 | import logging |
2 | | -import time |
3 | 2 |
|
4 | 3 | import jubilant |
| 4 | +from tenacity import Retrying, stop_after_attempt, wait_exponential |
5 | 5 | from utils import check_config |
6 | 6 |
|
7 | 7 | logger = logging.getLogger() |
@@ -72,18 +72,21 @@ def test_deploy( |
72 | 72 | "00000000-1111-4222-3333-444444444444:swift", |
73 | 73 | unit="rabbitmq-server/0", |
74 | 74 | ) |
75 | | - # Give some arbitrary time to process. |
76 | | - # For now I'm taking that cursed path, and depending on how flaky this |
77 | | - # becomes, I'll see later to implement a wait loop. |
78 | | - time.sleep(4) |
79 | | - |
80 | | - # Verify that the retracer didn't Traceback and processed the sent crash |
81 | | - task = juju.exec("journalctl", "-u", "retracer@amd64.service", unit="retracer/0") |
82 | | - retracer_logs = task.stdout |
83 | | - assert "Waiting for messages in `retrace_amd64`" in retracer_logs, ( |
84 | | - "retracer didn't reach waiting on amqp" |
85 | | - ) |
86 | | - assert ( |
87 | | - "00000000-1111-4222-3333-444444444444:swift:Failed to decompress core: Error -3 while decompressing data: incorrect header check" |
88 | | - in retracer_logs |
89 | | - ), "retracer didn't try to decompress the core. Either `swift` or `amqp` is broken." |
| 75 | + # Let give this test a few chances to succeed, as it can sometimes be a bit |
| 76 | + # slow to process the crash |
| 77 | + for attempt in Retrying( |
| 78 | + stop=stop_after_attempt(5), |
| 79 | + wait=wait_exponential(min=5, max=30), |
| 80 | + reraise=True, |
| 81 | + ): |
| 82 | + with attempt: |
| 83 | + # Verify that the retracer didn't Traceback and processed the sent crash |
| 84 | + task = juju.exec("journalctl", "-u", "retracer@amd64.service", unit="retracer/0") |
| 85 | + retracer_logs = task.stdout |
| 86 | + assert "Waiting for messages in `retrace_amd64`" in retracer_logs, ( |
| 87 | + "retracer didn't reach waiting on amqp" |
| 88 | + ) |
| 89 | + assert ( |
| 90 | + "00000000-1111-4222-3333-444444444444:swift:Failed to decompress core: Error -3 while decompressing data: incorrect header check" |
| 91 | + in retracer_logs |
| 92 | + ), "retracer didn't try to decompress the core. Either `swift` or `amqp` is broken." |
0 commit comments