Unverified Commit 6dad4c57 authored by yzong-rh's avatar yzong-rh Committed by GitHub
Browse files

[Test] Fix flaky race condition in test_abort_final_step (#38414)


Signed-off-by: default avatarYifan <yzong@redhat.com>
parent 171775f3
...@@ -259,8 +259,25 @@ async def test_abort_during_final_step(async_scheduling: bool): ...@@ -259,8 +259,25 @@ async def test_abort_during_final_step(async_scheduling: bool):
# Wait for generation to complete # Wait for generation to complete
await gen_task await gen_task
# Give the scheduler a moment to finish cleanup # Poll for the KV connector to record the finish status
await asyncio.sleep(0.1) timeout = 5.0
start = time.time()
captured_statuses = []
while time.time() - start < timeout:
with open(status_file) as f4:
status_lines = f4.read().strip().split("\n")
captured_statuses = [
line
for line in status_lines
if line and line.startswith("FINISHED_")
]
if captured_statuses:
break
await asyncio.sleep(0.05)
else:
raise TimeoutError(
"Timeout waiting for KV connector to record finish status."
)
# Verify we got output # Verify we got output
assert len(outputs) > 0, "Should have received at least one output" assert len(outputs) > 0, "Should have received at least one output"
...@@ -275,15 +292,6 @@ async def test_abort_during_final_step(async_scheduling: bool): ...@@ -275,15 +292,6 @@ async def test_abort_during_final_step(async_scheduling: bool):
f"'{final_output.outputs[0].finish_reason}'. " f"'{final_output.outputs[0].finish_reason}'. "
) )
with open(status_file) as f4:
status_lines = f4.read().strip().split("\n")
# Filter for actual finish statuses (not INIT or empty lines)
captured_statuses = [
line
for line in status_lines
if line and line.startswith("FINISHED_")
]
assert len(captured_statuses) >= 1, ( assert len(captured_statuses) >= 1, (
f"Expected at least 1 captured finish status, got " f"Expected at least 1 captured finish status, got "
f"{len(captured_statuses)}. File content: {status_lines}" f"{len(captured_statuses)}. File content: {status_lines}"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment