From c876b15b5414a9eb004df163e1645d67b6e7681d Mon Sep 17 00:00:00 2001 From: Mike Brown Date: Fri, 16 Oct 2020 19:21:10 -0500 Subject: [PATCH] getting cri integration up and running Signed-off-by: Mike Brown --- .github/workflows/ci.yml | 7 ++++++- Makefile | 14 +++++++++++++- ...st-integration.sh => test-cri-integration.sh} | 2 +- hack/test-utils.sh | 16 ++++------------ integration/main_test.go | 2 +- 5 files changed, 25 insertions(+), 16 deletions(-) rename hack/{test-integration.sh => test-cri-integration.sh} (93%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cffa30fb9..5679a122b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 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: TEST_RUNTIME: ${{ matrix.runtime }} run: | diff --git a/Makefile b/Makefile index a7906f8e2..d87e5e7d7 100644 --- a/Makefile +++ b/Makefile @@ -125,7 +125,7 @@ TESTFLAGS_PARALLEL ?= 8 OUTPUTDIR = $(join $(ROOTDIR), _output) 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 all: binaries @@ -182,6 +182,16 @@ integration: ## run integration tests @echo "$(WHALE) $@" @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 @echo "$(WHALE) $@" @go test ${TESTFLAGS} -bench . -run Benchmark -test.root @@ -309,6 +319,7 @@ clean: ## clean up binaries @rm -f $(BINARIES) @rm -f releases/*.tar.gz* @rm -rf $(OUTPUTDIR) + @rm -rf bin/cri-integration.test clean-test: ## clean up debris from previously failed tests @echo "$(WHALE) $@" @@ -323,6 +334,7 @@ clean-test: ## clean up debris from previously failed tests @rm -rf /run/containerd/runc/* @rm -rf /run/containerd/fifo/* @rm -rf /run/containerd-test/* + @rm -rf bin/cri-integration.test install: ## install binaries @echo "$(WHALE) $@ $(BINARIES)" diff --git a/hack/test-integration.sh b/hack/test-cri-integration.sh similarity index 93% rename from hack/test-integration.sh rename to hack/test-cri-integration.sh index 820d030ef..f584508f5 100755 --- a/hack/test-integration.sh +++ b/hack/test-cri-integration.sh @@ -33,7 +33,7 @@ mkdir -p ${REPORT_DIR} test_setup ${REPORT_DIR} # 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-root=${CRI_ROOT} \ --runtime-handler=${RUNTIME} \ diff --git a/hack/test-utils.sh b/hack/test-utils.sh index bde573b88..86a5e49fa 100755 --- a/hack/test-utils.sh +++ b/hack/test-utils.sh @@ -42,7 +42,7 @@ CONTAINERD_STATE=${CONTAINERD_STATE:-"/run/containerd${CONTAINERD_TEST_SUFFIX}"} # The containerd socket address. CONTAINERD_SOCK=${CONTAINERD_SOCK:-unix://${CONTAINERD_STATE}/containerd.sock} # 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 CONTAINERD_FLAGS+="--config ${CONTAINERD_CONFIG_FILE} " fi @@ -56,34 +56,26 @@ containerd_groupid= test_setup() { local report_dir=$1 # Start containerd - if [ ! -x "${ROOT}/_output/containerd" ]; then + if [ ! -x "bin/containerd" ]; then echo "containerd is not built" exit 1 fi - # rename the test containerd binary, so that we can easily - # distinguish it. - cp ${ROOT}/_output/containerd ${ROOT}/_output/${CONTAINERD_BIN} set -m # Create containerd in a different process group # 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 & pid=$! set +m containerd_groupid=$(ps -o pgid= -p ${pid}) # 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 - 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) if [ -z "${crictl_path}" ]; then echo "crictl is not in PATH" exit 1 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" } diff --git a/integration/main_test.go b/integration/main_test.go index 6c6112718..ac46449f8 100644 --- a/integration/main_test.go +++ b/integration/main_test.go @@ -335,7 +335,7 @@ func KillPid(pid int) error { // PidOf returns pid of a process by name. 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)) if err != nil { if len(output) != 0 {