Update makefile and all integration test

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu 2018-03-05 19:14:14 +00:00
parent d1e9960180
commit 05bcc3e88c
10 changed files with 59 additions and 97 deletions

View File

@ -35,27 +35,15 @@ jobs:
- make install.tools - make install.tools
- make .gitvalidation - make .gitvalidation
- make binaries - make binaries
- make containerd
go: "1.10" go: "1.10"
- stage: Test - stage: Test
script: script:
- make install.deps - make install.deps
- make containerd
- sudo make install-containerd
- make test - make test
- make test-integration - make test-integration
- make test-cri - make test-cri
after_script:
# Abuse travis to preserve the log.
- cat /tmp/test-integration/cri-containerd.log
- cat /tmp/test-integration/containerd.log
- cat /tmp/test-cri/cri-containerd.log
- cat /tmp/test-cri/containerd.log
go: "1.10"
- script:
- make install.deps
- make containerd
- sudo make install-containerd
- make test-integration STANDALONE_CRI_CONTAINERD=false
- make test-cri STANDALONE_CRI_CONTAINERD=false
after_script: after_script:
# Abuse travis to preserve the log. # Abuse travis to preserve the log.
- cat /tmp/test-integration/containerd.log - cat /tmp/test-integration/containerd.log

View File

@ -41,12 +41,14 @@ help:
@echo "Usage: make <target>" @echo "Usage: make <target>"
@echo @echo
@echo " * 'install' - Install binaries to system locations" @echo " * 'install' - Install binaries to system locations"
@echo " * 'binaries' - Build cri-containerd and ctrcri" @echo " * 'binaries' - Build containerd and ctrcri"
@echo " * 'static-binaries - Build static cri-containerd and ctrcri" @echo " * 'static-binaries - Build static containerd and ctrcri"
@echo " * 'ctrcri' - Build ctrcri"
@echo " * 'install-ctrcri' - Install ctrcri"
@echo " * 'containerd' - Build a customized containerd with CRI plugin for testing"
@echo " * 'install-containerd' - Install customized containerd to system location"
@echo " * 'release' - Build release tarball" @echo " * 'release' - Build release tarball"
@echo " * 'push' - Push release tarball to GCS" @echo " * 'push' - Push release tarball to GCS"
@echo " * 'containerd' - Build a customized containerd with CRI plugin for testing"
@echo " * 'install-containerd' - Install customized containerd to system location"
@echo " * 'test' - Test cri-containerd with unit test" @echo " * 'test' - Test cri-containerd with unit test"
@echo " * 'test-integration' - Test cri-containerd with integration test" @echo " * 'test-integration' - Test cri-containerd with integration test"
@echo " * 'test-cri' - Test cri-containerd with cri validation test" @echo " * 'test-cri' - Test cri-containerd with cri validation test"
@ -89,13 +91,6 @@ sync-vendor:
update-vendor: sync-vendor sort-vendor update-vendor: sync-vendor sort-vendor
$(BUILD_DIR)/cri-containerd: $(SOURCES)
$(GO) build -o $@ \
-tags '$(BUILD_TAGS)' \
-ldflags '$(GO_LDFLAGS)' \
-gcflags '$(GO_GCFLAGS)' \
$(PROJECT)/cmd/cri-containerd
$(BUILD_DIR)/ctrcri: $(SOURCES) $(BUILD_DIR)/ctrcri: $(SOURCES)
$(GO) build -o $@ \ $(GO) build -o $@ \
-tags '$(BUILD_TAGS)' \ -tags '$(BUILD_TAGS)' \
@ -131,17 +126,25 @@ test-e2e-node: binaries
clean: clean:
rm -rf $(BUILD_DIR)/* rm -rf $(BUILD_DIR)/*
binaries: $(BUILD_DIR)/cri-containerd $(BUILD_DIR)/ctrcri binaries: $(BUILD_DIR)/containerd $(BUILD_DIR)/ctrcri
static-binaries: GO_LDFLAGS += -extldflags "-fno-PIC -static" static-binaries: GO_LDFLAGS += -extldflags "-fno-PIC -static"
static-binaries: $(BUILD_DIR)/cri-containerd $(BUILD_DIR)/ctrcri static-binaries: $(BUILD_DIR)/containerd $(BUILD_DIR)/ctrcri
install: binaries ctrcri: $(BUILD_DIR)/ctrcri
install -D -m 755 $(BUILD_DIR)/cri-containerd $(BINDIR)/cri-containerd
install-ctrcri: ctrcri
install -D -m 755 $(BUILD_DIR)/ctrcri $(BINDIR)/ctrcri install -D -m 755 $(BUILD_DIR)/ctrcri $(BINDIR)/ctrcri
containerd: $(BUILD_DIR)/containerd
install-containerd: containerd
install -D -m 755 $(BUILD_DIR)/containerd $(BINDIR)/containerd
install: install-ctrcri install-containerd
uninstall: uninstall:
rm -f $(BINDIR)/cri-containerd rm -f $(BINDIR)/containerd
rm -f $(BINDIR)/ctrcri rm -f $(BINDIR)/ctrcri
$(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf $(BUILD_DIR)/$(TARBALL): static-binaries vendor.conf
@ -152,11 +155,6 @@ release: $(BUILD_DIR)/$(TARBALL)
push: $(BUILD_DIR)/$(TARBALL) push: $(BUILD_DIR)/$(TARBALL)
@BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/push.sh @BUILD_DIR=$(BUILD_DIR) TARBALL=$(TARBALL) VERSION=$(VERSION) ./hack/push.sh
containerd: $(BUILD_DIR)/containerd
install-containerd: containerd
install -D -m 755 $(BUILD_DIR)/containerd $(BINDIR)/containerd
proto: proto:
@hack/update-proto.sh @hack/update-proto.sh
@ -189,6 +187,10 @@ install.tools: .install.gitvalidation .install.gometalinter
.PHONY: \ .PHONY: \
binaries \ binaries \
static-binaries \ static-binaries \
ctrcri \
install-ctrcri \
containerd \
install-containerd \
release \ release \
push \ push \
boiler \ boiler \
@ -198,8 +200,6 @@ install.tools: .install.gitvalidation .install.gometalinter
help \ help \
install \ install \
lint \ lint \
containerd \
install-containerd \
test \ test \
test-integration \ test-integration \
test-cri \ test-cri \

View File

@ -133,8 +133,7 @@ fi
# Install containerd # Install containerd
checkout_repo ${CONTAINERD_PKG} ${CONTAINERD_VERSION} ${CONTAINERD_REPO} checkout_repo ${CONTAINERD_PKG} ${CONTAINERD_VERSION} ${CONTAINERD_REPO}
cd ${GOPATH}/src/${CONTAINERD_PKG} cd ${GOPATH}/src/${CONTAINERD_PKG}
# Build no_cri version and run standalone cri-containerd. make BUILDTAGS="${BUILDTAGS}"
make BUILDTAGS="${BUILDTAGS} no_cri"
# containerd make install requires `go` to work. Explicitly # containerd make install requires `go` to work. Explicitly
# set PATH to make sure it can find `go` even with `sudo`. # set PATH to make sure it can find `go` even with `sudo`.
${sudo} sh -c "PATH=${PATH} make install -e DESTDIR=${CONTAINERD_DIR}" ${sudo} sh -c "PATH=${PATH} make install -e DESTDIR=${CONTAINERD_DIR}"
@ -146,7 +145,7 @@ make crictl
${sudo} make install-crictl -e BINDIR=${CRICTL_DIR} GOPATH=${GOPATH} ${sudo} make install-crictl -e BINDIR=${CRICTL_DIR} GOPATH=${GOPATH}
${sudo} mkdir -p ${CRICTL_CONFIG_DIR} ${sudo} mkdir -p ${CRICTL_CONFIG_DIR}
${sudo} bash -c 'cat >'${CRICTL_CONFIG_DIR}'/crictl.yaml <<EOF ${sudo} bash -c 'cat >'${CRICTL_CONFIG_DIR}'/crictl.yaml <<EOF
runtime-endpoint: /var/run/cri-containerd.sock runtime-endpoint: /run/containerd/containerd.sock
EOF' EOF'
# Clean the tmp GOPATH dir. Use sudo because runc build generates # Clean the tmp GOPATH dir. Use sudo because runc build generates

View File

@ -28,21 +28,31 @@ TARBALL=${TARBALL:-"cri-containerd.tar.gz"}
# INCLUDE_CNI indicates whether to install CNI. By default don't # INCLUDE_CNI indicates whether to install CNI. By default don't
# include CNI in release tarball. # include CNI in release tarball.
INCLUDE_CNI=${INCLUDE_CNI:-false} INCLUDE_CNI=${INCLUDE_CNI:-false}
# CUSTOM_CONTAINERD indicates whether to install customized containerd
# for CI test.
CUSTOM_CONTAINERD=${CUSTOM_CONTAINERD:-false}
destdir=${BUILD_DIR}/release-stage destdir=${BUILD_DIR}/release-stage
# Remove release-stage directory to avoid including old files.
rm -rf ${destdir}
# Install dependencies into release stage. # Install dependencies into release stage.
NOSUDO=true INSTALL_CNI=${INCLUDE_CNI} DESTDIR=${destdir} ./hack/install-deps.sh NOSUDO=true INSTALL_CNI=${INCLUDE_CNI} DESTDIR=${destdir} ./hack/install-deps.sh
# Install cri-containerd into release stage. # Install ctrcri into release stage.
make install -e DESTDIR=${destdir} make install-ctrcri -e DESTDIR=${destdir}
if ${CUSTOM_CONTAINERD}; then
make install-containerd -e DESTDIR=${destdir}
fi
# Install systemd units into release stage. # Install systemd units into release stage.
mkdir -p ${destdir}/etc/systemd/system mkdir -p ${destdir}/etc/systemd/system
cp ${ROOT}/contrib/systemd-units/* ${destdir}/etc/systemd/system/ cp ${ROOT}/contrib/systemd-units/* ${destdir}/etc/systemd/system/
# Install cluster directory into release stage. # Install cluster directory into release stage.
mkdir -p ${destdir}/opt/cri-containerd mkdir -p ${destdir}/opt/containerd
cp -r ${ROOT}/cluster ${destdir}/opt/cri-containerd cp -r ${ROOT}/cluster ${destdir}/opt/containerd
# Create release tar # Create release tar
tarball=${BUILD_DIR}/${TARBALL} tarball=${BUILD_DIR}/${TARBALL}

View File

@ -52,7 +52,7 @@ mkdir -p ${REPORT_DIR}
test_setup ${REPORT_DIR} test_setup ${REPORT_DIR}
# Run cri validation test # Run cri validation test
sudo env PATH=${PATH} GOPATH=${GOPATH} ${CRITEST} --runtime-endpoint=${CRICONTAINERD_SOCK} --focus="${FOCUS}" --ginkgo-flags="--skip=\"${SKIP}\" --nodes=8" validation sudo env PATH=${PATH} GOPATH=${GOPATH} ${CRITEST} --runtime-endpoint=${CONTAINERD_SOCK} --focus="${FOCUS}" --ginkgo-flags="--skip=\"${SKIP}\" --nodes=8" validation
test_exit_code=$? test_exit_code=$?
test_teardown test_teardown

View File

@ -74,7 +74,7 @@ test_setup ${REPORT_DIR}
timeout "${TIMEOUT}" make test-e2e-node \ timeout "${TIMEOUT}" make test-e2e-node \
RUNTIME=remote \ RUNTIME=remote \
CONTAINER_RUNTIME_ENDPOINT=unix://${CRICONTAINERD_SOCK} \ CONTAINER_RUNTIME_ENDPOINT=unix://${CONTAINERD_SOCK} \
ARTIFACTS=${REPORT_DIR} \ ARTIFACTS=${REPORT_DIR} \
TEST_ARGS='--kubelet-flags=--cgroups-per-qos=true \ TEST_ARGS='--kubelet-flags=--cgroups-per-qos=true \
--kubelet-flags=--cgroup-root=/ \ --kubelet-flags=--cgroup-root=/ \

View File

@ -25,21 +25,15 @@ FOCUS=${FOCUS:-""}
# REPORT_DIR is the the directory to store test logs. # REPORT_DIR is the the directory to store test logs.
REPORT_DIR=${REPORT_DIR:-"/tmp/test-integration"} REPORT_DIR=${REPORT_DIR:-"/tmp/test-integration"}
CRICONTAINERD_ROOT="/var/lib/cri-containerd" CRI_ROOT="/var/lib/containerd/io.containerd.grpc.v1.cri"
if ! ${STANDALONE_CRI_CONTAINERD}; then
CRICONTAINERD_ROOT="/var/lib/containerd/io.containerd.grpc.v1.cri"
fi
mkdir -p ${REPORT_DIR} mkdir -p ${REPORT_DIR}
test_setup ${REPORT_DIR} test_setup ${REPORT_DIR}
# Run integration test. # Run integration test.
# Set STANDALONE_CRI_CONTAINERD so that integration test can see it.
# Some integration test needs the env to skip itself.
sudo ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v \ sudo ${ROOT}/_output/integration.test --test.run="${FOCUS}" --test.v \
--standalone-cri-containerd=${STANDALONE_CRI_CONTAINERD} \ --cri-endpoint=${CONTAINERD_SOCK} \
--cri-containerd-endpoint=${CRICONTAINERD_SOCK} \ --cri-root=${CRI_ROOT}
--cri-containerd-root=${CRICONTAINERD_ROOT}
test_exit_code=$? test_exit_code=$?

View File

@ -16,63 +16,36 @@
source $(dirname "${BASH_SOURCE[0]}")/utils.sh source $(dirname "${BASH_SOURCE[0]}")/utils.sh
# CRI_CONTAINERD_FLAGS are the extra flags to use when start cri-containerd. # RESTART_WAIT_PERIOD is the period to wait before restarting containerd.
CRI_CONTAINERD_FLAGS=${CRI_CONTAINERD_FLAGS:-""}
# RESTART_WAIT_PERIOD is the period to wait before restarting cri-containerd/containerd.
RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10} RESTART_WAIT_PERIOD=${RESTART_WAIT_PERIOD:-10}
# STANDALONE_CRI_CONTAINERD indicates whether to run standalone cri-containerd.
STANDALONE_CRI_CONTAINERD=${STANDALONE_CRI_CONTAINERD:-true}
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock CONTAINERD_SOCK=/run/containerd/containerd.sock
if ! ${STANDALONE_CRI_CONTAINERD}; then
CRICONTAINERD_SOCK=/var/run/containerd/containerd.sock
fi
cri_containerd_pid=
containerd_pid= containerd_pid=
# test_setup starts containerd and cri-containerd. # test_setup starts containerd.
test_setup() { test_setup() {
local report_dir=$1 local report_dir=$1
if [ ! -x ${ROOT}/_output/cri-containerd ]; then
echo "cri-containerd is not built"
exit 1
fi
# Start containerd # Start containerd
local containerd=$(command -v containerd) if [ ! -x ${ROOT}/_output/containerd ]; then
if [ ! -x "${containerd}" ]; then echo "containerd is not built"
echo "containerd is not installed, please run hack/install-deps.sh"
exit 1 exit 1
fi fi
sudo pkill -x cri-containerd
sudo pkill -x containerd sudo pkill -x containerd
echo "using ${containerd}" keepalive "sudo ${ROOT}/_output/containerd --log-level=debug" \
echo "containerd version: $(${containerd} --version)" ${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
keepalive "sudo ${containerd}" ${RESTART_WAIT_PERIOD} &> ${report_dir}/containerd.log &
containerd_pid=$! containerd_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
readiness_check "sudo ctr version" readiness_check "sudo ctr version"
readiness_check "sudo ${GOPATH}/bin/crictl --runtime-endpoint=${CONTAINERD_SOCK} info"
# Start cri-containerd
if ${STANDALONE_CRI_CONTAINERD}; then
keepalive "sudo ${ROOT}/_output/cri-containerd --log-level=debug ${CRI_CONTAINERD_FLAGS}" \
${RESTART_WAIT_PERIOD} &> ${report_dir}/cri-containerd.log &
cri_containerd_pid=$!
fi
readiness_check "sudo ${GOPATH}/bin/crictl --runtime-endpoint=${CRICONTAINERD_SOCK} info"
} }
# test_teardown kills containerd and cri-containerd. # test_teardown kills containerd.
test_teardown() { test_teardown() {
if [ -n "${containerd_pid}" ]; then if [ -n "${containerd_pid}" ]; then
kill ${containerd_pid} kill ${containerd_pid}
fi fi
if [ -n "${cri_containerd_pid}" ]; then
kill ${cri_containerd_pid}
fi
sudo pkill -x cri-containerd
sudo pkill -x containerd sudo pkill -x containerd
} }

View File

@ -341,5 +341,4 @@ func testStats(t *testing.T,
require.NotEmpty(t, s.GetWritableLayer().GetFsId().GetMountpoint()) require.NotEmpty(t, s.GetWritableLayer().GetFsId().GetMountpoint())
require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue()) require.NotEmpty(t, s.GetWritableLayer().GetUsedBytes().GetValue())
require.NotEmpty(t, s.GetWritableLayer().GetInodesUsed().GetValue()) require.NotEmpty(t, s.GetWritableLayer().GetInodesUsed().GetValue())
} }

View File

@ -50,9 +50,8 @@ var (
criContainerdClient api.CRIContainerdServiceClient criContainerdClient api.CRIContainerdServiceClient
) )
var standaloneCRIContainerd = flag.Bool("standalone-cri-containerd", true, "Whether cri-containerd is running in standalone mode.") var criContainerdEndpoint = flag.String("cri-endpoint", "/run/containerd/containerd.sock", "The endpoint of cri plugin.")
var criContainerdEndpoint = flag.String("cri-containerd-endpoint", "/var/run/cri-containerd.sock", "The endpoint of cri-containerd.") var criContainerdRoot = flag.String("cri-root", "/var/lib/containerd/io.containerd.grpc.v1.cri", "The root directory of cri plugin.")
var criContainerdRoot = flag.String("cri-containerd-root", "/var/lib/cri-containerd", "The root directory of cri-containerd.")
func init() { func init() {
flag.Parse() flag.Parse()
@ -61,7 +60,7 @@ func init() {
} }
} }
// ConnectDaemons connect cri-containerd and containerd, and initialize the clients. // ConnectDaemons connect cri plugin and containerd, and initialize the clients.
func ConnectDaemons() error { func ConnectDaemons() error {
var err error var err error
runtimeService, err = remote.NewRemoteRuntimeService(*criContainerdEndpoint, timeout) runtimeService, err = remote.NewRemoteRuntimeService(*criContainerdEndpoint, timeout)
@ -89,7 +88,7 @@ func ConnectDaemons() error {
} }
criContainerdClient, err = client.NewCRIContainerdClient(*criContainerdEndpoint, timeout) criContainerdClient, err = client.NewCRIContainerdClient(*criContainerdEndpoint, timeout)
if err != nil { if err != nil {
return fmt.Errorf("failed to connect cri-containerd: %v", err) return fmt.Errorf("failed to connect cri plugin: %v", err)
} }
return nil return nil
} }