test(ci): remove Docker output and stdin timing races
This commit is contained in:
1 parent
112ea9d174
commit
475b045b6f
3 files changed
+53
-24
No files matched your search
@@ -445,7 +445,7 @@ def test_exec_rejects_unsupported_shell(tmp_path):
|
||||
def test_exec_can_continue_with_stdin(tmp_path):
|
||||
async def run() -> tuple[str, str, str]:
|
||||
manager = ExecSessionManager()
|
||||
exec_tool = ExecTool(working_dir=str(tmp_path), timeout=5, session_manager=manager)
|
||||
exec_tool = ExecTool(working_dir=str(tmp_path), timeout=30, session_manager=manager)
|
||||
stdin_tool = ExecSessionTool(manager=manager)
|
||||
command = _python_command(
|
||||
"import sys; print('ready', flush=True); "
|
||||
@@ -453,16 +453,18 @@ def test_exec_can_continue_with_stdin(tmp_path):
|
||||
)
|
||||
|
||||
try:
|
||||
initial = await exec_tool.execute(command=command, yield_time_ms=500)
|
||||
initial = await exec_tool.execute(command=command, yield_time_ms=0)
|
||||
sid = _session_id(initial)
|
||||
result = await stdin_tool.execute(session_id=sid, input="ping\n", timeout_ms=1000)
|
||||
observed, final = await _poll_if_running(result, stdin_tool)
|
||||
if "ready" not in initial:
|
||||
initial += await stdin_tool.execute(session_id=sid, wait_for="ready", timeout_ms=10000)
|
||||
assert "ready" in initial, initial
|
||||
result = await stdin_tool.execute(session_id=sid, input="ping\n", timeout_ms=0)
|
||||
observed, final = await _poll_if_running(result, stdin_tool, timeout_ms=10000)
|
||||
return initial, observed, final
|
||||
finally:
|
||||
await manager.close_all()
|
||||
|
||||
initial, result, final = asyncio.run(run())
|
||||
assert "ready" in initial + result
|
||||
assert "Process running" in initial
|
||||
assert "Elapsed:" in initial
|
||||
assert "got:ping" in result
|
||||
@@ -471,30 +473,37 @@ def test_exec_can_continue_with_stdin(tmp_path):
|
||||
|
||||
|
||||
def test_exec_session_can_close_stdin(tmp_path):
|
||||
async def run() -> tuple[str, str]:
|
||||
async def run() -> tuple[str, str, str]:
|
||||
manager = ExecSessionManager()
|
||||
exec_tool = ExecTool(working_dir=str(tmp_path), timeout=5, session_manager=manager)
|
||||
exec_tool = ExecTool(working_dir=str(tmp_path), timeout=30, session_manager=manager)
|
||||
stdin_tool = ExecSessionTool(manager=manager)
|
||||
command = _python_command(
|
||||
"import sys; print('ready', flush=True); "
|
||||
"data=sys.stdin.read(); print('got:' + data, flush=True)"
|
||||
)
|
||||
|
||||
initial = await exec_tool.execute(command=command, yield_time_ms=1500)
|
||||
sid = _session_id(initial)
|
||||
result = await stdin_tool.execute(
|
||||
session_id=sid,
|
||||
input="payload",
|
||||
close_stdin=True,
|
||||
timeout_ms=1500,
|
||||
)
|
||||
return initial, result
|
||||
try:
|
||||
initial = await exec_tool.execute(command=command, yield_time_ms=0)
|
||||
sid = _session_id(initial)
|
||||
if "ready" not in initial:
|
||||
initial += await stdin_tool.execute(session_id=sid, wait_for="ready", timeout_ms=10000)
|
||||
assert "ready" in initial, initial
|
||||
# Check the acknowledgement separately from the child's EOF-driven exit.
|
||||
result = await stdin_tool.execute(
|
||||
session_id=sid,
|
||||
input="payload",
|
||||
close_stdin=True,
|
||||
timeout_ms=0,
|
||||
)
|
||||
observed, final = await _poll_if_running(result, stdin_tool, timeout_ms=10000)
|
||||
return result, observed, final
|
||||
finally:
|
||||
await manager.close_all()
|
||||
|
||||
initial, result = asyncio.run(run())
|
||||
assert "ready" in initial + result
|
||||
assert "got:payload" in result
|
||||
result, observed, final = asyncio.run(run())
|
||||
assert "Stdin closed." in result
|
||||
assert "Exit code: 0" in result
|
||||
assert "got:payload" in observed
|
||||
assert "Exit code: 0" in final
|
||||
|
||||
|
||||
def test_exec_session_can_terminate_session(tmp_path):
|
||||
|
||||
Reference in new issue
Block a user