Skip to content

Commit 613c979

Browse files
committed
feat: store test results for A/B runs
Currently when A/B is run, only results for B test are available in the `test_results` dir because this dir is shared for both runs and the last one overwrites the data. Now we move results into separate dirs after tests are done. Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent 74f90f0 commit 613c979

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

tests/framework/ab_test.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
of both invocations is the same, the test passes (with us being alerted to this situtation via a special pipeline that
2222
does not block PRs). If not, it fails, preventing PRs from introducing new vulnerable dependencies.
2323
"""
24+
import os
2425
import statistics
2526
from pathlib import Path
2627
from tempfile import TemporaryDirectory
@@ -103,7 +104,7 @@ def git_ab_test(
103104

104105

105106
def binary_ab_test(
106-
test_runner: Callable[[Path, bool], T],
107+
test_runner: Callable[[str, Path, bool], T],
107108
comparator: Callable[[T, T], U] = default_comparator,
108109
*,
109110
a_directory: Path = DEFAULT_A_DIRECTORY,
@@ -113,8 +114,14 @@ def binary_ab_test(
113114
Similar to `git_ab_test`, but instead of locally checking out different revisions, it operates on
114115
directories containing firecracker/jailer binaries
115116
"""
116-
result_a = test_runner(a_directory, True)
117-
result_b = test_runner(b_directory, False)
117+
result_a = test_runner("A", a_directory, True)
118+
result_b = test_runner("B", b_directory, False)
119+
120+
# put results back into the place, where buildkite will
121+
# expect them to be
122+
os.mkdir("test_results")
123+
os.rename("A", "test_results/A")
124+
os.rename("B", "test_results/B")
118125

119126
return result_a, result_b, comparator(result_a, result_b)
120127

tools/ab_test.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def uninteresting_dimensions(processed_emf):
180180
return uninteresting
181181

182182

183-
def collect_data(binary_dir: Path, pytest_opts: str):
183+
def collect_data(tag: str, binary_dir: Path, pytest_opts: str):
184184
"""Executes the specified test using the provided firecracker binaries"""
185185
binary_dir = binary_dir.resolve()
186186

@@ -195,9 +195,12 @@ def collect_data(binary_dir: Path, pytest_opts: str):
195195
check=True,
196196
shell=True,
197197
)
198-
return load_data_series(
199-
Path("test_results/test-report.json"), binary_dir, reemit=True
200-
)
198+
199+
# move results into a tag directory
200+
os.mkdir(tag)
201+
os.rename("test_results", tag)
202+
203+
return load_data_series(Path(f"{tag}/test-report.json"), binary_dir, reemit=True)
201204

202205

203206
def analyze_data(
@@ -346,7 +349,7 @@ def ab_performance_test(
346349
"""Does an A/B-test of the specified test with the given firecracker/jailer binaries"""
347350

348351
return binary_ab_test(
349-
lambda bin_dir, _: collect_data(bin_dir, pytest_opts),
352+
lambda tag, bin_dir, _: collect_data(tag, bin_dir, pytest_opts),
350353
lambda ah, be: analyze_data(
351354
ah,
352355
be,

0 commit comments

Comments
 (0)