Skip to content

Commit 4148086

Browse files
committed
Add critest to Makefile and test-images
Add critest tool to test-images and invoke in Dockerfile. Add rule to Makefile for running critest Preliminary step before adding critest to BuildKite pipeline. Signed-off-by: Gavin Inglis <[email protected]>
1 parent 3c25750 commit 4148086

File tree

7 files changed

+100
-3
lines changed

7 files changed

+100
-3
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,12 @@ TEST_BRIDGED_TAP_BIN?=$(BINPATH)/test-bridged-tap
256256
$(TEST_BRIDGED_TAP_BIN): $(shell find internal/cmd/test-bridged-tap -name *.go) $(GOMOD) $(GOSUM)
257257
go build -o $@ $(CURDIR)/internal/cmd/test-bridged-tap
258258

259+
LOOPBACK_BIN?=$(BINPATH)/loopback
260+
$(LOOPBACK_BIN):
261+
GOBIN=$(dir $@) GO111MODULE=off go get -u github.com/containernetworking/plugins/plugins/main/loopback
262+
259263
.PHONY: cni-bins
260-
cni-bins: $(BRIDGE_BIN) $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN) $(TC_REDIRECT_TAP_BIN)
264+
cni-bins: $(BRIDGE_BIN) $(PTP_BIN) $(HOSTLOCAL_BIN) $(FIREWALL_BIN) $(TC_REDIRECT_TAP_BIN) $(LOOPBACK_BIN)
261265

262266
.PHONY: test-cni-bins
263267
test-cni-bins: $(TEST_BRIDGED_TAP_BIN)
@@ -269,6 +273,7 @@ install-cni-bins: cni-bins $(CNI_BIN_ROOT)
269273
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(HOSTLOCAL_BIN)
270274
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(FIREWALL_BIN)
271275
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(TC_REDIRECT_TAP_BIN)
276+
install -D -o root -g root -m755 -t $(CNI_BIN_ROOT) $(LOOPBACK_BIN)
272277

273278
.PHONY: install-test-cni-bins
274279
install-test-cni-bins: test-cni-bins $(CNI_BIN_ROOT)

runtime/Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,24 @@ perf-test:
141141
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
142142
"go test -timeout 0 -v -count=1 -run \"^$(PERF_TESTNAME)$$\""
143143

144+
.PHONY: critest
145+
critest:
146+
$(CURDIR)/../tools/thinpool.sh reset "$(FICD_DM_POOL)"
147+
docker run --rm -it \
148+
--privileged \
149+
--ipc=host \
150+
--volume /dev:/dev \
151+
--volume /run/udev/control:/run/udev/control \
152+
--volume $(CURDIR)/..:/src \
153+
--volume $(GO_CACHE_VOLUME_NAME):/go \
154+
--env FICD_DM_VOLUME_GROUP=$(FICD_DM_VOLUME_GROUP) \
155+
--env FICD_DM_POOL=$(FICD_DM_POOL) \
156+
--env GOPROXY=direct \
157+
--env GOSUMDB=off \
158+
--workdir="/src/runtime" \
159+
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
160+
"critest -runtime-endpoint unix:///run/firecracker-containerd/containerd.sock"
161+
144162
clean:
145163
- rm -f containerd-shim-aws-firecracker
146164

tools/docker/Dockerfile.integ-test

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,18 @@ RUN mkdir -p \
2525
/var/run/firecracker-containerd \
2626
/src \
2727
/srv/firecracker_containerd_tests \
28-
${FICD_LOG_DIR}
28+
${FICD_LOG_DIR} \
29+
/etc/cni/net.d
30+
2931

3032
# Pull the images the tests need into the content store so we don't need internet
3133
# access during the tests themselves. This runs as a seperate step before the other
3234
# installs so we can minimize re-runs of the time-expensive downloading of images.
3335
COPY tools/docker/config.toml /etc/containerd/config.toml
3436
COPY tools/docker/do_not_edit_for_firecracker-control.config.json /etc/containerd/firecracker-runtime.json
37+
COPY tools/docker/critest/10-mynet.conf /etc/cni/net.d
38+
COPY tools/docker/critest/99-loopback.conf /etc/cni/net.d
39+
3540
RUN --mount=type=bind,source=firecracker-control/cmd/containerd,target=/src \
3641
make -C /src install && \
3742
ln -sv /usr/local/bin/firecracker-containerd /usr/local/bin/containerd && \
@@ -40,6 +45,13 @@ RUN containerd 2>/dev/null & \
4045
ctr --address /run/firecracker-containerd/containerd.sock content fetch docker.io/library/alpine:3.10.1 >/dev/null && \
4146
ctr --address /run/firecracker-containerd/containerd.sock content fetch docker.io/mlabbe/iperf3:3.6-r0 >/dev/null
4247

48+
# Install critest
49+
ENV VERSION="v1.23.0"
50+
RUN wget https://github.com/kubernetes-sigs/cri-tools/releases/download/$VERSION/critest-$VERSION-linux-amd64.tar.gz && \
51+
tar zxvf critest-$VERSION-linux-amd64.tar.gz -C /tmp/ && \
52+
install -D -o root -g root -m755 -t /usr/local/bin /tmp/critest && \
53+
rm -f critest-$VERSION-linux-amd64.tar.gz && \
54+
4355
# Install everything we need in this image. Due to the bind-mount, if the host has already
4456
# up-to-date versions of everything built, this step will be a very quick copy
4557
RUN --mount=type=bind,target=/src make -C /src \

tools/docker/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
imports = ["/etc/containerd/snapshotter/*.toml"]
1+
imports = ["/etc/containerd/snapshotter/*.toml", "/etc/containerd/cri/*.toml"]
22
[grpc]
33
address = "/run/firecracker-containerd/containerd.sock"

tools/docker/critest/10-mynet.conf

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"cniVersion": "0.2.0",
3+
"name": "mynet",
4+
"type": "bridge",
5+
"bridge": "cni0",
6+
"isGateway": true,
7+
"ipMasq": true,
8+
"ipam": {
9+
"type": "host-local",
10+
"subnet": "10.22.0.0/16",
11+
"routes": [
12+
{ "dst": "0.0.0.0/0" }
13+
]
14+
}
15+
}

tools/docker/critest/99-loopback.conf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"cniVersion": "0.2.0",
3+
"name": "lo",
4+
"type": "loopback"
5+
}

tools/docker/entrypoint.sh

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -e
44
chmod a+rwx ${FICD_LOG_DIR}
55

66
mkdir -p /etc/containerd/snapshotter
7+
mkdir -p /etc/containerd/cri
78

89
if [[ -z "$FICD_DM_VOLUME_GROUP" ]]; then
910
pool_name="${FICD_DM_POOL}"
@@ -19,6 +20,47 @@ version = 2
1920
base_image_size = "1024MB"
2021
EOF
2122

23+
cat > /etc/containerd/cri/criconfig.toml <<EOF
24+
version = 2
25+
[plugins]
26+
# The 'plugins."io.containerd.grpc.v1.cri"' table contains all of the server options.
27+
[plugins."io.containerd.grpc.v1.cri"]
28+
29+
# 'plugins."io.containerd.grpc.v1.cri".containerd' contains config related to containerd
30+
[plugins."io.containerd.grpc.v1.cri".containerd]
31+
32+
# snapshotter is the snapshotter used by containerd.
33+
snapshotter = "devmapper"
34+
35+
# default_runtime_name is the default runtime name to use.
36+
default_runtime_name = "containerd-shim-aws-firecracker"
37+
38+
# 'plugins."io.containerd.grpc.v1.cri".containerd.runtimes' is a map from CRI RuntimeHandler strings, which specify types
39+
# of runtime configurations, to the matching configurations.
40+
# In this example, 'runc' is the RuntimeHandler string to match.
41+
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.containerd-shim-aws-firecracker]
42+
# runtime_type is the runtime type to use in containerd.
43+
# The default value is "io.containerd.runc.v2" since containerd 1.4.
44+
# The default value was "io.containerd.runc.v1" in containerd 1.3, "io.containerd.runtime.v1.linux" in prior releases.
45+
runtime_type = "aws.firecracker"
46+
47+
48+
# conf_dir is the directory in which the admin places a CNI conf.
49+
# this allows a different CNI conf for the network stack when a different runtime is being used.
50+
cni_conf_dir = "/etc/cni/net.d"
51+
52+
# 'plugins."io.containerd.grpc.v1.cri".cni' contains config related to cni
53+
[plugins."io.containerd.grpc.v1.cri".cni]
54+
# bin_dir is the directory in which the binaries for the plugin is kept.
55+
bin_dir = "/opt/cni/bin"
56+
57+
# conf_dir is the directory in which the admin places a CNI conf.
58+
conf_dir = "/etc/cni/net.d"
59+
60+
[debug]
61+
level = "debug"
62+
EOF
63+
2264
touch ${FICD_CONTAINERD_OUTFILE}
2365
chmod a+rw ${FICD_CONTAINERD_OUTFILE}
2466
/usr/local/bin/containerd --log-level debug &>> ${FICD_CONTAINERD_OUTFILE} &

0 commit comments

Comments
 (0)