94057c3d3e
PR Test (NPU) / check-changes (push) Has been cancelled
PR Test (NPU) / pr-gate (push) Has been cancelled
PR Test (NPU) / set-image-config (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-1-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (0) (push) Has been cancelled
PR Test (NPU) / stage-b-test-2-npu-a2 (1) (push) Has been cancelled
PR Test (NPU) / stage-b-test-4-npu-a3 (push) Has been cancelled
PR Test (NPU) / stage-b-test-16-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-1-npu-a3 (push) Has been cancelled
PR Test (NPU) / multimodal-gen-test-2-npu-a3 (push) Has been cancelled
PR Test (Arm64) / pr-gate (push) Has been cancelled
PR Test (Arm64) / check-changes (push) Has been cancelled
PR Test (Arm64) / build-test (push) Has been cancelled
PR Test (sgl-router) / gate (push) Has been cancelled
PR Test (sgl-router) / tier-1 — lint (push) Has been cancelled
PR Test (sgl-router) / tier-2 — build + test (push) Has been cancelled
PR Test (sgl-router) / tier-3 — docker (placeholder) (push) Has been cancelled
PR Test (sgl-router) / tier-3 — k8s integration (push) Has been cancelled
PR Test (sgl-router) / tier-3 — e2e (push) Has been cancelled
PR Test (sgl-router) / finish (push) Has been cancelled
PR Test (NPU) / single-node-poc (map[name:qwen3_6_27b_w8a8_1p_in64k_out1k_50ms runner:linux-aarch64-a3-2 test_case:test/registered/ascend/performance/qwen3_6_27b/test_npu_qwen3_6_27b_w8a8_1p_in64k_out1k_50ms.py test_type:perf]) (push) Has been cancelled
PR Test (NPU) / pr-test-npu-finish (push) Has been cancelled
PR Test (Xeon) / pr-gate (push) Has been cancelled
PR Test (Xeon) / check-changes (push) Has been cancelled
PR Test (Xeon) / build-test (, xeon-gnr, base-b-test-cpu) (push) Has been cancelled
PR Test (XPU) / check-changes (push) Has been cancelled
PR Test (XPU) / pr-gate (push) Has been cancelled
PR Test (XPU) / stage-a-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / wait-for-stage-a (push) Has been cancelled
PR Test (XPU) / stage-b-test-1-gpu-xpu (push) Has been cancelled
PR Test (XPU) / finish (push) Has been cancelled
CI Model Inventory / build-inventory (push) Has been cancelled
Lint / lint (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Compilation Check (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Manual Policy (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark - Request Processing (push) Has been cancelled
PR Benchmark (SMG Components) / Benchmark Summary (push) Has been cancelled
PR Test (SMG) / build-wheel (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on windows (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (x86_64 - auto) (push) Has been cancelled
PR Test (SMG) / python-unit-tests (push) Has been cancelled
PR Test (SMG) / unit-tests (push) Has been cancelled
PR Test (SMG) / benchmarks (push) Has been cancelled
PR Test (SMG) / chat-completions (push) Has been cancelled
PR Test (SMG) / chat-completions-4gpu (push) Has been cancelled
PR Test (SMG) / e2e (push) Has been cancelled
PR Test (SMG) / docker-build-test (push) Has been cancelled
PR Test (SMG) / k8s-integration (push) Has been cancelled
PR Test (SMG) / finish (push) Has been cancelled
PR Test (SMG) / summarize-benchmarks (push) Has been cancelled
Release SGLang Model Gateway Docker Image / publish (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on macos (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - auto) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (aarch64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / build on linux (x86_64 - musllinux_1_1) (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Build SDist (push) Has been cancelled
Release SGLang Model Gateway to PyPI / Upload to PyPI (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (aarch64, 12.9, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu129-matrix (x86_64, 12.9, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu129 (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (aarch64, 13.0, 3.10, arm-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / build-cu130-matrix (x86_64, 13.0, 3.10, x64-kernel-build-node) (push) Has been cancelled
Release SGLang Kernels / release-cu130 (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 700) (push) Has been cancelled
Release SGLang Kernels / build-rocm-matrix (3.10, 720) (push) Has been cancelled
Release SGLang Kernels / release-rocm700 (push) Has been cancelled
Release SGLang Kernels / release-rocm720 (push) Has been cancelled
Release SGLang Kernels / build-musa43 (43, 3.10) (push) Has been cancelled
Release SGLang Kernels / release-musa43 (push) Has been cancelled
196 lines
7.2 KiB
Python
196 lines
7.2 KiB
Python
"""Unit tests for runner_utilization_report.classify_job.
|
|
|
|
Pure-logic tests (no GitHub API, stdlib only) so they run in the
|
|
runner-utilization workflow without installing dependencies:
|
|
|
|
python -m unittest discover -s scripts/ci/utils -p 'test_runner_utilization_report.py'
|
|
|
|
Regression guard for the queue-time underestimation bug: jobs still
|
|
waiting in the runner queue (or still running) used to be dropped because
|
|
the old code required a runner_name and a completed_at, so multi-hour
|
|
8-gpu waits never showed up in max/avg queue time.
|
|
"""
|
|
|
|
import os
|
|
import sys
|
|
import unittest
|
|
from datetime import datetime, timedelta, timezone
|
|
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import runner_utilization_report as rur # noqa: E402
|
|
|
|
NOW = datetime(2026, 5, 27, 21, 50, 56, tzinfo=timezone.utc)
|
|
CREATED = NOW - timedelta(hours=4) # entered the queue 4h ago
|
|
|
|
|
|
def _job(**kw):
|
|
base = {
|
|
"name": "base-c-test-8-gpu-h200 / base-c-test-8-gpu-h200 (3)",
|
|
"status": "completed",
|
|
"conclusion": "success",
|
|
"runner_name": "h200-wk03",
|
|
"labels": ["self-hosted", "X64", "8-gpu-h200"],
|
|
"created_at": CREATED.isoformat().replace("+00:00", "Z"),
|
|
"started_at": None,
|
|
"completed_at": None,
|
|
"html_url": "https://github.com/o/r/actions/runs/1/job/2",
|
|
}
|
|
base.update(kw)
|
|
return base
|
|
|
|
|
|
def _iso(dt):
|
|
return dt.isoformat().replace("+00:00", "Z")
|
|
|
|
|
|
class TestClassifyJob(unittest.TestCase):
|
|
def test_queued_job_counts_ongoing_wait(self):
|
|
"""The core bug: a still-queued job reports started_at == created_at
|
|
(placeholder) and no completed_at. Its wait must be now - created_at,
|
|
not 0, and it must not be dropped."""
|
|
job = _job(
|
|
status="queued",
|
|
runner_name="",
|
|
started_at=_iso(CREATED), # GitHub placeholder == created_at
|
|
completed_at=None,
|
|
)
|
|
info = rur.classify_job(job, NOW)
|
|
self.assertIsNotNone(info)
|
|
self.assertAlmostEqual(info["queue_time"], 4 * 3600, delta=1)
|
|
self.assertIsNone(info["start"]) # no runner occupied yet
|
|
self.assertEqual(info["labels"], ["8-gpu-h200"]) # generic labels dropped
|
|
|
|
def test_in_progress_job_counts_final_wait(self):
|
|
"""A running job's wait is final (started - created); old code dropped
|
|
it for lacking completed_at."""
|
|
started = CREATED + timedelta(hours=3)
|
|
job = _job(status="in_progress", started_at=_iso(started), completed_at=None)
|
|
info = rur.classify_job(job, NOW)
|
|
self.assertIsNotNone(info)
|
|
self.assertAlmostEqual(info["queue_time"], 3 * 3600, delta=1)
|
|
self.assertEqual(info["start"], started)
|
|
self.assertEqual(info["end"], NOW) # still occupying the runner
|
|
|
|
def test_completed_job_unchanged(self):
|
|
started = CREATED + timedelta(minutes=30)
|
|
completed = CREATED + timedelta(minutes=90)
|
|
job = _job(started_at=_iso(started), completed_at=_iso(completed))
|
|
info = rur.classify_job(job, NOW)
|
|
self.assertAlmostEqual(info["queue_time"], 30 * 60, delta=1)
|
|
self.assertAlmostEqual(info["duration"], 60 * 60, delta=1)
|
|
self.assertEqual(info["end"], completed)
|
|
|
|
def test_skipped_job_dropped(self):
|
|
"""Skipped / cancelled-before-start jobs never waited for a runner."""
|
|
job = _job(status="completed", runner_name="", started_at=None)
|
|
self.assertIsNone(rur.classify_job(job, NOW))
|
|
|
|
def test_queued_without_created_dropped(self):
|
|
job = _job(status="queued", runner_name="", created_at=None, started_at=None)
|
|
self.assertIsNone(rur.classify_job(job, NOW))
|
|
|
|
|
|
class TestConcurrencyHandlesQueuedJobs(unittest.TestCase):
|
|
def test_queued_job_does_not_crash_and_counts_in_peak_queue(self):
|
|
window_start = NOW - timedelta(hours=24)
|
|
queued = rur.classify_job(
|
|
_job(status="queued", runner_name="", started_at=_iso(CREATED)), NOW
|
|
)
|
|
ran = rur.classify_job(
|
|
_job(
|
|
started_at=_iso(CREATED + timedelta(hours=1)),
|
|
completed_at=_iso(CREATED + timedelta(hours=2)),
|
|
),
|
|
NOW,
|
|
)
|
|
conc = rur.calculate_concurrency_metrics(
|
|
[queued, ran], window_start, NOW, num_runners=2
|
|
)
|
|
# Both jobs were waiting at CREATED before either started -> peak 2.
|
|
self.assertEqual(conc["peak_queue"], 2)
|
|
|
|
|
|
class TestStatusAndFormatting(unittest.TestCase):
|
|
def test_status_mapping_and_url(self):
|
|
for conclusion, expected in (
|
|
("success", "pass"),
|
|
("failure", "fail"),
|
|
("timed_out", "fail"),
|
|
("cancelled", "cancel"),
|
|
):
|
|
info = rur.classify_job(
|
|
_job(
|
|
conclusion=conclusion,
|
|
started_at=_iso(CREATED + timedelta(minutes=5)),
|
|
completed_at=_iso(CREATED + timedelta(minutes=10)),
|
|
),
|
|
NOW,
|
|
)
|
|
self.assertEqual(info["status"], expected)
|
|
self.assertEqual(
|
|
info["html_url"], "https://github.com/o/r/actions/runs/1/job/2"
|
|
)
|
|
|
|
self.assertEqual(
|
|
rur.classify_job(
|
|
_job(status="queued", runner_name="", started_at=_iso(CREATED)), NOW
|
|
)["status"],
|
|
"queued",
|
|
)
|
|
self.assertEqual(
|
|
rur.classify_job(
|
|
_job(
|
|
status="in_progress", started_at=_iso(CREATED + timedelta(hours=1))
|
|
),
|
|
NOW,
|
|
)["status"],
|
|
"running",
|
|
)
|
|
|
|
def test_format_status_counts(self):
|
|
self.assertEqual(rur.format_status_counts({}), "—")
|
|
cell = rur.format_status_counts({"pass": 5, "queued": 2, "fail": 0})
|
|
self.assertIn("✅5", cell)
|
|
self.assertIn("⏳2", cell)
|
|
self.assertNotIn("❌", cell) # zero counts omitted
|
|
|
|
def test_format_report_has_links_and_status(self):
|
|
results = [
|
|
{
|
|
"label": "8-gpu-h200",
|
|
"num_runners": 4,
|
|
"effective_runners": 4,
|
|
"num_jobs": 2,
|
|
"total_active_hours": 1.0,
|
|
"utilization_pct": 50.0,
|
|
"avg_queue_min": 100.0,
|
|
"max_queue_min": 264.0,
|
|
"peak_concurrent": 1,
|
|
"avg_concurrent": 0.5,
|
|
"saturation_hours": 0.0,
|
|
"saturation_pct": 0.0,
|
|
"peak_queue": 2,
|
|
"status_counts": {"pass": 1, "queued": 1},
|
|
}
|
|
]
|
|
url = "https://github.com/sgl-project/sglang/actions/runs/1/job/2"
|
|
waits = [
|
|
{
|
|
"queue_time": 264 * 60,
|
|
"status": "queued",
|
|
"labels": ["8-gpu-h200"],
|
|
"job_name": "base-c-test-8-gpu-h200 (3)",
|
|
"html_url": url,
|
|
}
|
|
]
|
|
report = rur.format_report(results, 24, 0.0, longest_waits=waits)
|
|
self.assertIn("| Status |", report) # new main-table column
|
|
self.assertIn("Longest Queue Waits", report)
|
|
self.assertIn(f"]({url})", report) # clickable job link
|
|
self.assertIn("264m", report)
|
|
self.assertIn("⏳", report)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|