From 5811ed6a05158b5d2f953e3b8d3e3082ee36e635 Mon Sep 17 00:00:00 2001 From: Chaojun Zhang Date: Wed, 15 Jul 2026 19:53:47 +0800 Subject: [PATCH] [Test][kv_offload] Fix flaky drain() helper in test_fs_tier.py (#48545) Signed-off-by: Chaojun Zhang --- tests/v1/kv_offload/tiering/test_fs_tier.py | 22 ++++----------------- 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/tests/v1/kv_offload/tiering/test_fs_tier.py b/tests/v1/kv_offload/tiering/test_fs_tier.py index c90a4dad5e..4ac734d957 100644 --- a/tests/v1/kv_offload/tiering/test_fs_tier.py +++ b/tests/v1/kv_offload/tiering/test_fs_tier.py @@ -91,24 +91,10 @@ def make_job( ) -def drain(tier: FileSystemTierManager, max_rounds: int = 100) -> list: - """ - Call get_finished_jobs() repeatedly until no new results arrive for 20 - consecutive rounds or max_rounds is reached. - """ - results = [] - idle = 0 - for _ in range(max_rounds): - time.sleep(0.01) - new = list(tier.get_finished_jobs()) - results.extend(new) - if new: - idle = 0 - else: - idle += 1 - if idle >= 20: - break - return results +def drain(tier: FileSystemTierManager) -> list: + """Block until all in-flight jobs finish, then collect results.""" + tier.drain_jobs() + return list(tier.get_finished_jobs()) def lookup_and_wait(