Skip to content

Commit 3bd986b

Browse files
committed
Fix e2e tests writing output to test dir
Signed-off-by: Samuel Monson <[email protected]>
1 parent 800bec6 commit 3bd986b

File tree

4 files changed

+51
-20
lines changed

4 files changed

+51
-20
lines changed

tests/e2e/test_max_error_benchmark.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,21 @@ def server():
3535

3636

3737
@pytest.mark.timeout(30)
38-
def test_max_error_benchmark(server: VllmSimServer):
38+
def test_max_error_benchmark(server: VllmSimServer, tmp_path: Path):
3939
"""
4040
Test that the max error rate constraint is properly triggered when server goes down.
4141
"""
42-
report_path = Path("tests/e2e/max_error_benchmarks.json")
42+
report_name = "max_error_benchmarks.json"
43+
report_path = tmp_path / report_name
4344
rate = 10
4445
max_error_rate = 0.1
4546

4647
# Create and configure the guidellm client
47-
client = GuidellmClient(target=server.get_url(), output_path=report_path)
48+
client = GuidellmClient(
49+
target=server.get_url(),
50+
output_dir=tmp_path,
51+
outputs=report_name,
52+
)
4853

4954
try:
5055
# Start the benchmark

tests/e2e/test_over_saturated_benchmark.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,20 @@ def server():
3434

3535

3636
@pytest.mark.timeout(60)
37-
def test_over_saturated_benchmark(server: VllmSimServer):
37+
def test_over_saturated_benchmark(server: VllmSimServer, tmp_path: Path):
3838
"""
3939
Test over-saturation detection using the --default-over-saturation flag.
4040
"""
41-
report_path = Path("tests/e2e/over_saturated_benchmarks.json")
41+
report_name = "over_saturated_benchmarks.json"
42+
report_path = tmp_path / report_name
4243
rate = 10
4344

4445
# Create and configure the guidellm client
45-
client = GuidellmClient(target=server.get_url(), output_path=report_path)
46+
client = GuidellmClient(
47+
target=server.get_url(),
48+
output_dir=tmp_path,
49+
outputs=report_name,
50+
)
4651

4752
cleanup_report_file(report_path)
4853
# Start the benchmark with --default-over-saturation flag
@@ -74,15 +79,22 @@ def test_over_saturated_benchmark(server: VllmSimServer):
7479

7580

7681
@pytest.mark.timeout(60)
77-
def test_over_saturated_benchmark_with_dict_config(server: VllmSimServer):
82+
def test_over_saturated_benchmark_with_dict_config(
83+
server: VllmSimServer, tmp_path: Path
84+
):
7885
"""
7986
Test over-saturation detection with dictionary configuration instead of boolean.
8087
"""
81-
report_path = Path("tests/e2e/over_saturated_benchmarks_dict.json")
88+
report_name = "over_saturated_benchmarks_dict.json"
89+
report_path = tmp_path / report_name
8290
rate = 10
8391

8492
# Create and configure the guidellm client
85-
client = GuidellmClient(target=server.get_url(), output_path=report_path)
93+
client = GuidellmClient(
94+
target=server.get_url(),
95+
output_dir=tmp_path,
96+
outputs=report_name,
97+
)
8698

8799
cleanup_report_file(report_path)
88100
# Start the benchmark with dictionary configuration for over-saturation

tests/e2e/test_successful_benchmark.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ def server():
3737

3838
@pytest.mark.timeout(30)
3939
@pytest.mark.sanity
40-
def test_max_seconds_benchmark(server: VllmSimServer):
40+
def test_max_seconds_benchmark(server: VllmSimServer, tmp_path: Path):
4141
"""
4242
Test that the max seconds constraint is properly triggered.
4343
"""
44-
report_path = Path("tests/e2e/max_duration_benchmarks.json")
44+
report_name = "max_duration_benchmarks.json"
45+
report_path = tmp_path / report_name
4546
rate = 4
4647
duration = 5
4748
max_seconds = duration
4849
# Create and configure the guidellm client
49-
client = GuidellmClient(target=server.get_url(), output_path=report_path)
50+
client = GuidellmClient(
51+
target=server.get_url(),
52+
output_dir=tmp_path,
53+
outputs=report_name,
54+
)
5055

5156
try:
5257
# Start the benchmark
@@ -80,17 +85,22 @@ def test_max_seconds_benchmark(server: VllmSimServer):
8085

8186
@pytest.mark.timeout(30)
8287
@pytest.mark.sanity
83-
def test_max_requests_benchmark(server: VllmSimServer):
88+
def test_max_requests_benchmark(server: VllmSimServer, tmp_path: Path):
8489
"""
8590
Test that the max requests constraint is properly triggered.
8691
"""
87-
report_path = Path("tests/e2e/max_number_benchmarks.json")
92+
report_name = "max_number_benchmarks.json"
93+
report_path = tmp_path / report_name
8894
rate = 4
8995
duration = 5
9096
max_requests = rate * duration
9197

9298
# Create and configure the guidellm client
93-
client = GuidellmClient(target=server.get_url(), output_path=report_path)
99+
client = GuidellmClient(
100+
target=server.get_url(),
101+
output_dir=tmp_path,
102+
outputs=report_name,
103+
)
94104

95105
try:
96106
# Start the benchmark

tests/e2e/utils.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@ def get_guidellm_executable() -> str:
2626
class GuidellmClient:
2727
"""Wrapper class for running guidellm benchmark commands."""
2828

29-
def __init__(self, target: str, output_path: Path):
29+
def __init__(
30+
self, target: str, output_dir: Path, outputs: str = "benchmarks.json"
31+
) -> None:
3032
"""
3133
Initialize the guidellm client.
3234
3335
:param target: The target URL for the benchmark
3436
:param output_path: Path where the benchmark report will be saved
3537
"""
3638
self.target = target
37-
self.output_path = output_path
39+
self.output_dir = output_dir
40+
self.outputs = outputs
3841
self.process: subprocess.Popen | None = None
3942
self.stdout: str | None = None
4043
self.stderr: str | None = None
@@ -72,7 +75,7 @@ def start_benchmark(
7275
# Build command components
7376
cmd_parts = [
7477
*([f"{k}={v}" for k, v in extra_env.items()] if extra_env else []),
75-
"HF_HOME=/tmp/huggingface_cache",
78+
"HF_HOME=" + str(self.output_dir / "huggingface_cache"),
7679
f"{guidellm_exe} benchmark run",
7780
f'--target "{self.target}"',
7881
f"--profile {profile}",
@@ -108,7 +111,8 @@ def start_benchmark(
108111
[
109112
f'--data "{data}"',
110113
f'--processor "{processor}"',
111-
f"--output-path {self.output_path}",
114+
f"--output-dir {self.output_dir}",
115+
f"--outputs {self.outputs}",
112116
]
113117
)
114118

@@ -120,7 +124,7 @@ def start_benchmark(
120124
logger.info(f"Client command: {command}")
121125

122126
self.process = subprocess.Popen( # noqa: S603
123-
["/bin/bash", "-c", command],
127+
["/bin/sh", "-c", command],
124128
stdout=subprocess.PIPE,
125129
stderr=subprocess.PIPE,
126130
text=True,

0 commit comments

Comments
 (0)