Skip to content

Commit 9f04cde

Browse files
authored
Merge pull request #179 from xibz/ci-update
Add test step to test against HEAD of Firecracker
2 parents e0e96b5 + d89b4a4 commit 9f04cde

File tree

6 files changed

+108
-20
lines changed

6 files changed

+108
-20
lines changed

.buildkite/pipeline.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ steps:
3232
commands:
3333
- 'sudo ip tuntap add fc-test-tap${BUILDKITE_BUILD_NUMBER} mode tap user $(sudo id -u buildkite-agent)'
3434
- 'sudo ip tuntap add fc-root-tap${BUILDKITE_BUILD_NUMBER} mode tap user $(sudo id -u buildkite-agent)'
35+
- 'sudo ip tuntap add fc-mst-tap${BUILDKITE_BUILD_NUMBER} mode tap user $(sudo id -u buildkite-agent)'
36+
agents:
37+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
38+
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
39+
hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
40+
41+
- label: ':linux: build docker images'
42+
commands:
43+
- 'make test-images'
44+
- 'buildkite-agent artifact upload testdata/firecracker-master'
45+
- 'buildkite-agent artifact upload testdata/jailer-master'
3546
agents:
3647
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
3748
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
@@ -91,6 +102,27 @@ steps:
91102
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
92103
hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
93104

105+
- label: ':hammer: test against firecracker master'
106+
env:
107+
FC_TEST_BIN: "testdata/firecracker-master"
108+
DOCKER_IMAGE_TAG: "$BUILDKITE_BUILD_NUMBER"
109+
FC_TEST_JAILER_BIN: "testdata/jailer-master"
110+
commands:
111+
- 'ln -s /var/lib/fc-ci/vmlinux.bin testdata/vmlinux'
112+
- 'ln -s /var/lib/fc-ci/rootfs.ext4 testdata/root-drive.img'
113+
- 'make -C cni install CNI_BIN_ROOT=$(pwd)/testdata/bin'
114+
- 'buildkite-agent artifact download testdata/firecracker-master .'
115+
- 'chmod +x testdata/firecracker-master'
116+
- 'buildkite-agent artifact download testdata/jailer-master .'
117+
- 'chmod +x testdata/jailer-master'
118+
- "sudo -E FC_TEST_TAP=fc-mst-tap${BUILDKITE_BUILD_NUMBER} make test EXTRAGOARGS='-v -count=1 -race' DISABLE_ROOT_TESTS="
119+
agents:
120+
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
121+
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"
122+
hostname: "${BUILDKITE_AGENT_META_DATA_HOSTNAME}"
123+
soft_fail:
124+
- exit_status: "*"
125+
94126

95127
# This allows the cleanup step to always run, regardless of test failure
96128
- wait: ~
@@ -100,6 +132,7 @@ steps:
100132
commands:
101133
- 'sudo ip tuntap del fc-test-tap${BUILDKITE_BUILD_NUMBER} mode tap'
102134
- 'sudo ip tuntap del fc-root-tap${BUILDKITE_BUILD_NUMBER} mode tap'
135+
- 'sudo ip tuntap del fc-mst-tap${BUILDKITE_BUILD_NUMBER} mode tap'
103136
agents:
104137
queue: "${BUILDKITE_AGENT_META_DATA_QUEUE:-default}"
105138
distro: "${BUILDKITE_AGENT_META_DATA_DISTRO}"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
firecracker
22
jailer
33
firecracker-*
4+
jailer-*
45
vmlinux
56
root-drive.img
6-
TestPID.img
7+
TestPID.img

Makefile

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,14 @@
1212
# permissions and limitations under the License.
1313

1414
# Set this to pass additional commandline flags to the go compiler, e.g. "make test EXTRAGOARGS=-v"
15-
EXTRAGOARGS:=
15+
CARGO_CACHE_VOLUME_NAME?=cargocache
1616
DISABLE_ROOT_TESTS?=1
17+
DOCKER_IMAGE_TAG?=latest
18+
EXTRAGOARGS:=
19+
FIRECRACKER_BUILDER_NAME=firecracker-builder
20+
FIRECRACKER_BIN=testdata/firecracker-master
21+
JAILER_BIN=testdata/jailer-master
22+
FIRECRACKER_TARGET?=x86_64-unknown-linux-musl
1723

1824
# The below files are needed and can be downloaded from the internet
1925
testdata_objects = testdata/vmlinux testdata/root-drive.img testdata/firecracker
@@ -40,6 +46,7 @@ generate build clean:
4046

4147
distclean: clean
4248
rm -rf $(testdata_objects)
49+
docker volume rm -f $(CARGO_CACHE_VOLUME_NAME)
4350

4451
testdata/vmlinux:
4552
$(curl) -o $@ https://s3.amazonaws.com/spec.ccfc.min/img/hello/kernel/hello-vmlinux.bin
@@ -51,4 +58,33 @@ testdata/firecracker:
5158
testdata/root-drive.img:
5259
$(curl) -o $@ https://s3.amazonaws.com/spec.ccfc.min/img/hello/fsfiles/hello-rootfs.ext4
5360

61+
tools/firecracker-builder-stamp: tools/docker/Dockerfile
62+
docker build \
63+
-t localhost/$(FIRECRACKER_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \
64+
-f tools/docker/Dockerfile \
65+
.
66+
touch $@
67+
68+
.PHONY: test-images
69+
test-images: $(FIRECRACKER_BIN) $(JAILER_BIN)
70+
71+
$(FIRECRACKER_BIN) $(JAILER_BIN): tools/firecracker-builder-stamp
72+
docker run --rm -it \
73+
--privileged \
74+
--volume $(CURDIR)/testdata:/artifacts \
75+
--volume $(CARGO_CACHE_VOLUME_NAME):/usr/local/cargo/registry \
76+
-e HOME=/tmp \
77+
--workdir=/firecracker \
78+
localhost/$(FIRECRACKER_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \
79+
$(FIRECRACKER_TARGET)
80+
81+
.PHONY: firecracker-clean
82+
firecracker-clean:
83+
- docker run --rm -it \
84+
--privileged \
85+
--workdir /firecracker\
86+
localhost/$(FIRECRACKER_BUILDER_NAME):$(DOCKER_IMAGE_TAG) \
87+
cargo clean
88+
- rm $(FIRECRACKER_BIN) $(JAILER_BIN)
89+
5490
.PHONY: all generate clean distclean build test unit-tests all-tests check-kvm

machine_test.go

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -231,25 +231,8 @@ func TestJailerMicroVMExecution(t *testing.T) {
231231
}
232232
}
233233

234-
jailerBin := defaultJailerBinary
235-
if _, err := os.Stat(filepath.Join(testDataPath, defaultJailerBinary)); err == nil {
236-
jailerBin = filepath.Join(testDataPath, defaultJailerBinary)
237-
}
238-
239234
ctx := context.Background()
240-
cmd := NewJailerCommandBuilder().
241-
WithBin(jailerBin).
242-
WithGID(IntValue(cfg.JailerCfg.GID)).
243-
WithUID(IntValue(cfg.JailerCfg.UID)).
244-
WithNumaNode(IntValue(cfg.JailerCfg.NumaNode)).
245-
WithID(cfg.JailerCfg.ID).
246-
WithChrootBaseDir(cfg.JailerCfg.ChrootBaseDir).
247-
WithExecFile(cfg.JailerCfg.ExecFile).
248-
WithStdout(os.Stdout).
249-
WithStderr(os.Stderr).
250-
Build(ctx)
251-
252-
m, err := NewMachine(ctx, cfg, WithProcessRunner(cmd), WithLogger(fctesting.NewLogEntry(t)))
235+
m, err := NewMachine(ctx, cfg, WithLogger(fctesting.NewLogEntry(t)))
253236
if err != nil {
254237
t.Fatalf("failed to create new machine: %v", err)
255238
}

tools/docker/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright 2018-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License"). You may
4+
# not use this file except in compliance with the License. A copy of the
5+
# License is located at
6+
#
7+
# http://aws.amazon.com/apache2.0/
8+
#
9+
# or in the "license" file accompanying this file. This file is distributed
10+
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
11+
# express or implied. See the License for the specific language governing
12+
# permissions and limitations under the License.
13+
14+
FROM rust:1.39-stretch
15+
16+
ENV DEBIAN_FRONTEND="noninteractive"
17+
RUN apt-get update && apt-get install --yes --no-install-recommends \
18+
musl-tools
19+
20+
RUN rustup target add x86_64-unknown-linux-musl
21+
22+
VOLUME /src
23+
24+
RUN mkdir --mode=0777 --parents /usr/local/cargo/registry
25+
VOLUME /usr/local/cargo/registry
26+
27+
RUN git clone https://github.com/firecracker-microvm/firecracker.git
28+
COPY tools/docker/entrypoint.sh /usr/local/bin
29+
WORKDIR firecracker
30+
ENTRYPOINT ["entrypoint.sh"]

tools/docker/entrypoint.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
3+
cargo build --release --target $@
4+
cp build/cargo_target/x86_64-unknown-linux-musl/release/firecracker /artifacts/firecracker-master
5+
cp build/cargo_target/x86_64-unknown-linux-musl/release/jailer /artifacts/jailer-master

0 commit comments

Comments
 (0)