Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions tests/integration/test_query_async_polling.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,20 @@ def test_query_async_polling(
)
assert run.row_count == 1

runs_listing = query_runs_api.list_query_runs(x_database_id=database_id, limit=50)
assert any(r.id == query_run_id for r in runs_listing.query_runs), (
f"query run {query_run_id} not surfaced by list_query_runs"
)
# The shared sdkci database serves concurrent CI runs, and a run that just
# reached terminal status can lag out of list_query_runs briefly — retry
# for a few seconds before declaring it missing.
listing_deadline = time.monotonic() + 10.0
while True:
runs_listing = query_runs_api.list_query_runs(
x_database_id=database_id, limit=50
)
if any(r.id == query_run_id for r in runs_listing.query_runs):
break
assert time.monotonic() < listing_deadline, (
f"query run {query_run_id} not surfaced by list_query_runs"
)
time.sleep(POLL_INTERVAL_S)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: the list_results assertion at line 99 has the same race (not blocking).

list_results runs against the same shared sdkci-shared database, immediately after the result is created. A result that just became visible can lag out of the listing exactly like a query run does. That assertion still fails on the first miss, so test_query_async_polling can flake again at line 99 for the same reason.

Wrap the list_results call in the same bounded retry, or factor the retry into a small local helper that both listings call.


if run.result_id:
result = results_api.get_result(run.result_id, x_database_id=database_id)
Expand Down