Completely working log streaming
This commit is contained in:
parent
8d390af122
commit
08eab785c6
@ -144,11 +144,12 @@ async def get_logs(uuid: str) -> StreamingResponse:
|
||||
yield line + "\n"
|
||||
for line in proc.stdout:
|
||||
yield line + "\n"
|
||||
break
|
||||
continue
|
||||
while True:
|
||||
out = proc.output
|
||||
line = out.get()
|
||||
if line is None:
|
||||
log.debug("stream logs and line is None")
|
||||
break
|
||||
yield line
|
||||
|
||||
|
@ -40,10 +40,17 @@ def test_create(api: TestClient, test_flake_with_core: Path) -> None:
|
||||
assert response.status_code == 200, "Failed to get vm status"
|
||||
|
||||
response = api.get(f"/api/vms/{uuid}/logs")
|
||||
print("=========LOGS==========")
|
||||
print("=========FLAKE LOGS==========")
|
||||
for line in response.stream:
|
||||
assert line != b"", "Failed to get vm logs"
|
||||
print(line.decode("utf-8"), end="")
|
||||
print("=========END LOGS==========")
|
||||
assert response.status_code == 200, "Failed to get vm logs"
|
||||
|
||||
response = api.get(f"/api/vms/{uuid}/logs")
|
||||
print("=========VM LOGS==========")
|
||||
for line in response.stream:
|
||||
assert line != b"", "Failed to get vm logs"
|
||||
print(line.decode("utf-8"), end="")
|
||||
print("=========END LOGS==========")
|
||||
assert response.status_code == 200, "Failed to get vm logs"
|
||||
time.sleep(10)
|
Loading…
Reference in New Issue
Block a user