Skip to content

Commit 88445a8

Browse files
committed
test(live): auto-retry two flaky production UI tests
test_failed_job_error_visible_in_ui and test_my_models_page_renders both failed on b45e10b's CI run due to transient production blips (empty page bodies on an authenticated page), unrelated to that commit's RAST retry-window change. Wire the existing but unused flaky_external marker to pytest-rerunfailures (one retry, 5s delay) via the pytest_collection_modifyitems hook in tests/live/conftest.py, and apply the marker to just those two tests. Also fix test_error_translation.py test_504_all_attempts_fails_with_original_exception, broken by b45e10b's _MAX_RETRIES bump (3 -> 5): it hardcoded a 2-element _BACKOFF_SECONDS tuple, which is now too short and causes an IndexError on the later retry attempts instead of the exception under test. Size the tuple from the real _MAX_RETRIES instead.
1 parent b45e10b commit 88445a8

4 files changed

Lines changed: 14 additions & 1 deletion

File tree

tests/live/conftest.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,3 +328,8 @@ def pytest_collection_modifyitems(config, items) -> None: # noqa: D401
328328
if part in dir_to_marker:
329329
item.add_marker(getattr(pytest.mark, dir_to_marker[part]))
330330
break
331+
# Tests marked flaky_external (production/PATRIC/BV-BRC/SOLR
332+
# instability, not our bug) get one automatic retry via
333+
# pytest-rerunfailures instead of failing the whole run outright.
334+
if item.get_closest_marker("flaky_external") is not None:
335+
item.add_marker(pytest.mark.flaky(reruns=1, reruns_delay=5))

tests/live/ui/test_failed_job_error_display.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ def _wait_for_failure(api_url: str, token: str, job_id: str, timeout_s: int = 30
6666
)
6767

6868

69+
@pytest.mark.flaky_external
6970
def test_failed_job_error_visible_in_ui(
7071
authenticated_page,
7172
target_env,

tests/live/ui/test_job_polling.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
pytestmark = pytest.mark.requires_token
1919

2020

21+
@pytest.mark.flaky_external
2122
def test_my_models_page_renders(authenticated_page, target_env) -> None:
2223
"""U07: /my-models loads with auth and shows either models or an empty state."""
2324
errors = collect_console_errors(authenticated_page)

tests/unit/test_error_translation.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,13 @@ def call(self, method, params):
184184
raise RuntimeError("HTTPError: 504 Gateway Timeout")
185185

186186
monkeypatch.setattr(genome_annotator, "RPCClient", AlwaysFlakyClient)
187-
monkeypatch.setattr(genome_annotator, "_BACKOFF_SECONDS", (0, 0))
187+
# Backoff tuple must have _MAX_RETRIES - 1 entries or the retry loop
188+
# indexes past the end on the later attempts.
189+
monkeypatch.setattr(
190+
genome_annotator,
191+
"_BACKOFF_SECONDS",
192+
(0,) * (genome_annotator._MAX_RETRIES - 1),
193+
)
188194

189195
with pytest.raises(RuntimeError, match="504"):
190196
genome_annotator.annotate_fasta(">p1\nMKKLVAVLIVSLAVAL")

0 commit comments

Comments
 (0)