From ea3f1fbd0d27228a6ffad3c598cdbad150ce90c9 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 22 Jul 2026 13:45:22 +0200 Subject: [PATCH] test(e2e): poll Files list after upload (read-after-write staleness) The nightly's remaining flake after #521 was `TestFullE2E` failing on "uploaded file must appear in list": the just-uploaded file was missing from an immediate tag-filtered Files list. The upload is durable (the facade path round-trips read_bytes right before), but the tag index is read-after-write eventually consistent and lags a few seconds -- so it passed locally and in some CI runs, failed in others. Poll the list until the file appears (bounded ~30s) instead of asserting the first read, in both the SDK-facade round-trip (kbc.files.list) and the CLI file-ops flow (storage files --tag). Same pattern already used for the add-column / swap read-after-DDL lags. Test-only. make check green (4648 passed). --- tests/test_e2e.py | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tests/test_e2e.py b/tests/test_e2e.py index 89145454..56ea69cc 100644 --- a/tests/test_e2e.py +++ b/tests/test_e2e.py @@ -2251,8 +2251,17 @@ def _test_library_facade(self, workspace_id: int, table_id: str) -> None: assert kbc.files.read_bytes(meta.id) == payload, "read_bytes round-trip mismatch" - listed = kbc.files.list(tags=[facade_tag]) - assert any(f.id == meta.id for f in listed), "uploaded file must appear in list" + # The tag-filtered Files list is read-after-write eventually + # consistent: the upload is durable (read_bytes round-tripped it + # just above), but the tag index can lag a few seconds. Poll instead + # of asserting the first list (intermittently missed in CI 2026-07-22). + found = False + for _ in range(15): + if any(f.id == meta.id for f in kbc.files.list(tags=[facade_tag])): + found = True + break + time.sleep(2) + assert found, "uploaded file must appear in list" kbc.files.delete(meta.id) self._created_file_ids.remove(meta.id) @@ -2672,16 +2681,23 @@ def _test_file_operations(self) -> None: self._created_file_ids.append(file_id) assert file_id > 0 - # files (list) - data = self._run_ok( - "storage", - "files", - "--project", - self.alias, - "--tag", - f"e2e-{RUN_ID}", - ) - file_ids = [f["id"] for f in data["data"]["files"]] + # files (list) -- the tag index is read-after-write eventually + # consistent; poll until the just-uploaded file appears rather than + # asserting the first list. + file_ids: list[int] = [] + for _ in range(15): + data = self._run_ok( + "storage", + "files", + "--project", + self.alias, + "--tag", + f"e2e-{RUN_ID}", + ) + file_ids = [f["id"] for f in data["data"]["files"]] + if file_id in file_ids: + break + time.sleep(2) assert file_id in file_ids # file-detail