Skip to content

Commit dd234ca

Browse files
committed
ci: add option to use a different Firecracker binary
This enables us to run a pipeline against an existing binary. The binary has to exist in the Buildkite artifacts buckets. (cherry-picked from eb83708 with some rebasing changes) Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent faf830e commit dd234ca

File tree

4 files changed

+45
-6
lines changed

4 files changed

+45
-6
lines changed

.buildkite/common.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,23 @@ def run_all_tests(changed_files):
110110
)
111111

112112

113+
def devtool_test(devtool_opts=None, pytest_opts=None, binary_dir=None):
114+
"""Generate a `devtool test` command"""
115+
cmds = []
116+
parts = ["./tools/devtool -y test"]
117+
if devtool_opts:
118+
parts.append(devtool_opts)
119+
parts.append("--")
120+
if binary_dir is not None:
121+
cmds.append(f'buildkite-agent artifact download "{binary_dir}/$(uname -m)/*" .')
122+
cmds.append(f"chmod -v a+x {binary_dir}/**/*")
123+
parts.append(f"--binary-dir=../{binary_dir}/$(uname -m)")
124+
if pytest_opts:
125+
parts.append(pytest_opts)
126+
cmds.append(" ".join(parts))
127+
return cmds
128+
129+
113130
class DictAction(argparse.Action):
114131
"""An argparse action that can receive a nested dictionary
115132
@@ -159,3 +176,10 @@ def __call__(self, parser, namespace, value, option_string=None):
159176
default={},
160177
type=str,
161178
)
179+
COMMON_PARSER.add_argument(
180+
"--binary-dir",
181+
help="Use the Firecracker binaries from this path",
182+
required=False,
183+
default=None,
184+
type=str,
185+
)

.buildkite/pipeline_perf.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"""Generate Buildkite performance pipelines dynamically"""
66
import os
77

8-
from common import COMMON_PARSER, group, overlay_dict, pipeline_to_json
8+
from common import COMMON_PARSER, devtool_test, group, overlay_dict, pipeline_to_json
99

1010
# In `devtool_opts`, we restrict both the set of CPUs on which the docker container's threads can run,
1111
# and its memory node. For the cpuset, we pick a continuous set of CPUs from a single NUMA node
@@ -66,13 +66,17 @@ def build_group(test):
6666
devtool_opts = test.pop("devtool_opts")
6767
test_path = test.pop("test_path")
6868
ab_opts = test.pop("ab_opts", "")
69+
devtool_opts += " --performance"
70+
pytest_opts = ""
6971
if REVISION_A:
70-
command = f"./tools/devtool -y test --performance --ab {devtool_opts} -- {REVISION_A} {REVISION_B} --test {test_path} {ab_opts}"
72+
devtool_opts += " --ab"
73+
pytest_opts = f"{REVISION_A} {REVISION_B} --test {test_path} {ab_opts}"
7174
else:
72-
command = f"./tools/devtool -y test --performance {devtool_opts} -- -m nonci {test_path}"
75+
pytest_opts += f" -m nonci {test_path}"
76+
binary_dir = test.pop("binary_dir")
7377
return group(
7478
label=test.pop("label"),
75-
command=command,
79+
command=devtool_test(devtool_opts, pytest_opts, binary_dir),
7680
artifacts=["./test_results/*"],
7781
instances=test.pop("instances"),
7882
platforms=test.pop("platforms"),
@@ -99,6 +103,7 @@ def build_group(test):
99103
test_data.setdefault("instances", args.instances)
100104
# use ag=1 instances to make sure no two performance tests are scheduled on the same instance
101105
test_data.setdefault("agents", {"ag": 1})
106+
test_data["binary_dir"] = args.binary_dir
102107
test_data = overlay_dict(test_data, args.step_param)
103108
test_data["retry"] = {
104109
"automatic": [

.buildkite/pipeline_pr.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from common import (
88
COMMON_PARSER,
9+
devtool_test,
910
get_changed_files,
1011
group,
1112
overlay_dict,
@@ -61,7 +62,10 @@
6162

6263
functional_grp = group(
6364
"⚙ Functional and security 🔒",
64-
"./tools/devtool -y test -- -n 8 --dist worksteal integration_tests/{{functional,security}}",
65+
devtool_test(
66+
pytest_opts="-n 8 --dist worksteal integration_tests/{{functional,security}}",
67+
binary_dir=args.binary_dir,
68+
),
6569
**defaults,
6670
)
6771

@@ -77,7 +81,11 @@
7781

7882
performance_grp = group(
7983
"⏱ Performance",
80-
"./tools/devtool -y test --performance -c 1-10 -m 0 -- ../tests/integration_tests/performance/",
84+
devtool_test(
85+
devtool_opts="--performance -c 1-10 -m 0",
86+
pytest_opts="../tests/integration_tests/performance/",
87+
binary_dir=args.binary_dir,
88+
),
8189
**defaults_for_performance,
8290
)
8391

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,8 @@ def microvm_factory(request, record_property, results_dir):
248248
if binary_dir := request.config.getoption("--binary-dir"):
249249
fc_binary_path = Path(binary_dir) / "firecracker"
250250
jailer_binary_path = Path(binary_dir) / "jailer"
251+
if not fc_binary_path.exists():
252+
raise RuntimeError("Firecracker binary does not exist")
251253
else:
252254
fc_binary_path, jailer_binary_path = build_tools.get_firecracker_binaries()
253255
record_property("firecracker_bin", str(fc_binary_path))

0 commit comments

Comments
 (0)