forked from firecracker-microvm/firecracker-containerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
174 lines (151 loc) · 5.69 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"). You may
# not use this file except in compliance with the License. A copy of the
# License is located at
#
# http://aws.amazon.com/apache2.0/
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
# Set this to pass additional commandline flags to the go compiler, e.g. "make test EXTRAGOARGS=-v"
EXTRAGOARGS?=
NUMBER_OF_VMS?=
SOURCES := $(shell find ../config ../eventbridge ../firecracker-control ../internal ../proto . -name '*.go')
GOMOD := $(shell go env GOMOD)
GOSUM := $(GOMOD:.mod=.sum)
DOCKER_IMAGE_TAG?=latest
GO_CACHE_VOLUME_NAME?=gocache
FIRECRACKER_CONTAINERD_TEST_IMAGE?=localhost/firecracker-containerd-test
FICD_DM_POOL?=fc-test-thinpool
REVISION=$(shell git rev-parse HEAD)
INTEG_TEST_SUFFIX := _Isolated
INTEG_TESTNAMES=$(shell docker run --rm \
--network=none \
--volume $(CURDIR)/..:/src \
--volume $(GO_CACHE_VOLUME_NAME):/go \
--entrypoint=/bin/bash \
--workdir=/src/runtime \
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
-c "go test -list . | sed '$$d' | grep $(INTEG_TEST_SUFFIX)")
all: runtime
runtime: containerd-shim-aws-firecracker
containerd-shim-aws-firecracker: $(SOURCES) $(GOMOD) $(GOSUM)
go build -o containerd-shim-aws-firecracker $(EXTRAGOARGS) -ldflags "-X main.revision=$(REVISION)"
install: containerd-shim-aws-firecracker
install -D -o root -g root -m755 -t $(INSTALLROOT)/bin containerd-shim-aws-firecracker
test:
go test ./... $(EXTRAGOARGS)
integ-test:
$(MAKE) $(addprefix integ-test-,$(INTEG_TESTNAMES))
integ-test-%: logs
$(CURDIR)/../tools/thinpool.sh reset "$(FICD_DM_POOL)"
docker run --rm -it \
--privileged \
--ipc=host \
--network=none \
--volume /dev:/dev \
--volume /run/udev/control:/run/udev/control \
--volume $(CURDIR)/logs:/var/log/firecracker-containerd-test \
--volume $(CURDIR)/..:/src \
--volume $(GO_CACHE_VOLUME_NAME):/go \
--env ENABLE_ISOLATED_TESTS=1 \
--env FICD_DM_VOLUME_GROUP=$(FICD_DM_VOLUME_GROUP) \
--env FICD_DM_POOL=$(FICD_DM_POOL) \
--env GOPROXY=direct \
--env GOSUMDB=off \
--env NUMBER_OF_VMS=$(NUMBER_OF_VMS) \
--workdir="/src/runtime" \
--init \
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
"go test $(EXTRAGOARGS) -run '^$(subst integ-test-,,$@)$$'"
benchmark-%: logs
$(CURDIR)/../tools/thinpool.sh reset "$(FICD_DM_POOL)"
docker run --rm -it \
--privileged \
--ipc=host \
--network=none \
--volume /dev:/dev \
--volume /run/udev/control:/run/udev/control \
--volume $(CURDIR)/logs:/var/log/firecracker-containerd-test \
--volume $(CURDIR)/..:/src \
--volume $(GO_CACHE_VOLUME_NAME):/go \
--env ENABLE_ISOLATED_TESTS=1 \
--env FICD_DM_VOLUME_GROUP=$(FICD_DM_VOLUME_GROUP) \
--env FICD_DM_POOL=$(FICD_DM_POOL) \
--env GOPROXY=direct \
--env GOSUMDB=off \
--env NUMBER_OF_VMS=$(NUMBER_OF_VMS) \
--workdir="/src/runtime" \
--init \
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
"go test $(EXTRAGOARGS) -run '$(subst benchmark-,,$@)'"
logs:
mkdir logs
PERF_TESTNAME?=TestCNIPlugin_Performance
PERF_VMCOUNT?=25
PERF_RUNTIME_SECONDS?=600
PERF_VM_MEMSIZE_MB?=1024
PERF_TARGET_BANDWIDTH?=1G
FICD_DM_VOLUME_GROUP?=
FICD_DM_POOL?=
tc-redirect-tap-perf:
$(MAKE) PERF_PLUGIN_NAME=tc-redirect-tap perf-test
test-bridged-tap-perf:
$(MAKE) PERF_PLUGIN_NAME=test-bridged-tap perf-test
perf-test:
$(if $(PERF_PLUGIN_NAME),true,$(error PERF_PLUGIN_NAME must be set for perf-test target))
mkdir -p $(CURDIR)/logs
docker run --rm -it \
--privileged \
--ipc=host \
--network=none \
--volume /dev:/dev \
--volume /run/udev/control:/run/udev/control \
--volume $(CURDIR)/logs:/var/log/firecracker-containerd-test \
--volume $(CURDIR)/..:/src \
--volume $(GO_CACHE_VOLUME_NAME):/go \
--env ENABLE_ISOLATED_TESTS=1 \
--env PERF_PLUGIN_NAME=$(PERF_PLUGIN_NAME) \
--env PERF_VMCOUNT=$(PERF_VMCOUNT) \
--env PERF_RUNTIME_SECONDS=$(PERF_RUNTIME_SECONDS) \
--env PERF_VM_MEMSIZE_MB=$(PERF_VM_MEMSIZE_MB) \
--env PERF_TARGET_BANDWIDTH=$(PERF_TARGET_BANDWIDTH) \
--env FICD_DM_VOLUME_GROUP=$(FICD_DM_VOLUME_GROUP) \
--env FICD_DM_POOL=$(FICD_DM_POOL) \
--env GOPROXY=direct \
--env GOSUMDB=off \
--workdir="/src/runtime" \
--init \
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
"go test -timeout 0 -v -count=1 -run \"^$(PERF_TESTNAME)$$\""
.PHONY: critest
critest:
$(CURDIR)/../tools/thinpool.sh reset "$(FICD_DM_POOL)"
docker run --rm -it \
--privileged \
--ipc=host \
--volume /dev:/dev \
--volume /run/udev/control:/run/udev/control \
--volume $(CURDIR)/..:/src \
--volume $(CURDIR)/../examples/etc/containerd/firecracker-runtime.json:/etc/containerd/firecracker-runtime.json \
--volume $(CURDIR)/../tools/demo/fc-br0.interface:/etc/network/interfaces.d/fc-br0 \
--volume $(CURDIR)/logs:/var/log/firecracker-containerd-test \
--volume $(CURDIR)/../tools/critest:/src/runtime/critest \
--volume $(GO_CACHE_VOLUME_NAME):/go \
--env FICD_DM_VOLUME_GROUP=$(FICD_DM_VOLUME_GROUP) \
--env FICD_DM_POOL=$(FICD_DM_POOL) \
--env GOPROXY=direct \
--env GOSUMDB=off \
--env ACK_GINKGO_DEPRECATIONS=1.16.5 \
--workdir="/src/runtime" \
$(FIRECRACKER_CONTAINERD_TEST_IMAGE):$(DOCKER_IMAGE_TAG) \
"sleep 1 && critest -ginkgo.noColor -runtime-endpoint unix:///run/firecracker-containerd/containerd.sock | \
./critest/critest_diff.sh"
clean:
- rm -f containerd-shim-aws-firecracker
distclean: clean
- rm -rf logs
.PHONY: all runtime clean distclean install test integ-test