Skip to content

test(athena): allow for floci-duck cold start when polling query state#1910

Open
hampsterx wants to merge 1 commit into
floci-io:mainfrom
hampsterx:test/athena-query-poll-timeout
Open

test(athena): allow for floci-duck cold start when polling query state#1910
hampsterx wants to merge 1 commit into
floci-io:mainfrom
hampsterx:test/athena-query-poll-timeout

Conversation

@hampsterx

Copy link
Copy Markdown
Contributor

Summary

  • AthenaTest.getQueryResults allowed 10s (20 attempts at 500ms) for a query to reach a terminal state. The first Athena query in a run starts the floci-duck sidecar, so that budget also has to cover pulling floci/floci-duck:latest and waiting for the health check. FlociDuckManager.HEALTH_POLL_MAX_MS alone permits 30s for health, so 10s could never cover a cold start.
  • This makes the test a race that CI loses intermittently. In run 29706871552 the image pulled in 4.1s, the sidecar reported healthy at +10.0s, and the query succeeded 372ms after the final poll had already given up.
  • Raise the budget to 60s, matching StepFunctionsActivityTest.pollUntilDone, which polls the same way for the same reason. The loop still exits on the first non-RUNNING state, so a warm sidecar returns as fast as before and only a genuine hang uses the full window.
  • Make a timeout self-explaining. The failure above surfaced as a bare expected: SUCCEEDED but was: RUNNING, which gives no hint that the budget ran out rather than the query landing in a wrong state. Fail fast on FAILED with the stateChangeReason (as DataLakeTest already does), name the execution and budget in the timeout assertion, and restore the interrupt flag rather than swallowing it (as CloudWatchLogsInsightsTest already does).

No production code changes, and no CI config changes: the lazy cold-start path stays under test rather than being pre-warmed away.

Timeline from the failing run

Time Event
23:02:43.809 StartQueryExecution, begins pulling floci/floci-duck:latest
23:02:47.953 Image pulled (4.1s)
23:02:48.256 Container started, waiting for health check
23:02:53.390 Test's 20th and final poll, still RUNNING, assertion fails
23:02:53.762 floci-duck ready
23:02:53.802 Query succeeded

Test plan

  • mvn test-compile clean for compatibility-tests/sdk-test-java
  • Diagnosis confirmed against AthenaService.startQueryExecution: state is RUNNING synchronously, then SUCCEEDED/FAILED via vertx.executeBlocking, so the loop exits on either terminal state and the budget change is a tolerance fix, not a masked hang
  • Budget cross-checked against sibling pollers in the same suite (StepFunctionsActivityTest 60s, DataLakeTest 30s, AppSyncTest 10s)
  • native / sdk-test-java green in CI

@greptile-apps

greptile-apps Bot commented Jul 19, 2026

Copy link
Copy Markdown

Greptile Summary

This PR fixes an intermittent CI flake in AthenaTest.getQueryResults where the 10-second poll budget (20 × 500 ms) was too short to cover a cold sidecar start — the floci-duck health check alone can take up to 30 s on a fresh pull. It raises the budget to 60 s (120 × 500 ms), aligning with StepFunctionsActivityTest, and hardens the surrounding loop.

  • Increases the poll attempts from 20 to 120, giving a 60 s window that covers the full cold-start path (image pull + health check) while exiting immediately on any non-RUNNING state.
  • Adds a fast-fail branch for the FAILED terminal state that surfaces stateChangeReason, and restores the interrupt flag on InterruptedException instead of swallowing it — both patterns already present in sibling tests (DataLakeTest, CloudWatchLogsInsightsTest).

Confidence Score: 5/5

Safe to merge — test-only change that raises a poll timeout and improves error diagnostics with no risk to production behaviour.

The change touches a single test file, adds no new dependencies, and the logic is straightforward: a larger loop bound, a fast-fail branch for the FAILED state, and proper interrupt handling. The only finding is a cosmetic wording issue in the assertion description that could produce a slightly misleading message on a CANCELLED query — no impact on correctness.

No files require special attention.

Important Files Changed

Filename Overview
compatibility-tests/sdk-test-java/src/test/java/com/floci/test/AthenaTest.java Raises cold-start poll budget from 10s to 60s, adds fast-fail on FAILED state with stateChangeReason, restores interrupt flag, and improves timeout assertion message.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Test as AthenaTest
    participant Athena as AthenaService (floci)
    participant Duck as floci-duck sidecar

    Test->>Athena: startQueryExecution()
    Athena-->>Test: "queryExecutionId (state=RUNNING)"
    Note over Duck: Cold start: pull image (~4s) + health check (~6s)

    loop Poll up to 120x (60s budget)
        Test->>Athena: getQueryExecution(queryExecutionId)
        Athena-->>Test: status.state()
        alt "state == FAILED"
            Test->>Test: Assertions.fail(stateChangeReason)
        else "state == RUNNING"
            Test->>Test: Thread.sleep(500ms)
        else "state == SUCCEEDED"
            Test->>Test: exit loop
        end
    end

    Test->>Athena: getQueryResults(queryExecutionId)
    Athena->>Duck: execute query
    Duck-->>Athena: result set
    Athena-->>Test: GetQueryResultsResponse
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Test as AthenaTest
    participant Athena as AthenaService (floci)
    participant Duck as floci-duck sidecar

    Test->>Athena: startQueryExecution()
    Athena-->>Test: "queryExecutionId (state=RUNNING)"
    Note over Duck: Cold start: pull image (~4s) + health check (~6s)

    loop Poll up to 120x (60s budget)
        Test->>Athena: getQueryExecution(queryExecutionId)
        Athena-->>Test: status.state()
        alt "state == FAILED"
            Test->>Test: Assertions.fail(stateChangeReason)
        else "state == RUNNING"
            Test->>Test: Thread.sleep(500ms)
        else "state == SUCCEEDED"
            Test->>Test: exit loop
        end
    end

    Test->>Athena: getQueryResults(queryExecutionId)
    Athena->>Duck: execute query
    Duck-->>Athena: result set
    Athena-->>Test: GetQueryResultsResponse
Loading

Reviews (1): Last reviewed commit: e57785c | Re-trigger Greptile

getQueryResults polled for a terminal query state for 10s (20 attempts at
500ms). The first Athena query in a run starts the floci-duck sidecar, so
that budget has to cover pulling floci/floci-duck:latest and waiting for
its health check before the query itself can run. FlociDuckManager alone
allows up to 30s for the health check (HEALTH_POLL_MAX_MS), so 10s could
never cover a cold start. A recent CI run pulled the image in 4.1s, reached
sidecar health at +10.0s, and succeeded 372ms after the final poll had
already given up.

Raise the budget to 60s, matching StepFunctionsActivityTest.pollUntilDone,
which polls the same way for the same reason. The loop still exits on the
first non-RUNNING state, so a warm sidecar returns as quickly as before and
only a genuine hang uses the full window.

Also make a timeout self-explaining. The failure above surfaced as a bare
"expected: SUCCEEDED but was: RUNNING", which gives no hint that the budget
ran out rather than the query landing in a wrong state. Fail fast on FAILED
with the stateChangeReason, name the execution and the budget in the timeout
assertion, and restore the interrupt flag instead of swallowing it.
@hampsterx
hampsterx force-pushed the test/athena-query-poll-timeout branch from e57785c to 4e4bcee Compare July 20, 2026 00:10
@hectorvent hectorvent added the athena Amazon Athena label Jul 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

athena Amazon Athena

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants