Repository navigation
ci(e2e): upload worker logs as artifacts on test failure #963
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
50eb577
0dc1ca2
77d3398
c23151e
2068aa7
66ae9e4
f5d54f9
0cf1dd7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,7 @@ | |
| from __future__ import annotations | ||
|
|
||
| import logging | ||
| import os | ||
| import sys | ||
| from importlib.util import find_spec | ||
| from pathlib import Path | ||
|
|
@@ -112,6 +113,42 @@ def pytest_runtest_logstart(nodeid: str, location: tuple) -> None: | |
| ) | ||
| from smg_client import SmgClient | ||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Failure diagnostics | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| @pytest.hookimpl(hookwrapper=True) | ||
| def pytest_runtest_makereport(item, call): | ||
| """Print worker log summary on test failure.""" | ||
| from infra import LOG_SEPARATOR_WIDTH | ||
|
|
||
| outcome = yield | ||
| report = outcome.get_result() | ||
|
|
||
| if not report.failed: | ||
| return | ||
|
|
||
| log_dir = os.environ.get("E2E_LOG_DIR") | ||
| if not log_dir or not Path(log_dir).is_dir(): | ||
| return | ||
|
|
||
| logs = sorted(p.name for p in Path(log_dir).glob("*.log") if p.is_file()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new Useful? React with 👍 / 👎. |
||
| if logs: | ||
| print(f"\n{'!' * LOG_SEPARATOR_WIDTH}") | ||
| print(f"Worker logs available in CI artifacts ({len(logs)} files)") | ||
| # Show only the most recent logs to avoid flooding the console | ||
| for f in logs[-5:]: | ||
| print(f" {f}") | ||
| if len(logs) > 5: | ||
| print(f" ... and {len(logs) - 5} more") | ||
| print(f"{'!' * LOG_SEPARATOR_WIDTH}") | ||
|
|
||
|
|
||
| # --------------------------------------------------------------------------- | ||
| # Fixtures | ||
| # --------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def model(setup_backend): | ||
|
|
@@ -144,6 +181,7 @@ def api_client(request, setup_backend): | |
| __all__ = [ | ||
| # Hooks | ||
| "pytest_runtest_logstart", | ||
| "pytest_runtest_makereport", | ||
| "pytest_runtest_setup", | ||
| "pytest_collection_modifyitems", | ||
| "pytest_configure", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,10 @@ | |
|
|
||
| _WORKER_DEFAULTS = {"count": 1, "prefill": None, "decode": None} | ||
|
|
||
| # Track worker startup failures — fail fast after repeated failures for same model/engine | ||
| _worker_start_failures: dict[tuple[str, str], int] = {} # (model_id, engine) -> count | ||
| _MAX_WORKER_START_FAILURES = 3 # fail fast after this many failures (matches --reruns 2) | ||
|
|
||
|
|
||
| def _start_gateway(gateway: Gateway, gateway_config: dict, **mode_kwargs) -> None: | ||
| """Start gateway with mode-specific kwargs and shared config.""" | ||
|
|
@@ -106,7 +110,12 @@ def setup_backend(request: pytest.FixtureRequest): | |
| engine = get_runtime() | ||
| model_path = get_model_spec(model_id)["model"] | ||
| workers_config = get_marker_kwargs(request, "workers", defaults=_WORKER_DEFAULTS) | ||
| log_dir = gateway_config.get("log_dir") | ||
| log_dir = os.environ.get("E2E_LOG_DIR") or gateway_config.get("log_dir") | ||
|
|
||
| worker_key = (model_id, engine) | ||
| fail_count = _worker_start_failures.get(worker_key, 0) | ||
| if fail_count >= _MAX_WORKER_START_FAILURES: | ||
| pytest.fail(f"Worker {model_id}/{engine} failed to start {fail_count} times — giving up") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
|
|
||
| gateway = Gateway() | ||
| try: | ||
|
|
@@ -158,13 +167,19 @@ def _setup_local( | |
| num_workers = workers_config.get("count") or 1 | ||
| logger.info("Starting %s backend: model=%s, workers=%d", backend_name, model_id, num_workers) | ||
|
|
||
| workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_workers, | ||
| log_dir=log_dir, | ||
| ) | ||
| try: | ||
| workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_workers, | ||
| log_dir=log_dir, | ||
| ) | ||
| except (TimeoutError, RuntimeError): | ||
| _worker_start_failures[(model_id, engine)] = ( | ||
| _worker_start_failures.get((model_id, engine), 0) + 1 | ||
| ) | ||
| raise | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| try: | ||
| _start_gateway( | ||
| gateway, | ||
|
|
@@ -212,27 +227,39 @@ def _setup_pd( | |
|
|
||
| all_workers: list = [] | ||
| try: | ||
| prefill_workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_prefill, | ||
| worker_type=WorkerType.PREFILL, | ||
| log_dir=log_dir, | ||
| ) | ||
| try: | ||
| prefill_workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_prefill, | ||
| worker_type=WorkerType.PREFILL, | ||
| log_dir=log_dir, | ||
| ) | ||
| except (TimeoutError, RuntimeError): | ||
| _worker_start_failures[(model_id, engine)] = ( | ||
| _worker_start_failures.get((model_id, engine), 0) + 1 | ||
| ) | ||
| raise | ||
| all_workers.extend(prefill_workers) | ||
|
|
||
| # Decode workers start on GPUs after prefill workers | ||
| decode_gpu_offset = num_prefill * spec.get("tp", 1) | ||
| decode_workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_decode, | ||
| worker_type=WorkerType.DECODE, | ||
| log_dir=log_dir, | ||
| gpu_offset=decode_gpu_offset, | ||
| ) | ||
| try: | ||
| decode_workers = start_workers( | ||
| model_id, | ||
| engine=engine, | ||
| mode=connection_mode, | ||
| count=num_decode, | ||
| worker_type=WorkerType.DECODE, | ||
| log_dir=log_dir, | ||
| gpu_offset=decode_gpu_offset, | ||
| ) | ||
| except (TimeoutError, RuntimeError): | ||
| _worker_start_failures[(model_id, engine)] = ( | ||
| _worker_start_failures.get((model_id, engine), 0) + 1 | ||
| ) | ||
| raise | ||
| all_workers.extend(decode_workers) | ||
|
|
||
| _start_gateway( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.