Skip to content

Commit 0c2eefb

Browse files
committed
a
1 parent c31c41f commit 0c2eefb

File tree

3 files changed

+121
-0
lines changed

3 files changed

+121
-0
lines changed

.github/workflows/test.yaml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
name: Test Suite
4+
on: push
5+
6+
jobs:
7+
unit-tests:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Checkout repository
11+
uses: actions/checkout@v4
12+
- name: Install uv
13+
uses: astral-sh/setup-uv@v6
14+
with:
15+
python-version: 3.10
16+
activate-environment: true
17+
- name: Install dependencies
18+
run: uv pip install ".[dev]"
19+
- name: Run unit tests
20+
run: pytest tests --ignore=tests/integration -v
21+
22+
integration-tests:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
- name: Install uv
28+
uses: astral-sh/setup-uv@v6
29+
with:
30+
python-version: 3.10
31+
activate-environment: true
32+
- name: Install dependencies
33+
run: |
34+
uv pip install ".[dev]"
35+
uv pip install "./integration-tests[dev]"
36+
- name: Run integration tests
37+
run: pytest tests/integration -v

tests/integration/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
import pytest
5+
import requests
6+
import time
7+
import subprocess
8+
from pathlib import Path
9+
10+
11+
class TestAIPerfMockServerIntegration:
12+
@pytest.fixture(scope="class")
13+
def test_server(self):
14+
"""Start a test LLM inference server for integration testing"""
15+
# Start test server (e.g., vLLM, Triton, etc.)
16+
server_process = subprocess.Popen(
17+
[
18+
"aiperf-mock-server",
19+
"-m",
20+
"Qwen/Qwen3-0.6B",
21+
"-p",
22+
"8080",
23+
]
24+
)
25+
26+
# Wait for server to be ready
27+
self._wait_for_server_ready("http://127.0.0.1:8080")
28+
29+
yield "http://127.0.0.1:8080"
30+
31+
# Cleanup
32+
server_process.terminate()
33+
server_process.wait()
34+
35+
def _wait_for_server_ready(self, url, timeout=60):
36+
"""Wait for server to become ready"""
37+
start_time = time.time()
38+
while time.time() - start_time < timeout:
39+
try:
40+
response = requests.get(f"{url}/health", timeout=5)
41+
if response.status_code == 200:
42+
return
43+
except requests.exceptions.RequestException:
44+
pass
45+
time.sleep(2)
46+
raise RuntimeError("Server failed to start within timeout")
47+
48+
def test_basic_performance_analysis(self, test_server):
49+
"""Test basic throughput and latency measurement"""
50+
# Run your CLI tool against the test server
51+
result = subprocess.run(
52+
[
53+
"aiperf",
54+
"profile",
55+
"--model-names",
56+
"Qwen/Qwen3-0.6B",
57+
"--concurrency",
58+
"1",
59+
"--request-count",
60+
"1",
61+
],
62+
capture_output=True,
63+
text=True,
64+
)
65+
66+
assert result.returncode == 0, f"aiperf failed: {result.stderr}"
67+
68+
# Parse and validate output
69+
import json
70+
71+
output = json.loads(result.stdout)
72+
73+
# Verify key metrics are present
74+
assert "ttft_avg" in output
75+
assert "tpot_avg" in output
76+
assert "throughput_tokens_per_sec" in output
77+
assert "request_throughput" in output
78+
79+
# Verify metrics are reasonable
80+
assert output["ttft_avg"] > 0
81+
assert output["tpot_avg"] > 0
82+
assert output["throughput_tokens_per_sec"] > 0

0 commit comments

Comments
 (0)