Skip to content

Commit 316d955

Browse files
committed
test(ab): generalize --test to --pytest-opts
Allow passing arbitrary pytest options through to the ab-testing script, so that things like `-k` can be used for test selection. Signed-off-by: Patrick Roy <[email protected]>
1 parent fcb39a6 commit 316d955

File tree

2 files changed

+23
-20
lines changed

2 files changed

+23
-20
lines changed

.buildkite/pipeline_perf.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,41 +18,41 @@
1818
perf_test = {
1919
"virtio-block": {
2020
"label": "💿 Virtio Block Performance",
21-
"test_path": "integration_tests/performance/test_block_ab.py::test_block_performance",
21+
"tests": "integration_tests/performance/test_block_ab.py::test_block_performance",
2222
"devtool_opts": "-c 1-10 -m 0",
2323
},
2424
"vhost-user-block": {
2525
"label": "💿 vhost-user Block Performance",
26-
"test_path": "integration_tests/performance/test_block_ab.py::test_block_vhost_user_performance",
26+
"tests": "integration_tests/performance/test_block_ab.py::test_block_vhost_user_performance",
2727
"devtool_opts": "-c 1-10 -m 0",
2828
"ab_opts": "--noise-threshold 0.1",
2929
},
3030
"network": {
3131
"label": "📠 Network Latency and Throughput",
32-
"test_path": "integration_tests/performance/test_network_ab.py",
32+
"tests": "integration_tests/performance/test_network_ab.py",
3333
"devtool_opts": "-c 1-10 -m 0",
3434
# Triggers if delta is > 0.01ms (10µs) or default relative threshold (5%)
3535
# only relevant for latency test, throughput test will always be magnitudes above this anyway
3636
"ab_opts": "--absolute-strength 0.010",
3737
},
3838
"snapshot-latency": {
3939
"label": "📸 Snapshot Latency",
40-
"test_path": "integration_tests/performance/test_snapshot_ab.py::test_restore_latency integration_tests/performance/test_snapshot_ab.py::test_post_restore_latency",
40+
"tests": "integration_tests/performance/test_snapshot_ab.py::test_restore_latency integration_tests/performance/test_snapshot_ab.py::test_post_restore_latency",
4141
"devtool_opts": "-c 1-12 -m 0",
4242
},
4343
"population-latency": {
4444
"label": "📸 Memory Population Latency",
45-
"test_path": "integration_tests/performance/test_snapshot_ab.py::test_population_latency",
45+
"tests": "integration_tests/performance/test_snapshot_ab.py::test_population_latency",
4646
"devtool_opts": "-c 1-12 -m 0",
4747
},
4848
"vsock-throughput": {
4949
"label": "🧦 Vsock Throughput",
50-
"test_path": "integration_tests/performance/test_vsock_ab.py",
50+
"tests": "integration_tests/performance/test_vsock_ab.py",
5151
"devtool_opts": "-c 1-10 -m 0",
5252
},
5353
"memory-overhead": {
5454
"label": "💾 Memory Overhead and 👢 Boottime",
55-
"test_path": "integration_tests/performance/test_memory_overhead.py integration_tests/performance/test_boottime.py::test_boottime",
55+
"tests": "integration_tests/performance/test_memory_overhead.py integration_tests/performance/test_boottime.py::test_boottime",
5656
"devtool_opts": "-c 1-10 -m 0",
5757
},
5858
}
@@ -93,23 +93,21 @@
9393
tests = [perf_test[test] for test in pipeline.args.test or perf_test.keys()]
9494
for test in tests:
9595
devtool_opts = test.pop("devtool_opts")
96-
test_path = test.pop("test_path")
96+
test_selector = test.pop("tests")
9797
ab_opts = test.pop("ab_opts", "")
9898
devtool_opts += " --performance"
99-
pytest_opts = ""
99+
test_script_opts = ""
100100
if REVISION_A:
101101
devtool_opts += " --ab"
102-
pytest_opts = (
103-
f"{ab_opts} run build/{REVISION_A}/ build/{REVISION_B} --test {test_path}"
104-
)
102+
test_script_opts = f'{ab_opts} run build/{REVISION_A}/ build/{REVISION_B} --pytest-opts "{test_selector}"'
105103
else:
106104
# Passing `-m ''` below instructs pytest to collect tests regardless of
107105
# their markers (e.g. it will collect both tests marked as nonci, and
108106
# tests without any markers).
109-
pytest_opts += f" -m '' {test_path}"
107+
test_script_opts += f" -m '' {test_selector}"
110108

111109
pipeline.build_group(
112-
command=pipeline.devtool_test(devtool_opts, pytest_opts),
110+
command=pipeline.devtool_test(devtool_opts, test_script_opts),
113111
# and the rest can be command arguments
114112
**test,
115113
)

tools/ab_test.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,19 +174,20 @@ def load_data_series(report_path: Path, tag=None, *, reemit: bool = False):
174174
return post_processed_emf
175175

176176

177-
def collect_data(binary_dir: Path, tests: list[str]):
177+
def collect_data(binary_dir: Path, pytest_opts: str):
178178
"""Executes the specified test using the provided firecracker binaries"""
179179
binary_dir = binary_dir.resolve()
180180

181181
print(f"Collecting samples with {binary_dir}")
182182
subprocess.run(
183-
["./tools/test.sh", f"--binary-dir={binary_dir}", *tests, "-m", ""],
183+
f"./tools/test.sh --binary-dir={binary_dir} {pytest_opts} -m ''",
184184
env=os.environ
185185
| {
186186
"AWS_EMF_ENVIRONMENT": "local",
187187
"AWS_EMF_NAMESPACE": "local",
188188
},
189189
check=True,
190+
shell=True,
190191
)
191192
return load_data_series(
192193
Path("test_results/test-report.json"), binary_dir, reemit=True
@@ -330,15 +331,15 @@ def analyze_data(
330331
def ab_performance_test(
331332
a_revision: Path,
332333
b_revision: Path,
333-
tests,
334+
pytest_opts,
334335
p_thresh,
335336
strength_abs_thresh,
336337
noise_threshold,
337338
):
338339
"""Does an A/B-test of the specified test with the given firecracker/jailer binaries"""
339340

340341
return binary_ab_test(
341-
lambda bin_dir, _: collect_data(bin_dir, tests),
342+
lambda bin_dir, _: collect_data(bin_dir, pytest_opts),
342343
lambda ah, be: analyze_data(
343344
ah,
344345
be,
@@ -371,7 +372,11 @@ def ab_performance_test(
371372
help="Directory containing firecracker and jailer binaries whose performance we want to compare against the results from a_revision",
372373
type=Path,
373374
)
374-
run_parser.add_argument("--test", help="The test to run", nargs="+", required=True)
375+
run_parser.add_argument(
376+
"--pytest-opts",
377+
help="Parameters to pass through to pytest, for example for test selection",
378+
required=True,
379+
)
375380
analyze_parser = subparsers.add_parser(
376381
"analyze",
377382
help="Analyze the results of two manually ran tests based on their test-report.json files",
@@ -410,7 +415,7 @@ def ab_performance_test(
410415
ab_performance_test(
411416
args.a_revision,
412417
args.b_revision,
413-
args.test,
418+
args.pytest_opts,
414419
args.significance,
415420
args.absolute_strength,
416421
args.noise_threshold,

0 commit comments

Comments
 (0)