Skip to content

Commit b8ed26b

Browse files
authored
Merge pull request #4639 from mikebrow/enable-cri-integration
getting cri integration up and running
2 parents f36f313 + c876b15 commit b8ed26b

5 files changed

Lines changed: 25 additions & 16 deletions

File tree

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,12 @@ jobs:
368368
sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 make integration EXTRA_TESTFLAGS=-no-criu
369369
working-directory: src/github.com/containerd/containerd
370370

371-
- name: CRI test
371+
- name: CRI Integration Test
372+
run: |
373+
make cri-integration
374+
working-directory: src/github.com/containerd/containerd
375+
376+
- name: cri-tools critest
372377
env:
373378
TEST_RUNTIME: ${{ matrix.runtime }}
374379
run: |

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ TESTFLAGS_PARALLEL ?= 8
125125
OUTPUTDIR = $(join $(ROOTDIR), _output)
126126
CRIDIR=$(OUTPUTDIR)/cri
127127

128-
.PHONY: clean all AUTHORS build binaries test integration generate protos checkprotos coverage ci check help install uninstall vendor release mandir install-man genman install-cri-deps cri-release cri-cni-release
128+
.PHONY: clean all AUTHORS build binaries test integration generate protos checkprotos coverage ci check help install uninstall vendor release mandir install-man genman install-cri-deps cri-release cri-cni-release cri-integration bin/cri-integration.test
129129
.DEFAULT: default
130130

131131
all: binaries
@@ -182,6 +182,16 @@ integration: ## run integration tests
182182
@echo "$(WHALE) $@"
183183
@go test ${TESTFLAGS} -test.root -parallel ${TESTFLAGS_PARALLEL}
184184

185+
# TODO integrate cri integration bucket with coverage
186+
bin/cri-integration.test:
187+
@echo "$(WHALE) $@"
188+
@go test -c ./integration -o bin/cri-integration.test
189+
190+
cri-integration: binaries bin/cri-integration.test ## run cri integration tests
191+
@echo "$(WHALE) $@"
192+
@./hack/test-cri-integration.sh
193+
@rm -rf bin/cri-integration.test
194+
185195
benchmark: ## run benchmarks tests
186196
@echo "$(WHALE) $@"
187197
@go test ${TESTFLAGS} -bench . -run Benchmark -test.root
@@ -309,6 +319,7 @@ clean: ## clean up binaries
309319
@rm -f $(BINARIES)
310320
@rm -f releases/*.tar.gz*
311321
@rm -rf $(OUTPUTDIR)
322+
@rm -rf bin/cri-integration.test
312323

313324
clean-test: ## clean up debris from previously failed tests
314325
@echo "$(WHALE) $@"
@@ -323,6 +334,7 @@ clean-test: ## clean up debris from previously failed tests
323334
@rm -rf /run/containerd/runc/*
324335
@rm -rf /run/containerd/fifo/*
325336
@rm -rf /run/containerd-test/*
337+
@rm -rf bin/cri-integration.test
326338

327339
install: ## install binaries
328340
@echo "$(WHALE) $@ $(BINARIES)"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ mkdir -p ${REPORT_DIR}
3333
test_setup ${REPORT_DIR}
3434

3535
# Run integration test.
36-
sudo PATH=${PATH} ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v \
36+
sudo PATH=${PATH} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
3737
--cri-endpoint=${CONTAINERD_SOCK} \
3838
--cri-root=${CRI_ROOT} \
3939
--runtime-handler=${RUNTIME} \

hack/test-utils.sh

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ CONTAINERD_STATE=${CONTAINERD_STATE:-"/run/containerd${CONTAINERD_TEST_SUFFIX}"}
4242
# The containerd socket address.
4343
CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock}
4444
# The containerd binary name.
45-
CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd${CONTAINERD_TEST_SUFFIX}"}
45+
CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd"} # don't need a suffix now
4646
if [ -f "${CONTAINERD_CONFIG_FILE}" ]; then
4747
CONTAINERD_FLAGS+="--config ${CONTAINERD_CONFIG_FILE} "
4848
fi
@@ -56,34 +56,26 @@ containerd_groupid=
5656
test_setup() {
5757
local report_dir=$1
5858
# Start containerd
59-
if [ ! -x "${ROOT}/_output/containerd" ]; then
59+
if [ ! -x "bin/containerd" ]; then
6060
echo "containerd is not built"
6161
exit 1
6262
fi
63-
# rename the test containerd binary, so that we can easily
64-
# distinguish it.
65-
cp ${ROOT}/_output/containerd ${ROOT}/_output/${CONTAINERD_BIN}
6663
set -m
6764
# Create containerd in a different process group
6865
# so that we can easily clean them up.
69-
keepalive "sudo PATH=${PATH} ${ROOT}/_output/${CONTAINERD_BIN} ${CONTAINERD_FLAGS}" \
66+
keepalive "sudo PATH=${PATH} bin/containerd ${CONTAINERD_FLAGS}" \
7067
${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
7168
pid=$!
7269
set +m
7370
containerd_groupid=$(ps -o pgid= -p ${pid})
7471
# Wait for containerd to be running by using the containerd client ctr to check the version
7572
# of the containerd server. Wait an increasing amount of time after each of five attempts
76-
local -r ctr_path=$(which ctr)
77-
if [ -z "${ctr_path}" ]; then
78-
echo "ctr is not in PATH"
79-
exit 1
80-
fi
8173
local -r crictl_path=$(which crictl)
8274
if [ -z "${crictl_path}" ]; then
8375
echo "crictl is not in PATH"
8476
exit 1
8577
fi
86-
readiness_check "sudo ${ctr_path} --address ${CONTAINERD_SOCK#"unix://"} version"
78+
readiness_check "sudo bin/ctr --address ${CONTAINERD_SOCK#"unix://"} version"
8779
readiness_check "sudo ${crictl_path} --runtime-endpoint=${CONTAINERD_SOCK} info"
8880
}
8981

integration/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ func KillPid(pid int) error {
335335

336336
// PidOf returns pid of a process by name.
337337
func PidOf(name string) (int, error) {
338-
b, err := exec.Command("pidof", name).CombinedOutput()
338+
b, err := exec.Command("pidof", "-s", name).CombinedOutput()
339339
output := strings.TrimSpace(string(b))
340340
if err != nil {
341341
if len(output) != 0 {

0 commit comments

Comments
 (0)