Merge pull request #4639 from mikebrow/enable-cri-integration

getting cri integration up and running
This commit is contained in:
Derek McGowan 2020-10-19 14:55:19 -07:00 committed by GitHub
commit b8ed26b66c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 16 deletions

View File

@ -368,7 +368,12 @@ jobs:
sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 make integration EXTRA_TESTFLAGS=-no-criu sudo GOPATH=$GOPATH GOPROXY=$GOPROXY TEST_RUNTIME=$TEST_RUNTIME RUNC_FLAVOR=$RUNC_FLAVOR TESTFLAGS_PARALLEL=1 make integration EXTRA_TESTFLAGS=-no-criu
working-directory: src/github.com/containerd/containerd working-directory: src/github.com/containerd/containerd
- name: CRI test - name: CRI Integration Test
run: |
make cri-integration
working-directory: src/github.com/containerd/containerd
- name: cri-tools critest
env: env:
TEST_RUNTIME: ${{ matrix.runtime }} TEST_RUNTIME: ${{ matrix.runtime }}
run: | run: |

View File

@ -125,7 +125,7 @@ TESTFLAGS_PARALLEL ?= 8
OUTPUTDIR = $(join $(ROOTDIR), _output) OUTPUTDIR = $(join $(ROOTDIR), _output)
CRIDIR=$(OUTPUTDIR)/cri CRIDIR=$(OUTPUTDIR)/cri
.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 .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
.DEFAULT: default .DEFAULT: default
all: binaries all: binaries
@ -182,6 +182,16 @@ integration: ## run integration tests
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@go test ${TESTFLAGS} -test.root -parallel ${TESTFLAGS_PARALLEL} @go test ${TESTFLAGS} -test.root -parallel ${TESTFLAGS_PARALLEL}
# TODO integrate cri integration bucket with coverage
bin/cri-integration.test:
@echo "$(WHALE) $@"
@go test -c ./integration -o bin/cri-integration.test
cri-integration: binaries bin/cri-integration.test ## run cri integration tests
@echo "$(WHALE) $@"
@./hack/test-cri-integration.sh
@rm -rf bin/cri-integration.test
benchmark: ## run benchmarks tests benchmark: ## run benchmarks tests
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@go test ${TESTFLAGS} -bench . -run Benchmark -test.root @go test ${TESTFLAGS} -bench . -run Benchmark -test.root
@ -309,6 +319,7 @@ clean: ## clean up binaries
@rm -f $(BINARIES) @rm -f $(BINARIES)
@rm -f releases/*.tar.gz* @rm -f releases/*.tar.gz*
@rm -rf $(OUTPUTDIR) @rm -rf $(OUTPUTDIR)
@rm -rf bin/cri-integration.test
clean-test: ## clean up debris from previously failed tests clean-test: ## clean up debris from previously failed tests
@echo "$(WHALE) $@" @echo "$(WHALE) $@"
@ -323,6 +334,7 @@ clean-test: ## clean up debris from previously failed tests
@rm -rf /run/containerd/runc/* @rm -rf /run/containerd/runc/*
@rm -rf /run/containerd/fifo/* @rm -rf /run/containerd/fifo/*
@rm -rf /run/containerd-test/* @rm -rf /run/containerd-test/*
@rm -rf bin/cri-integration.test
install: ## install binaries install: ## install binaries
@echo "$(WHALE) $@ $(BINARIES)" @echo "$(WHALE) $@ $(BINARIES)"

View File

@ -33,7 +33,7 @@ mkdir -p ${REPORT_DIR}
test_setup ${REPORT_DIR} test_setup ${REPORT_DIR}
# Run integration test. # Run integration test.
sudo PATH=${PATH} ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v \ sudo PATH=${PATH} bin/cri-integration.test --test.run="${FOCUS}" --test.v \
--cri-endpoint=${CONTAINERD_SOCK} \ --cri-endpoint=${CONTAINERD_SOCK} \
--cri-root=${CRI_ROOT} \ --cri-root=${CRI_ROOT} \
--runtime-handler=${RUNTIME} \ --runtime-handler=${RUNTIME} \

View File

@ -42,7 +42,7 @@ CONTAINERD_STATE=${CONTAINERD_STATE:-"/run/containerd${CONTAINERD_TEST_SUFFIX}"}
# The containerd socket address. # The containerd socket address.
CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock} CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock}
# The containerd binary name. # The containerd binary name.
CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd${CONTAINERD_TEST_SUFFIX}"} CONTAINERD_BIN=${CONTAINERD_BIN:-"containerd"} # don't need a suffix now
if [ -f "${CONTAINERD_CONFIG_FILE}" ]; then if [ -f "${CONTAINERD_CONFIG_FILE}" ]; then
CONTAINERD_FLAGS+="--config ${CONTAINERD_CONFIG_FILE} " CONTAINERD_FLAGS+="--config ${CONTAINERD_CONFIG_FILE} "
fi fi
@ -56,34 +56,26 @@ containerd_groupid=
test_setup() { test_setup() {
local report_dir=$1 local report_dir=$1
# Start containerd # Start containerd
if [ ! -x "${ROOT}/_output/containerd" ]; then if [ ! -x "bin/containerd" ]; then
echo "containerd is not built" echo "containerd is not built"
exit 1 exit 1
fi fi
# rename the test containerd binary, so that we can easily
# distinguish it.
cp ${ROOT}/_output/containerd ${ROOT}/_output/${CONTAINERD_BIN}
set -m set -m
# Create containerd in a different process group # Create containerd in a different process group
# so that we can easily clean them up. # so that we can easily clean them up.
keepalive "sudo PATH=${PATH} ${ROOT}/_output/${CONTAINERD_BIN} ${CONTAINERD_FLAGS}" \ keepalive "sudo PATH=${PATH} bin/containerd ${CONTAINERD_FLAGS}" \
${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log & ${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
pid=$! pid=$!
set +m set +m
containerd_groupid=$(ps -o pgid= -p ${pid}) containerd_groupid=$(ps -o pgid= -p ${pid})
# Wait for containerd to be running by using the containerd client ctr to check the version # Wait for containerd to be running by using the containerd client ctr to check the version
# of the containerd server. Wait an increasing amount of time after each of five attempts # of the containerd server. Wait an increasing amount of time after each of five attempts
local -r ctr_path=$(which ctr)
if [ -z "${ctr_path}" ]; then
echo "ctr is not in PATH"
exit 1
fi
local -r crictl_path=$(which crictl) local -r crictl_path=$(which crictl)
if [ -z "${crictl_path}" ]; then if [ -z "${crictl_path}" ]; then
echo "crictl is not in PATH" echo "crictl is not in PATH"
exit 1 exit 1
fi fi
readiness_check "sudo ${ctr_path} --address ${CONTAINERD_SOCK#"unix://"} version" readiness_check "sudo bin/ctr --address ${CONTAINERD_SOCK#"unix://"} version"
readiness_check "sudo ${crictl_path} --runtime-endpoint=${CONTAINERD_SOCK} info" readiness_check "sudo ${crictl_path} --runtime-endpoint=${CONTAINERD_SOCK} info"
} }

View File

@ -335,7 +335,7 @@ func KillPid(pid int) error {
// PidOf returns pid of a process by name. // PidOf returns pid of a process by name.
func PidOf(name string) (int, error) { func PidOf(name string) (int, error) {
b, err := exec.Command("pidof", name).CombinedOutput() b, err := exec.Command("pidof", "-s", name).CombinedOutput()
output := strings.TrimSpace(string(b)) output := strings.TrimSpace(string(b))
if err != nil { if err != nil {
if len(output) != 0 { if len(output) != 0 {