Skip to content

Commit eb83708

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. Signed-off-by: Pablo Barbáchano <[email protected]>
1 parent 56bf4d5 commit eb83708

File tree

4 files changed

+38
-4
lines changed

4 files changed

+38
-4
lines changed

.buildkite/common.py

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

112112

113+
def devtool_test(test_path, 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 pytest_opts:
121+
parts.append(pytest_opts)
122+
if binary_dir is not None:
123+
cmds.append(f'buildkite-agent artifact download "{binary_dir}/$(uname -m)/*" .')
124+
cmds.append(f"chmod -v a+x {binary_dir}/**/*")
125+
parts.append(f"--binary-dir=../{binary_dir}/$(uname -m)")
126+
parts.append(test_path)
127+
cmds.append(" ".join(parts))
128+
return cmds
129+
130+
113131
class DictAction(argparse.Action):
114132
"""An argparse action that can receive a nested dictionary
115133
@@ -159,3 +177,10 @@ def __call__(self, parser, namespace, value, option_string=None):
159177
default={},
160178
type=str,
161179
)
180+
COMMON_PARSER.add_argument(
181+
"--binary-dir",
182+
help="Use the Firecracker binaries from this path",
183+
required=False,
184+
default=None,
185+
type=str,
186+
)

.buildkite/pipeline_perf.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
"""Generate Buildkite performance pipelines dynamically"""
66

7-
from common import COMMON_PARSER, group, overlay_dict, pipeline_to_json
7+
from common import COMMON_PARSER, devtool_test, group, overlay_dict, pipeline_to_json
88

99
perf_test = {
1010
"block": {
@@ -45,9 +45,11 @@ def build_group(test):
4545
devtool_opts = test.pop("devtool_opts")
4646
test_path = test.pop("test_path")
4747
retries = test.pop("retries")
48+
binary_dir = test.pop("binary_dir")
49+
pytest_opts = f"-m nonci --reruns {retries} --perf-fail"
4850
return group(
4951
label=test.pop("label"),
50-
command=f"./tools/devtool -y test {devtool_opts} -- -m nonci --reruns {retries} --perf-fail {test_path}",
52+
command=devtool_test(test_path, devtool_opts, pytest_opts, binary_dir),
5153
artifacts=["./test_results/*"],
5254
instances=test.pop("instances"),
5355
platforms=test.pop("platforms"),
@@ -75,6 +77,7 @@ def build_group(test):
7577
test_data.setdefault("agents", {"ag": 1})
7678
test_data["retries"] = args.retries
7779
test_data["timeout_in_minutes"] *= args.retries + 1
80+
test_data["binary_dir"] = args.binary_dir
7881
test_data = overlay_dict(test_data, args.step_param)
7982
test_data["retry"] = {
8083
"automatic": [

.buildkite/pipeline_pr.py

Lines changed: 6 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+
"-n 8 --dist worksteal integration_tests/{{functional,security}}",
67+
binary_dir=args.binary_dir,
68+
),
6569
**defaults,
6670
)
6771

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

7882
performance_grp = group(
7983
"⏱ Performance",
80-
"./tools/devtool -y test -- ../tests/integration_tests/performance/",
84+
devtool_test("../tests/integration_tests/performance/", binary_dir=args.binary_dir),
8185
**defaults_for_performance,
8286
)
8387

tests/conftest.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ def microvm_factory(fc_tmp_path, bin_cloner_path, request):
288288
if binary_dir := request.config.getoption("--binary-dir"):
289289
fc_binary_path = Path(binary_dir) / "firecracker"
290290
jailer_binary_path = Path(binary_dir) / "jailer"
291+
if not fc_binary_path.exists():
292+
raise RuntimeError("Firecracker binary does not exist")
291293
else:
292294
fc_binary_path, jailer_binary_path = build_tools.get_firecracker_binaries()
293295

0 commit comments

Comments
 (0)