Skip to content

Commit da6d4f8

Browse files
error test case
1 parent af8cb6d commit da6d4f8

1 file changed

Lines changed: 39 additions & 18 deletions

File tree

‎tests/test_services.py‎

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,15 @@ async def test_known_model_returns_config(self, http_client):
152152
)
153153
assert r.status_code == 200
154154
body = r.json()
155-
assert "precision" in body
155+
# precision/input_tokens/output_tokens/batch_size/pipeline_parallel_size/
156+
# tensor_parallel_size were dropped from this response: none of them were
157+
# ever forwarded to the benchmark container, only displayed. gpu_count is
158+
# the one the backend actually reads; dataset_path is now required and
159+
# must always be present (even if blank) so the UI has a key to bind to.
160+
assert "gpu_count" in body
156161
assert "concurrency" in body
157-
assert "tensor_parallel_size" in body
162+
assert "max_model_len" in body
163+
assert "dataset_path" in body
158164

159165
@pytest.mark.asyncio
160166
async def test_known_model_returns_gated_and_license_fields(self, http_client):
@@ -174,7 +180,8 @@ async def test_unknown_model_falls_back_to_defaults(self, http_client):
174180
assert r.status_code == 200
175181
body = r.json()
176182
# Default config should still have mandatory keys
177-
assert "precision" in body
183+
assert "gpu_count" in body
184+
assert "dataset_path" in body
178185
assert body["gated"] is False
179186

180187
@pytest.mark.asyncio
@@ -187,7 +194,7 @@ async def test_lookup_is_case_insensitive(self, http_client):
187194
)
188195
assert r_lower.status_code == 200
189196
assert r_upper.status_code == 200
190-
assert r_lower.json()["precision"] == r_upper.json()["precision"]
197+
assert r_lower.json()["gpu_count"] == r_upper.json()["gpu_count"]
191198

192199

193200
# ─────────────────────────────────────────────────────────────────────────────
@@ -346,14 +353,35 @@ async def test_start_returns_task_id(self, http_client):
346353
r = await http_client.post("/api/v1/benchmarks/start", json={
347354
"model_name": "tinyllama",
348355
"node_ips": ["10.0.0.1"],
349-
"config": {},
356+
"config": {"dataset_path": "/home/drut/datasets/sharegpt.json"},
350357
})
351358
assert r.status_code == 200
352359
body = r.json()
353360
assert "task_id" in body
354361
assert body["task_id"].startswith("wl-")
355362
assert body["status"] == "success"
356363

364+
@pytest.mark.asyncio
365+
async def test_start_rejects_missing_dataset_path(self, http_client):
366+
# dataset_path is required — the benchmark can't run without it
367+
# (worker.py used to fail deep inside the Celery task instead;
368+
# now the API rejects it up front).
369+
r = await http_client.post("/api/v1/benchmarks/start", json={
370+
"model_name": "tinyllama",
371+
"node_ips": ["10.0.0.1"],
372+
"config": {},
373+
})
374+
assert r.status_code == 422
375+
376+
@pytest.mark.asyncio
377+
async def test_start_rejects_blank_dataset_path(self, http_client):
378+
r = await http_client.post("/api/v1/benchmarks/start", json={
379+
"model_name": "tinyllama",
380+
"node_ips": ["10.0.0.1"],
381+
"config": {"dataset_path": " "},
382+
})
383+
assert r.status_code == 422
384+
357385
@pytest.mark.asyncio
358386
async def test_start_creates_workload_in_created_state(self, http_client, db_session):
359387
from sqlalchemy import select
@@ -364,7 +392,7 @@ async def test_start_creates_workload_in_created_state(self, http_client, db_ses
364392
r = await http_client.post("/api/v1/benchmarks/start", json={
365393
"model_name": "llama3",
366394
"node_ips": ["10.0.0.1"],
367-
"config": {"gpu_count": 2},
395+
"config": {"gpu_count": 2, "dataset_path": "/home/drut/datasets/sharegpt.json"},
368396
})
369397
task_id = r.json()["task_id"]
370398

@@ -387,7 +415,7 @@ async def test_start_multi_node_creates_node_records(self, http_client, db_sessi
387415
r = await http_client.post("/api/v1/benchmarks/start", json={
388416
"model_name": "llama3",
389417
"node_ips": ips,
390-
"config": {},
418+
"config": {"dataset_path": "/home/drut/datasets/sharegpt.json"},
391419
})
392420
task_id = r.json()["task_id"]
393421

@@ -410,7 +438,7 @@ async def test_status_returns_created_for_new_workload(self, http_client):
410438
r_start = await http_client.post("/api/v1/benchmarks/start", json={
411439
"model_name": "tinyllama",
412440
"node_ips": ["10.0.0.1"],
413-
"config": {},
441+
"config": {"dataset_path": "/home/drut/datasets/sharegpt.json"},
414442
})
415443
task_id = r_start.json()["task_id"]
416444

@@ -432,7 +460,7 @@ async def test_start_dispatches_celery_task(self, http_client):
432460
r = await http_client.post("/api/v1/benchmarks/start", json={
433461
"model_name": "tinyllama",
434462
"node_ips": ["10.0.0.1"],
435-
"config": {},
463+
"config": {"dataset_path": "/home/drut/datasets/sharegpt.json"},
436464
})
437465
task_id = r.json()["task_id"]
438466
mock_chain.delay.assert_called_once_with(task_id)
@@ -1398,15 +1426,8 @@ def test_model_storage_mode_default(self):
13981426
assert settings.MODEL_STORAGE_MODE == "huggingface"
13991427

14001428
def test_ssh_default_user_default(self):
1401-
# Verifies the shipped code default for open-source users who clone
1402-
# this repo without a customized .env — not the live runtime value,
1403-
# which Corespan's own deployments intentionally override via .env
1404-
# to match our node machines' actual SSH user. Reading the field
1405-
# default directly (instead of the live `settings` singleton) makes
1406-
# this test correct regardless of what .env is present on the
1407-
# machine running it.
1408-
from app.config import Settings
1409-
assert Settings.model_fields["SSH_DEFAULT_USER"].default == "ubuntu"
1429+
from app.config import settings
1430+
assert settings.SSH_DEFAULT_USER == "ubuntu"
14101431

14111432
def test_database_url_contains_test_db_name(self):
14121433
from app.config import get_database_url

0 commit comments

Comments
 (0)