Skip to content

test: tolerate transient gateway 504 on live premium lane - #133

Merged
martinkersner merged 1 commit into
mainfrom
fix/premium-live-transient-504
Jul 2, 2026
Merged

test: tolerate transient gateway 504 on live premium lane#133
martinkersner merged 1 commit into
mainfrom
fix/premium-live-transient-504

Conversation

@martinkersner

Copy link
Copy Markdown
Member

Summary

The non-blocking Live keyed tests lane went red on the last push to main (run 28571765425): TestPremium.test_premium_target_market failed with an HTTP 504 Gateway Timeout from prod.

A 504 is a gateway timeout — the edge gave up on a slow upstream. It is not a client ReadTimeout, so the DATAMAXI_TIMEOUT 10s→30s bump from #130 cannot prevent it. The premium endpoint intermittently 504s under load; this is prod infra flakiness, not an SDK bug.

Change

  • tests/conftest.py: add live_call(fn, retries=3, backoff=1.0) — retries transient 5xx (502/503/504) with linear backoff, and pytest.skips if every attempt still hits a transient status (the non-blocking live lane must not go red on infra flakiness). Real 5xx (e.g. 500), 4xx, and assertion failures propagate unchanged.
  • tests/test_integration.py: route all TestPremium premium data calls through live_call. The fast premium.exchanges() list call is left as-is.

Tests

  • Keyless offline CI lane (-m "not integration"): 134 passed, 11 skipped, 107 deselected — unchanged.
  • live_call logic unit-verified out of band: retry-then-succeed, persistent-transient→skip, non-transient 500→propagate, 4xx→propagate.
  • flake8 + black clean.

Known failures / notes

  • The live-keyed lane requires an API key and only runs on push to main; it cannot run on this PR branch. If prod is healthy at merge time the premium tests pass; if it 504s they now skip instead of failing.

Live-keyed lane went red on push to main: TestPremium.test_premium_target_market
got HTTP 504 from prod (gateway timeout, not a client ReadTimeout — the 30s
DATAMAXI_TIMEOUT from #130 can't help). The premium endpoint intermittently
504s under load; infra flakiness, not an SDK bug.

- conftest: add live_call(fn) helper — retries transient 5xx (502/503/504)
  with linear backoff, pytest.skip on persistent transient; real 5xx/4xx and
  assertions propagate unchanged.
- test_integration: route all TestPremium data calls through live_call.

keyless CI lane: 134 passed, 11 skipped (unchanged). helper logic unit-verified.
@martinkersner
martinkersner merged commit dc8d131 into main Jul 2, 2026
5 checks passed
@martinkersner
martinkersner deleted the fix/premium-live-transient-504 branch July 2, 2026 07:31
martinkersner added a commit that referenced this pull request Jul 2, 2026
Live keyed lane went red again on a transient prod 504 — this time
test_cex_candle (ServerError 504 "upstream request timeout"). #133's
per-endpoint live_call wrapping only covered TestPremium, so the same
infra flakiness resurfaced on the next unwrapped call. The run still
showed green: job-level continue-on-error masked the failed job.

- conftest: replace per-call live_call helper with autouse fixture
  _tolerate_transient_gateway — monkeypatches API.send_request (the one
  method every endpoint inherits) to retry transient 502/503/504 then
  pytest.skip. Covers test_call.py + test_integration.py + future live
  tests. No-op without a key (keyless/mocked lanes untouched).
- test_integration: revert the 19 live_call(lambda: ...) premium wraps
  to direct calls; drop now-dead import.
- live-tests.yml: move continue-on-error from job to pytest step so the
  job conclusion stays honest (setup failures still red) while the push
  stays non-blocking; add a step that annotates + writes a run-summary
  warning when the live suite fails, so failures are visible not silent.

keyless offline suite unchanged: 134 passed, 11 skipped.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant