[Test][kv_offload] Fix flaky drain() helper in test_fs_tier.py (#48545)
Signed-off-by: Chaojun Zhang <chaojun.zhang@intel.com>
Chaojun Zhang committed
Jul 15, 2026 at 19:53 UTC
5811ed6a05158b5d2f953e3b8d3e3082ee36e635
1 file changed
+4
-18
tests/v1/kv_offload/tiering/test_fs_tier.py
+4
-18
@@ -91,24 +91,10 @@ def make_job(
91
)
92
93
94
-def drain(tier: FileSystemTierManager, max_rounds: int = 100) -> list:
95
- """
96
- Call get_finished_jobs() repeatedly until no new results arrive for 20
97
- consecutive rounds or max_rounds is reached.
98
- """
99
- results = []
100
- idle = 0
101
- for _ in range(max_rounds):
102
- time.sleep(0.01)
103
- new = list(tier.get_finished_jobs())
104
- results.extend(new)
105
- if new:
106
- idle = 0
107
- else:
108
- idle += 1
109
- if idle >= 20:
110
- break
111
- return results
94
+def drain(tier: FileSystemTierManager) -> list:
95
+ """Block until all in-flight jobs finish, then collect results."""
96
+ tier.drain_jobs()
97
+ return list(tier.get_finished_jobs())
98
99
100
def lookup_and_wait(