Skip to content
10 changes: 10 additions & 0 deletions .github/workflows/e2e-gpu-job.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ jobs:
env:
SHOW_WORKER_LOGS: "0"
SHOW_ROUTER_LOGS: "1"
E2E_LOG_DIR: e2e-logs
BRAVE_MCP_HOST: ${{ inputs.setup_agentic_deps && 'brave-search-mcp' || '' }}
run: |
bash scripts/ci_killall_sglang.sh "nuk_gpus"
Expand All @@ -126,6 +127,15 @@ jobs:
--reruns 2 --reruns-delay 5 \
-s -vv

- name: Upload worker logs
if: failure() || cancelled()
uses: actions/upload-artifact@v4
with:
name: e2e-worker-logs-${{ inputs.engine }}-gpu${{ inputs.gpu_tier }}-${{ inputs.test_dirs }}
path: e2e-logs/
retention-days: 7
if-no-files-found: ignore
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

- name: Cleanup Oracle test users
if: always() && inputs.setup_agentic_deps
run: |
Expand Down
38 changes: 38 additions & 0 deletions e2e_test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from __future__ import annotations

import logging
import os
import sys
from importlib.util import find_spec
from pathlib import Path
Expand Down Expand Up @@ -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())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Order failure log summary by modification time

The new pytest_runtest_makereport hook claims to show the “most recent” worker logs, but it sorts by filename (sorted(p.name ...)) and then takes logs[-5:]. Filename order is not chronological (it is dominated by model/engine/port), so when multiple log files exist this summary can hide the logs from the actual failing run and surface stale ones instead, weakening the diagnostics this change is meant to provide.

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):
Expand Down Expand Up @@ -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",
Expand Down
77 changes: 52 additions & 25 deletions e2e_test/fixtures/setup_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Reset startup-failure budget after successful worker boot

setup_backend now hard-fails once _worker_start_failures[(model_id, engine)] >= 3, but this counter is only incremented in exception paths and never reset after a successful startup. That makes the budget cumulative for the whole test session, so three intermittent startup flakes (even if separated by many successful classes) permanently force later classes for the same model/engine to fail immediately, which can mask real test outcomes and materially reduce E2E coverage.

Useful? React with 👍 / 👎.


gateway = Gateway()
try:
Expand Down Expand Up @@ -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
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
try:
_start_gateway(
gateway,
Expand Down Expand Up @@ -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(
Expand Down
17 changes: 8 additions & 9 deletions e2e_test/infra/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def _build_vllm_base_cmd(
"--max-model-len",
"16384",
"--gpu-memory-utilization",
"0.9",
"1.1", # TEMP: intentionally invalid to test log artifact upload
Comment thread
CatherineSue marked this conversation as resolved.
Resolved
Comment thread
CatherineSue marked this conversation as resolved.
Resolved
Comment thread
CatherineSue marked this conversation as resolved.
Resolved
Comment thread
CatherineSue marked this conversation as resolved.
Resolved
Comment thread
CatherineSue marked this conversation as resolved.
Resolved
]
extra = spec.get("vllm_args", [])
if extra:
Expand Down Expand Up @@ -315,18 +315,17 @@ def _spawn_process(self, cmd: list[str], env: dict[str, str]) -> subprocess.Pope
stderr_target: int | IO[Any] | None = None

if not show_output:
safe_name = f"{self.model_id}_{self.engine}_{self.mode.value}_{self.port}".replace(
"/", "__"
).replace(":", "_")
if self.log_dir:
os.makedirs(self.log_dir, exist_ok=True)
safe_name = f"{self.model_id}_{self.engine}_{self.mode.value}_{self.port}".replace(
"/", "__"
).replace(":", "_")
log_path = os.path.join(self.log_dir, f"worker-{safe_name}.log")
self._log_file = open(log_path, "w", encoding="utf-8")
stdout_target = self._log_file
stderr_target = subprocess.STDOUT
else:
stdout_target = subprocess.DEVNULL
stderr_target = subprocess.DEVNULL
log_path = os.path.join(tempfile.gettempdir(), f"smg-worker-{safe_name}.log")
self._log_file = open(log_path, "w", encoding="utf-8")
Comment thread
key4ng marked this conversation as resolved.
Resolved
stdout_target = self._log_file
stderr_target = subprocess.STDOUT

try:
return subprocess.Popen(
Expand Down
Loading