Skip to content
Merged
Show file tree
Hide file tree
Changes from 40 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f1feaba
Adding test directory and e2e tests to Dynamo
pvijayakrish May 21, 2025
70c6628
Add Licences to all files
pvijayakrish May 21, 2025
529a25d
updated locally
nnshah1 May 28, 2025
6215a73
Merge branch 'main' into neelays/tests
nnshah1 May 28, 2025
4423f1a
incremental
nnshah1 May 30, 2025
b8af868
Merge branch 'main' into neelays/tests
nnshah1 May 30, 2025
6bd155d
updating incremental
nnshah1 Jun 2, 2025
1317900
updated - incremental
nnshah1 Jun 2, 2025
3934ca3
updated
nnshah1 Jun 3, 2025
aa02e2b
removing for testing only serve
nnshah1 Jun 3, 2025
ae4faec
tests
nnshah1 Jun 3, 2025
f4b7d93
missing file
nnshah1 Jun 3, 2025
716d35e
increasing timeout
nnshah1 Jun 3, 2025
0d337b8
updating test time 15 min
nnshah1 Jun 3, 2025
6833988
cleaning up
nnshah1 Jun 3, 2025
61d99ae
updated
nnshah1 Jun 3, 2025
38b782b
updated for mypy
nnshah1 Jun 3, 2025
6d9ae43
updating with pre-commit
nnshah1 Jun 3, 2025
07c821e
updated
nnshah1 Jun 3, 2025
d128f2a
updated
nnshah1 Jun 4, 2025
fd1281b
updated
nnshah1 Jun 4, 2025
3be2584
updaTed
nnshah1 Jun 4, 2025
d1235e1
updated
nnshah1 Jun 4, 2025
2d5c3a7
updates
nnshah1 Jun 4, 2025
d01e4c7
updated
nnshah1 Jun 4, 2025
c296f28
updates
nnshah1 Jun 4, 2025
b378d75
updates
nnshah1 Jun 4, 2025
a7a139d
updated
nnshah1 Jun 4, 2025
48d77b0
updated
nnshah1 Jun 4, 2025
b44884f
changing name back - will add comment
nnshah1 Jun 4, 2025
33ef224
updates
nnshah1 Jun 4, 2025
ec7379e
adding failure case
nnshah1 Jun 4, 2025
3d8b8ac
updated
nnshah1 Jun 4, 2025
35010a0
updates
nnshah1 Jun 4, 2025
47feef9
updated
nnshah1 Jun 4, 2025
702c713
updated
nnshah1 Jun 4, 2025
b5db16f
updated based on ai feedback
nnshah1 Jun 5, 2025
2358c7d
updates
nnshah1 Jun 5, 2025
b9ce178
Update tests/utils/managed_process.py
nnshah1 Jun 5, 2025
a0a4307
Update tests/utils/managed_process.py
nnshah1 Jun 5, 2025
e40ff81
tweaking elapsed logic
nnshah1 Jun 5, 2025
708afd0
Merge branch 'neelays/tests' of https://github.com/ai-dynamo/dynamo i…
nnshah1 Jun 5, 2025
1d0cf46
updated
nnshah1 Jun 5, 2025
b3823c2
fixes basd on feedback
nnshah1 Jun 5, 2025
b9ea317
mypy updates
nnshah1 Jun 5, 2025
ba5f400
updating from feedback
nnshah1 Jun 5, 2025
c87b950
update from feedback
nnshah1 Jun 5, 2025
1a16830
reverting change
nnshah1 Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions container/deps/requirements.test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

psutil>=5.0.0
pyright
pytest
pytest-asyncio
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,16 @@ markers = [
"pre_merge: marks tests to run before merging",
"nightly: marks tests to run nightly",
"weekly: marks tests to run weekly",
"gpu: marks tests to run on GPU"
"gpu_1: marks tests to run on GPU",
"gpu_2: marks tests to run on 2GPUs",
"e2e: marks tests as end-to-end tests",
"integration: marks tests as integration tests",
"unit: marks tests as unit tests",
"stress: marks tests as stress tests",
"vllm: marks tests as requiring vllm",
"tensorrtllm: marks tests as requiring tensorrtllm",
"sglang: marks tests as requiring sglang",
"slow: marks tests as known to be slow"
]

# Linting/formatting
Expand Down
98 changes: 98 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# Dynamo Testing Framework

## Overview

This document outlines the testing framework for the Dynamo runtime system, including test discovery, organization, and best practices.

## Directory Structure

```bash
tests/
├── serve/ # E2E tests using dynamo serve
│ ├── conftest.py # test fixtures as needed for specific test area
├── run/ # E2E tests using dynamo run
│ ├── conftest.py # test fixtures as needed for specific test area
├── conftest.py # Shared fixtures and configuration
└── README.md # This file
```

## Test Discovery

Pytest automatically discovers tests based on their naming convention. All test files must follow this pattern:

```bash
test_<component_or_flow>.py
```

Where:
- `component_or_flow`: The component or flow being tested (e.g., planner, kv_router)
- For e2e tests, this could be the API or simply "dynamo"

## Running Tests

To run all tests:
```bash
pytest
```

To run only specific tests:
```bash
# Run only vLLM tests
pytest -v -m vllm

# Run only e2e tests
pytest -v -m e2e

# Run tests for a specific component
pytest -v -m planner

# Run with print statements visible
pytest -s
```

## Test Markers

Markers help control which tests run under different conditions. Add these decorators to your test functions:

### Frequency-based markers
- `@pytest.mark.nightly` - Tests run nightly
- `@pytest.mark.weekly` - Tests run weekly
- `@pytest.mark.pre_merge` - Tests run before merging PRs

### Role-based markers
- `@pytest.mark.e2e` - End-to-end tests
- `@pytest.mark.integration` - Integration tests
- `@pytest.mark.unit` - Unit tests
- `@pytest.mark.stress` - Stress/load tests
- `@pytest.mark.benchmark` - Performance benchmark tests

### Component-specific markers
- `@pytest.mark.vllm` - Framework tests
- `@pytest.mark.sglang` - Framework tests
- `@pytest.mark.tensorrtllm` - Framework tests
- `@pytest.mark.planner` - Planner component tests
- `@pytest.mark.kv_router` - KV Router component tests
- etc.

### Execution-related markers
- `@pytest.mark.slow` - Tests that take a long time to run
- `@pytest.mark.skip(reason="Example: KV Manager is under development")` - Skip these tests
- `@pytest.mark.xfail(reason="Expected to fail because...")` - Tests expected to fail

## Environment Setup

Tests are designed to run in the appropriate framework container built
via ```./container/build.sh --framework X``` and run via
```./container/run.sh --mount-workspace -it -- pytest```.


### Environment Variables
- `HF_TOKEN` - Your HuggingFace API token to avoid rate limits
- Get a token from https://huggingface.co/settings/tokens
- Set it before running tests: `export HF_TOKEN=your_token_here`

### Model Download Cache

The tests will automatically use a local cache at `~/.cache/huggingface` to avoid
repeated downloads of model files. This cache is shared across test runs to improve performance.

14 changes: 14 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
76 changes: 76 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import logging
import os

import pytest

from tests.utils.managed_process import ManagedProcess

# Custom format inspired by your example
LOG_FORMAT = "[TEST] %(asctime)s %(levelname)s %(name)s: %(message)s"

# Configure logging
logging.basicConfig(
level=logging.INFO,
format=LOG_FORMAT,
datefmt="%Y-%m-%dT%H:%M:%S", # ISO 8601 UTC format with microseconds
)


class EtcdServer(ManagedProcess):
def __init__(self, request, port=2379, timeout=300):
port_string = str(port)
etcd_env = os.environ.copy()
etcd_env["ALLOW_NONE_AUTHENTICATION"] = "yes"
command = [
"etcd",
"--listen-client-urls",
f"http://0.0.0.0:{port_string}",
"--advertise-client-urls",
f"http://0.0.0.0:{port_string}",
"--data-dir",
"/tmp/etcd-test-data",
]
super().__init__(
command=command,
timeout=timeout,
display_output=False,
health_check_ports=[port],
data_dir="/tmp/etcd-test-data",
log_dir=request.node.name,
)


class NatsServer(ManagedProcess):
def __init__(self, request, port=4222, timeout=300):
data_dir = "/tmp/nats/jetstream"
command = ["nats-server", "-js", "--trace", "--store_dir", data_dir]
super().__init__(
command=command,
timeout=timeout,
display_output=False,
data_dir=data_dir,
health_check_ports=[port],
log_dir=request.node.name,
)


@pytest.fixture()
def runtime_services(request):
with NatsServer(request) as nats_process:
with EtcdServer(request) as etcd_process:
yield nats_process, etcd_process
14 changes: 14 additions & 0 deletions tests/serve/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
14 changes: 14 additions & 0 deletions tests/serve/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
Loading
Loading