Skip to content

Commit d0e7edf

Browse files
committed
refactor: move binary_ab_test to ab_test.py
This function was only used in ab_test.py Signed-off-by: Egor Lazarchuk <yegorlz@amazon.co.uk>
1 parent f66dd13 commit d0e7edf

File tree

2 files changed

+22
-25
lines changed

2 files changed

+22
-25
lines changed

tests/framework/ab_test.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@
2626
from typing import Callable, Optional, TypeVar
2727

2828
from framework import utils
29-
from framework.defs import FC_WORKSPACE_DIR
3029
from framework.properties import global_props
3130
from framework.utils import CommandReturn
3231
from framework.with_filelock import with_filelock
33-
from host_tools.cargo_build import DEFAULT_TARGET_DIR
3432

3533
# Locally, this will always compare against main, even if we try to merge into, say, a feature branch.
3634
# We might want to do a more sophisticated way to determine a "parent" branch here.
@@ -95,27 +93,6 @@ def git_ab_test(
9593
return result_a, result_b, comparison
9694

9795

98-
DEFAULT_A_DIRECTORY = FC_WORKSPACE_DIR / "build" / "main"
99-
DEFAULT_B_DIRECTORY = FC_WORKSPACE_DIR / "build" / "cargo_target" / DEFAULT_TARGET_DIR
100-
101-
102-
def binary_ab_test(
103-
test_runner: Callable[[Path, bool], T],
104-
comparator: Callable[[T, T], U] = default_comparator,
105-
*,
106-
a_directory: Path = DEFAULT_A_DIRECTORY,
107-
b_directory: Path = DEFAULT_B_DIRECTORY,
108-
):
109-
"""
110-
Similar to `git_ab_test`, but instead of locally checking out different revisions, it operates on
111-
directories containing firecracker/jailer binaries
112-
"""
113-
result_a = test_runner(a_directory, True)
114-
result_b = test_runner(b_directory, False)
115-
116-
return result_a, result_b, comparator(result_a, result_b)
117-
118-
11996
def git_ab_test_host_command_if_pr(
12097
command: str,
12198
*,

tools/ab_test.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,14 @@
2525
import sys
2626
from collections import defaultdict
2727
from pathlib import Path
28-
from typing import List
28+
from typing import Callable, List, TypeVar
2929

3030
import scipy
3131

3232
# Hack to be able to use our test framework code
3333
sys.path.append(str(Path(__file__).parent.parent / "tests"))
3434

3535
# pylint:disable=wrong-import-position
36-
from framework.ab_test import binary_ab_test
3736
from framework.properties import global_props
3837
from host_tools.metrics import get_metrics_logger
3938

@@ -379,6 +378,27 @@ def analyze_data(
379378
print("No regressions detected!")
380379

381380

381+
T = TypeVar("T")
382+
U = TypeVar("U")
383+
384+
385+
def binary_ab_test(
386+
test_runner: Callable[[Path, bool], T],
387+
comparator: Callable[[T, T], U],
388+
*,
389+
a_directory: Path,
390+
b_directory: Path,
391+
):
392+
"""
393+
Similar to `git_ab_test`, but instead of locally checking out different revisions, it operates on
394+
directories containing firecracker/jailer binaries
395+
"""
396+
result_a = test_runner(a_directory, True)
397+
result_b = test_runner(b_directory, False)
398+
399+
return result_a, result_b, comparator(result_a, result_b)
400+
401+
382402
def ab_performance_test(
383403
a_revision: Path,
384404
b_revision: Path,

0 commit comments

Comments
 (0)