diff --git a/.github/workflows/nightly-ci.yml b/.github/workflows/nightly-ci.yml index b802f577b0be..ba4d21589648 100644 --- a/.github/workflows/nightly-ci.yml +++ b/.github/workflows/nightly-ci.yml @@ -601,7 +601,7 @@ jobs: uses: $/.github/workflows/shared-deploy-test.yml with: framework: sglang - profiles: '["agg"]' + profiles: '["agg", "agg_logging"]' image_tag: ${{ needs.sglang-copy-to-acr.outputs.image_tag }} namespace: ${{ needs.deploy-operator.outputs.namespace }} vcluster_name: ${{ needs.deploy-operator.outputs.vcluster_name }} diff --git a/.github/workflows/post-merge-ci.yml b/.github/workflows/post-merge-ci.yml index 6c8b7f6032cd..6a1cc72dbe2d 100644 --- a/.github/workflows/post-merge-ci.yml +++ b/.github/workflows/post-merge-ci.yml @@ -912,7 +912,7 @@ jobs: uses: $/.github/workflows/shared-deploy-test.yml with: framework: sglang - profiles: '["agg", "agg_router"]' + profiles: '["agg", "agg_logging", "agg_router"]' image_tag: ${{ needs.sglang-copy-to-acr.outputs.image_tag }} namespace: ${{ needs.deploy-operator.outputs.namespace }} vcluster_name: ${{ needs.deploy-operator.outputs.vcluster_name }} diff --git a/tests/deploy/dgd_utils.py b/tests/deploy/dgd_utils.py index 657de83db903..c87ca7487d21 100644 --- a/tests/deploy/dgd_utils.py +++ b/tests/deploy/dgd_utils.py @@ -658,7 +658,8 @@ def get_logging_config(self) -> dict: Returns: dict with 'jsonl_enabled' and 'log_level' keys """ - envs = self._deployment_spec.get("spec", {}).get("envs", []) + env_key = "env" if self._schema == SCHEMA_V1BETA1 else "envs" + envs = self._deployment_spec.get("spec", {}).get(env_key, []) jsonl_enabled = False log_level = None diff --git a/tests/deploy/test_dgd.py b/tests/deploy/test_dgd.py index 07cb60574dd0..68bae6ebd7ef 100644 --- a/tests/deploy/test_dgd.py +++ b/tests/deploy/test_dgd.py @@ -9,10 +9,12 @@ """ import asyncio +import json import logging import os import subprocess import time +from typing import Any import kr8s import pytest @@ -36,11 +38,58 @@ logger = logging.getLogger(__name__) GAIE_MODEL_NAME = "Qwen/Qwen3-0.6B" +JSON_LOG_REQUIRED_FIELDS = frozenset({"time", "level", "target", "message"}) # The install script deploys the Gateway into agentgateway-system; the # controller provisions the proxy Service in that same namespace. GAIE_AGW_NAMESPACE = "agentgateway-system" +def normalize_log_lines(log_lines: Any) -> list[str]: + """Return pod logs as a reusable list of lines.""" + if isinstance(log_lines, str): + return log_lines.splitlines() + return list(log_lines) + + +def find_structured_json_log(log_lines: list[str]) -> dict[str, Any] | None: + """Return the first Dynamo JSONL record with the documented core fields.""" + for line in log_lines: + try: + record = json.loads(line) + except (json.JSONDecodeError, TypeError): + continue + + if isinstance(record, dict) and JSON_LOG_REQUIRED_FIELDS.issubset(record): + return record + + return None + + +def validate_agg_logging_configuration(deployment_spec: DeploymentSpec) -> None: + """Verify that the logging profile enables structured JSONL output.""" + logging_config = deployment_spec.get_logging_config() + if not logging_config["jsonl_enabled"]: + pytest.fail("The agg_logging deployment profile must enable DYN_LOGGING_JSONL") + + +def validate_agg_logging_output(frontend_pod: Any, baseline_line_count: int) -> None: + """Verify that inference emitted a new structured frontend log record.""" + frontend_log_lines = normalize_log_lines(frontend_pod.logs(container="main")) + new_log_lines = frontend_log_lines[baseline_line_count:] + json_log_record = find_structured_json_log(new_log_lines) + if json_log_record is None: + pytest.fail( + "The agg_logging deployment served inference but the frontend " + "did not emit a new structured Dynamo JSONL record" + ) + + logger.info( + "Validated structured JSON logging: target=%s message=%s", + json_log_record["target"], + json_log_record["message"], + ) + + @pytest.mark.framework_only @pytest.mark.k8s @pytest.mark.deploy @@ -75,6 +124,7 @@ async def test_deployment( # Extract identifying information from the target framework = deployment_target.framework profile = deployment_target.profile + validate_agg_logging = profile == "agg_logging" # NIXL_ERR_BACKEND: vCluster CI nodes lack RDMA/UCX for inter-pod KV # transfer. Prefill workers crash in NixlWrapper.create_backend. @@ -99,6 +149,9 @@ async def test_deployment( f"{framework}/{profile}" ) + if validate_agg_logging: + validate_agg_logging_configuration(deployment_spec) + logger.info( f"Starting deployment test for {deployment_target.test_id} " f"(source: {deployment_target.source}, model: {model}, namespace: {namespace})" @@ -156,6 +209,11 @@ async def test_deployment( "temperature": DEFAULT_TEMPERATURE, "stream": False, } + frontend_log_baseline = ( + len(normalize_log_lines(frontend_pod.logs(container="main"))) + if validate_agg_logging + else 0 + ) response = send_request( url, payload, timeout=float(DEFAULT_REQUEST_TIMEOUT), method="POST" ) @@ -167,6 +225,9 @@ async def test_deployment( min_content_length=MIN_RESPONSE_CONTENT_LENGTH, ) + if validate_agg_logging: + validate_agg_logging_output(frontend_pod, frontend_log_baseline) + logger.info( f"Deployment test PASSED for {deployment_target.test_id} " f"(source: {deployment_target.source}, model: {model}, namespace: {namespace})" diff --git a/tests/deploy/test_dgd_utils.py b/tests/deploy/test_dgd_utils.py new file mode 100644 index 000000000000..ef1d0179df27 --- /dev/null +++ b/tests/deploy/test_dgd_utils.py @@ -0,0 +1,30 @@ +# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Unit tests for schema-aware DynamoGraphDeployment helpers.""" + +import pytest +import yaml + +from tests.deploy.dgd_utils import DeploymentSpec + +pytestmark = [pytest.mark.unit, pytest.mark.pre_merge, pytest.mark.gpu_0] + + +def test_logging_config_reads_existing_v1beta1_env(tmp_path) -> None: + """Recognize JSONL logging already declared in a v1beta1 manifest.""" + manifest = { + "apiVersion": "nvidia.com/v1beta1", + "kind": "DynamoGraphDeployment", + "metadata": {"name": "logging-test"}, + "spec": { + "components": [], + "env": [{"name": "DYN_LOGGING_JSONL", "value": "1"}], + }, + } + manifest_path = tmp_path / "deploy.yaml" + manifest_path.write_text(yaml.safe_dump(manifest)) + + deployment_spec = DeploymentSpec(str(manifest_path)) + + assert deployment_spec.get_logging_config()["jsonl_enabled"] is True