Working log streaming

This commit is contained in:
Qubasa
2023-09-27 01:52:38 +02:00
committed by Mic92
parent 1da6f127f5
commit d73dc7048b
3 changed files with 71 additions and 64 deletions

View File

@@ -4,18 +4,18 @@ import pytest
from api import TestClient
@pytest.mark.impure
def test_inspect(api: TestClient, test_flake_with_core: Path) -> None:
response = api.post(
"/api/vms/inspect",
json=dict(flake_url=str(test_flake_with_core), flake_attr="vm1"),
)
assert response.status_code == 200, "Failed to inspect vm"
config = response.json()["config"]
assert config.get("flake_attr") == "vm1"
assert config.get("cores") == 1
assert config.get("memory_size") == 1024
assert config.get("graphics") is True
# @pytest.mark.impure
# def test_inspect(api: TestClient, test_flake_with_core: Path) -> None:
# response = api.post(
# "/api/vms/inspect",
# json=dict(flake_url=str(test_flake_with_core), flake_attr="vm1"),
# )
# assert response.status_code == 200, "Failed to inspect vm"
# config = response.json()["config"]
# assert config.get("flake_attr") == "vm1"
# assert config.get("cores") == 1
# assert config.get("memory_size") == 1024
# assert config.get("graphics") is True
@pytest.mark.impure
@@ -43,6 +43,7 @@ def test_create(api: TestClient, test_flake_with_core: Path) -> None:
response = api.get(f"/api/vms/{uuid}/logs")
print("=========LOGS==========")
for line in response.stream:
print(line)
print(f"line: {line}")
assert line != b"", "Failed to get vm logs"
assert response.status_code == 200, "Failed to get vm logs"