fix: add pytest to build.sh, fix hanging tests, add request timeouts
This commit is contained in:
@@ -3,8 +3,11 @@
|
||||
import time
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
import requests
|
||||
|
||||
REQUEST_TIMEOUT = 5
|
||||
|
||||
|
||||
def _unique_id():
|
||||
return str(uuid.uuid4())
|
||||
@@ -26,7 +29,9 @@ def test_full_pipeline_lifecycle(pipeline_server):
|
||||
{"id": _unique_id(), "text": "echo step3", "title": "Step 3", "order": 2},
|
||||
],
|
||||
}
|
||||
resp = requests.post(f"{base}/api/pipelines", json=pipeline)
|
||||
resp = requests.post(
|
||||
f"{base}/api/pipelines", json=pipeline, timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
created = resp.json()
|
||||
assert created["id"] == pipeline_id
|
||||
@@ -34,13 +39,15 @@ def test_full_pipeline_lifecycle(pipeline_server):
|
||||
assert len(created["prompts"]) == 3
|
||||
|
||||
# --- List pipelines ---
|
||||
resp = requests.get(f"{base}/api/pipelines")
|
||||
resp = requests.get(f"{base}/api/pipelines", timeout=REQUEST_TIMEOUT)
|
||||
assert resp.status_code == 200
|
||||
pipelines = resp.json()
|
||||
assert any(p["id"] == pipeline_id for p in pipelines)
|
||||
|
||||
# --- Get single pipeline ---
|
||||
resp = requests.get(f"{base}/api/pipelines/{pipeline_id}")
|
||||
resp = requests.get(
|
||||
f"{base}/api/pipelines/{pipeline_id}", timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
fetched = resp.json()
|
||||
assert fetched["id"] == pipeline_id
|
||||
@@ -49,7 +56,9 @@ def test_full_pipeline_lifecycle(pipeline_server):
|
||||
assert fetched["prompts"][0]["order"] == 0
|
||||
|
||||
# --- Start a run ---
|
||||
resp = requests.post(f"{base}/api/runs", json={"pipeline_id": pipeline_id})
|
||||
resp = requests.post(
|
||||
f"{base}/api/runs", json={"pipeline_id": pipeline_id}, timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
run_data = resp.json()
|
||||
run_id = run_data["run_id"]
|
||||
@@ -58,7 +67,9 @@ def test_full_pipeline_lifecycle(pipeline_server):
|
||||
|
||||
# --- Poll run status until completed ---
|
||||
for _ in range(60):
|
||||
resp = requests.get(f"{base}/api/runs/{run_id}/status")
|
||||
resp = requests.get(
|
||||
f"{base}/api/runs/{run_id}/status", timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
status_data = resp.json()
|
||||
if status_data["status"] in ("completed", "error"):
|
||||
@@ -71,15 +82,19 @@ def test_full_pipeline_lifecycle(pipeline_server):
|
||||
assert len(status_data["steps"]) == 3
|
||||
|
||||
# --- Get log ---
|
||||
resp = requests.get(f"{base}/api/runs/{run_id}/log")
|
||||
resp = requests.get(f"{base}/api/runs/{run_id}/log", timeout=REQUEST_TIMEOUT)
|
||||
assert resp.status_code == 200
|
||||
assert len(resp.text) > 0
|
||||
|
||||
# --- Delete pipeline ---
|
||||
resp = requests.delete(f"{base}/api/pipelines/{pipeline_id}")
|
||||
resp = requests.delete(
|
||||
f"{base}/api/pipelines/{pipeline_id}", timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 200
|
||||
assert resp.json()["deleted"] == pipeline_id
|
||||
|
||||
# --- Verify deletion ---
|
||||
resp = requests.get(f"{base}/api/pipelines/{pipeline_id}")
|
||||
resp = requests.get(
|
||||
f"{base}/api/pipelines/{pipeline_id}", timeout=REQUEST_TIMEOUT
|
||||
)
|
||||
assert resp.status_code == 404
|
||||
|
||||
Reference in New Issue
Block a user