Skip to content

Commit dd104c1

Browse files
pb8oJonathanWoollett-Light
authored andcommitted
chore(ab_test.py): output nested test session as it happens
Instead of waiting until the end, use `subprocess.run` to inherit the parent's terminal/stdout/stderr. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent a47b1d3 commit dd104c1

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

.buildkite/pipeline_perf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def build_group(test):
7171
pytest_opts = ""
7272
if REVISION_A:
7373
devtool_opts += " --ab"
74-
pytest_opts = f" {ab_opts} run {REVISION_A} {REVISION_B} --test '{test_path}'"
74+
pytest_opts = f" {ab_opts} run {REVISION_A} {REVISION_B} --test {test_path}"
7575
else:
7676
# Passing `-m ''` below instructs pytest to collect tests regardless of their markers (e.g. it will collect both tests marked as nonci, and tests without any markers).
7777
pytest_opts += f" -m '' {test_path}"

tools/ab_test.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121
"""
2222
import argparse
2323
import json
24+
import os
2425
import statistics
26+
import subprocess
2527
import sys
2628
from collections import defaultdict
2729
from pathlib import Path
@@ -153,16 +155,20 @@ def load_data_series(report_path: Path, revision: str = None, *, reemit: bool =
153155
return processed_emf
154156

155157

156-
def collect_data(binary_dir: Path, test: str):
158+
def collect_data(binary_dir: Path, tests: list[str]):
157159
"""Executes the specified test using the provided firecracker binaries"""
158160
revision = binary_dir.name
159161

160-
print("Collecting samples")
161-
_, stdout, _ = utils.run_cmd(
162-
f"AWS_EMF_ENVIRONMENT=local AWS_EMF_NAMESPACE=local ./tools/test.sh --binary-dir={binary_dir} {test} -m ''"
162+
print(f"Collecting samples with {binary_dir}")
163+
subprocess.run(
164+
["./tools/test.sh", f"--binary-dir={binary_dir}", *tests, "-m", ""],
165+
env=os.environ
166+
| {
167+
"AWS_EMF_ENVIRONMENT": "local",
168+
"AWS_EMF_NAMESPACE": "local",
169+
},
170+
check=True,
163171
)
164-
print(stdout.strip())
165-
166172
return load_data_series(
167173
Path("test_results/test-report.json"), revision, reemit=True
168174
)
@@ -304,7 +310,7 @@ def analyze_data(
304310

305311

306312
def ab_performance_test(
307-
a_revision, b_revision, test, p_thresh, strength_abs_thresh, noise_threshold
313+
a_revision, b_revision, tests, p_thresh, strength_abs_thresh, noise_threshold
308314
):
309315
"""Does an A/B-test of the specified test across the given revisions"""
310316
_, commit_list, _ = utils.run_cmd(
@@ -318,7 +324,7 @@ def ab_performance_test(
318324
def test_runner(workspace, _is_ab: bool):
319325
utils.run_cmd("./tools/release.sh --profile release", cwd=workspace)
320326
bin_dir = ".." / get_binary("firecracker", workspace_dir=workspace).parent
321-
return collect_data(bin_dir, test)
327+
return collect_data(bin_dir, tests)
322328

323329
return git_ab_test(
324330
test_runner,
@@ -357,7 +363,7 @@ def canonicalize_revision(revision):
357363
"b_revision",
358364
help="The revision whose performance we want to compare against the results from a_revision",
359365
)
360-
run_parser.add_argument("--test", help="The test to run", required=True)
366+
run_parser.add_argument("--test", help="The test to run", nargs="+", required=True)
361367
analyze_parser = subparsers.add_parser(
362368
"analyze",
363369
help="Analyze the results of two manually ran tests based on their test-report.json files",

0 commit comments

Comments
 (0)