From 11f956ef6c7839bfc0691aed6352c7c06327006c Mon Sep 17 00:00:00 2001 From: Quentin Millpass Date: Tue, 24 Nov 2026 23:15:16 -0700 Subject: [PATCH 1/2] [CU-1k5fpda96vg] Wait for instruments to be indexed in the e2e instruments test --- tests/e2e_tests/cli/test_workbench.py | 29 ++++++++++++++++----------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/tests/e2e_tests/cli/test_workbench.py b/tests/e2e_tests/cli/test_workbench.py index 388496c7..692ad8d4 100644 --- a/tests/e2e_tests/cli/test_workbench.py +++ b/tests/e2e_tests/cli/test_workbench.py @@ -1707,28 +1707,33 @@ def test_workflow_transformation_delete(self): def test_instruments_list(self): self._create_storage_account(provider=Provider.aws) - self._wait() - instruments = [Instrument(**instrument) for instrument in self.simple_invoke( - 'workbench', 'instruments', 'list' - )] + instruments = self._wait_for_listed( + Instrument, + 'workbench', 'instruments', 'list', + description='instruments to be indexed', + ) self.assert_not_empty(instruments, f'Expected at least one instrument. Found {instruments}') for instrument in instruments: self.assert_not_empty(instrument.id, 'Instrument ID should not be empty') - def _wait_for_samples(self): + return self._wait_for_listed( + Sample, + 'workbench', 'samples', 'list', + description='samples to be created', + ) + + def _wait_for_listed(self, model, *command, description): timeout = 300 start_time = asyncio.get_event_loop().time() + items = [] while True: - samples = [Sample(**sample) for sample in self.simple_invoke( - 'workbench', 'samples', 'list' - )] - if samples: - break + items = [model(**item) for item in self.simple_invoke(*command)] + if items: + return items if asyncio.get_event_loop().time() - start_time > timeout: - raise TimeoutError("Timeout reached while waiting for samples to be created.") + raise TimeoutError(f"Timeout reached while waiting for {description}. Found {items}") sleep(2) - return samples def _wait(self): timeout = 30 From 4bd10eb10ba417465c9e37a543448421319292e9 Mon Sep 17 00:00:00 2001 From: Quentin Millpass Date: Wed, 25 Nov 2026 00:20:30 -0700 Subject: [PATCH 2/2] [CU-1k5fpda96vg] Time the e2e polling with a monotonic clock instead of the asyncio loop --- tests/e2e_tests/cli/test_workbench.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/tests/e2e_tests/cli/test_workbench.py b/tests/e2e_tests/cli/test_workbench.py index 692ad8d4..4320cb1e 100644 --- a/tests/e2e_tests/cli/test_workbench.py +++ b/tests/e2e_tests/cli/test_workbench.py @@ -1,11 +1,10 @@ -import asyncio import json import random from datetime import date, timedelta from pathlib import Path from tempfile import TemporaryDirectory -from time import sleep +from time import monotonic, sleep from dnastack.client.workbench.workflow.models import Workflow, WorkflowVersion, WorkflowDefaults, \ WorkflowTransformation @@ -1725,17 +1724,14 @@ def _wait_for_samples(self): def _wait_for_listed(self, model, *command, description): timeout = 300 - start_time = asyncio.get_event_loop().time() - items = [] + start_time = monotonic() while True: items = [model(**item) for item in self.simple_invoke(*command)] if items: return items - if asyncio.get_event_loop().time() - start_time > timeout: - raise TimeoutError(f"Timeout reached while waiting for {description}. Found {items}") + if monotonic() - start_time > timeout: + raise TimeoutError(f'Timed out after {timeout}s waiting for {description}.') sleep(2) def _wait(self): - timeout = 30 - asyncio.get_event_loop().time() - sleep(timeout) + sleep(30)