Skip to content

Commit 58a0184

Browse files
Merge pull request #25 from alphabetc1/ci/add_more_testcase
[WIP] ci: add more testcase
2 parents 1c50a0f + 7ca7d85 commit 58a0184

File tree

13 files changed

+1659
-213
lines changed

13 files changed

+1659
-213
lines changed

.github/workflows/pr-test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: PR Test
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
jobs:
8+
pr-test:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
15+
with:
16+
python-version: "3.12"
17+
18+
- name: Install package and test deps
19+
run: |
20+
python -m pip install --upgrade pip
21+
python -m pip install -e .
22+
python -m pip install pytest
23+
24+
- name: Run CPU-only tests
25+
run: pytest tests/unit -v

development.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Run tests:
1010

1111
```bash
1212
pip install pytest
13+
# CPU-only tests (unit + fake e2e)
1314
pytest tests/unit -v
15+
16+
# Real E2E tests (GPU required, longer runtime)
17+
pytest tests/e2e/test_e2e_sglang.py -v -s
1418
```
1519

1620
## Benchmark Scripts

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ package-dir = { "" = "src" }
3333
where = ["src"]
3434

3535
[tool.pytest.ini_options]
36-
testpaths = ["tests/unit"]
36+
testpaths = ["tests/unit", "tests/e2e"]

src/sglang_diffusion_routing/cli/main.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from __future__ import annotations
55

66
import argparse
7-
import asyncio
87
import sys
98

109
from sglang_diffusion_routing import DiffusionRouter
@@ -26,18 +25,9 @@ def _run_router_server(
2625
worker_urls if worker_urls is not None else args.worker_urls or []
2726
)
2827
router = DiffusionRouter(args, verbose=args.verbose)
29-
refresh_tasks = []
3028
for url in worker_urls:
3129
normalized_url = router.normalize_worker_url(url)
3230
router.register_worker(normalized_url)
33-
refresh_tasks.append(router.refresh_worker_video_support(normalized_url))
34-
35-
if refresh_tasks:
36-
37-
async def _refresh_all_worker_video_support() -> None:
38-
await asyncio.gather(*refresh_tasks)
39-
40-
asyncio.run(_refresh_all_worker_video_support())
4131

4232
print(f"{log_prefix} starting router on {args.host}:{args.port}", flush=True)
4333
print(

src/sglang_diffusion_routing/router/diffusion_router.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def _setup_routes(self) -> None:
6969
)
7070

7171
async def _start_background_health_check(self) -> None:
72+
# Probe video capability for pre-registered workers in the running event loop.
73+
unknown_workers = [
74+
url for url, support in self.worker_video_support.items() if support is None
75+
]
76+
if unknown_workers:
77+
await asyncio.gather(
78+
*(self.refresh_worker_video_support(url) for url in unknown_workers),
79+
return_exceptions=True,
80+
)
81+
7282
if self._health_task is None or self._health_task.done():
7383
self._health_task = asyncio.create_task(self._health_check_loop())
7484

@@ -383,6 +393,12 @@ async def generate(self, request: Request):
383393

384394
async def generate_video(self, request: Request):
385395
"""Route video generation to /v1/videos."""
396+
if not self.worker_request_counts:
397+
return JSONResponse(
398+
status_code=503,
399+
content={"error": "No workers registered in the pool"},
400+
)
401+
386402
candidate_workers = [
387403
worker_url
388404
for worker_url, support in self.worker_video_support.items()

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Pytest configuration: force local src import precedence."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
from pathlib import Path
7+
8+
src_str = str(Path(__file__).resolve().parent.parent / "src")
9+
while src_str in sys.path:
10+
sys.path.remove(src_str)
11+
sys.path.insert(0, src_str)

tests/e2e/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)