Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
ff625465
Unverified
Commit
ff625465
authored
Oct 07, 2025
by
KrishnanPrash
Committed by
GitHub
Oct 07, 2025
Browse files
ci: Adding Unit Tests for vLLM (--custom-jinja-template) (#3362)
parent
a5371bfc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
134 additions
and
1 deletion
+134
-1
.github/workflows/container-validation-backends.yml
.github/workflows/container-validation-backends.yml
+7
-1
tests/unit/conftest.py
tests/unit/conftest.py
+32
-0
tests/unit/test_vllm_unit.py
tests/unit/test_vllm_unit.py
+95
-0
No files found.
.github/workflows/container-validation-backends.yml
View file @
ff625465
...
@@ -77,7 +77,13 @@ jobs:
...
@@ -77,7 +77,13 @@ jobs:
azure_acr_hostname
:
${{ secrets.AZURE_ACR_HOSTNAME }}
azure_acr_hostname
:
${{ secrets.AZURE_ACR_HOSTNAME }}
azure_acr_user
:
${{ secrets.AZURE_ACR_USER }}
azure_acr_user
:
${{ secrets.AZURE_ACR_USER }}
azure_acr_password
:
${{ secrets.AZURE_ACR_PASSWORD }}
azure_acr_password
:
${{ secrets.AZURE_ACR_PASSWORD }}
-
name
:
Run tests
-
name
:
Run unit tests
if
:
${{ matrix.platform.arch != 'arm64' }}
uses
:
./.github/actions/pytest
with
:
image_tag
:
${{ steps.build-image.outputs.image_tag }}
pytest_marks
:
"
unit
and
vllm
and
gpu_1"
-
name
:
Run e2e tests
if
:
${{ matrix.platform.arch != 'arm64' }}
if
:
${{ matrix.platform.arch != 'arm64' }}
uses
:
./.github/actions/pytest
uses
:
./.github/actions/pytest
with
:
with
:
...
...
tests/unit/conftest.py
0 → 100644
View file @
ff625465
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Conftest for dynamo backend unit tests.
Handles conditional test collection to prevent import errors when backend
frameworks are not installed in the current container.
"""
import
importlib.util
def
pytest_ignore_collect
(
collection_path
,
config
):
"""Skip collecting backend test files if their framework isn't installed.
Checks test file naming pattern: test_<backend>_*.py
"""
filename
=
collection_path
.
name
# Map test file prefixes to required modules
backend_requirements
=
{
"test_vllm_"
:
"vllm"
,
"test_sglang_"
:
"sglang"
,
"test_trtllm_"
:
"tensorrt_llm"
,
}
for
prefix
,
required_module
in
backend_requirements
.
items
():
if
filename
.
startswith
(
prefix
):
if
importlib
.
util
.
find_spec
(
required_module
)
is
None
:
return
True
# Module not available, skip this file
return
None
# Not a backend test or module available
tests/unit/test_vllm_unit.py
0 → 100644
View file @
ff625465
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""Unit tests for vLLM backend components."""
import
re
import
sys
from
pathlib
import
Path
import
pytest
from
dynamo.vllm.args
import
parse_args
# Get path relative to this test file
TEST_DIR
=
Path
(
__file__
).
parent
.
parent
JINJA_TEMPLATE_PATH
=
str
(
TEST_DIR
/
"serve"
/
"fixtures"
/
"custom_template.jinja"
)
pytestmark
=
[
pytest
.
mark
.
unit
,
pytest
.
mark
.
vllm
,
pytest
.
mark
.
gpu_1
,
pytest
.
mark
.
pre_merge
,
]
def
test_custom_jinja_template_invalid_path
(
monkeypatch
):
"""Test that invalid file path raises FileNotFoundError."""
invalid_path
=
"/nonexistent/path/to/template.jinja"
monkeypatch
.
setattr
(
sys
,
"argv"
,
[
"dynamo.vllm"
,
"--model"
,
"Qwen/Qwen3-0.6B"
,
"--custom-jinja-template"
,
invalid_path
,
],
)
with
pytest
.
raises
(
FileNotFoundError
,
match
=
re
.
escape
(
f
"Custom Jinja template file not found:
{
invalid_path
}
"
),
):
parse_args
()
def
test_custom_jinja_template_valid_path
(
monkeypatch
):
"""Test that valid absolute path is stored correctly."""
monkeypatch
.
setattr
(
sys
,
"argv"
,
[
"dynamo.vllm"
,
"--model"
,
"Qwen/Qwen3-0.6B"
,
"--custom-jinja-template"
,
JINJA_TEMPLATE_PATH
,
],
)
config
=
parse_args
()
assert
config
.
custom_jinja_template
==
JINJA_TEMPLATE_PATH
,
(
f
"Expected custom_jinja_template value to be
{
JINJA_TEMPLATE_PATH
}
, "
f
"got
{
config
.
custom_jinja_template
}
"
)
def
test_custom_jinja_template_env_var_expansion
(
monkeypatch
):
"""Test that environment variables in paths are expanded by Python code."""
jinja_dir
=
str
(
TEST_DIR
/
"serve"
/
"fixtures"
)
monkeypatch
.
setenv
(
"JINJA_DIR"
,
jinja_dir
)
cli_path
=
"$JINJA_DIR/custom_template.jinja"
monkeypatch
.
setattr
(
sys
,
"argv"
,
[
"dynamo.vllm"
,
"--model"
,
"Qwen/Qwen3-0.6B"
,
"--custom-jinja-template"
,
cli_path
,
],
)
config
=
parse_args
()
assert
"$JINJA_DIR"
not
in
config
.
custom_jinja_template
assert
config
.
custom_jinja_template
==
JINJA_TEMPLATE_PATH
,
(
f
"Expected custom_jinja_template value to be
{
JINJA_TEMPLATE_PATH
}
, "
f
"got
{
config
.
custom_jinja_template
}
"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment