Merge pull request #93 from Random-Liu/cri-validation-presubmit
Add CRI validation test into presubmit test.
This commit is contained in:
commit
3b5e2789c5
21
.travis.yml
21
.travis.yml
@ -5,8 +5,21 @@ go:
|
||||
|
||||
sudo: required
|
||||
|
||||
install:
|
||||
services:
|
||||
- docker
|
||||
|
||||
before_install:
|
||||
# libseccomp in trusty is not new enough, need backports version.
|
||||
- sudo sh -c "echo 'deb http://archive.ubuntu.com/ubuntu trusty-backports main restricted universe multiverse' > /etc/apt/sources.list.d/backports.list"
|
||||
- sudo apt-get update
|
||||
|
||||
install:
|
||||
- sudo apt-get install btrfs-tools
|
||||
- sudo apt-get install libseccomp2/trusty-backports
|
||||
- sudo apt-get install libseccomp-dev/trusty-backports
|
||||
- docker run --rm -v /usr/local/bin:/target jpetazzo/nsenter
|
||||
- make install.tools
|
||||
- make install.deps
|
||||
|
||||
before_script:
|
||||
- export PATH=$HOME/gopath/bin:$PATH
|
||||
@ -16,3 +29,9 @@ script:
|
||||
- make verify
|
||||
- make binaries
|
||||
- make test
|
||||
- make test-cri
|
||||
after_script:
|
||||
# Abuse travis to preserve the log.
|
||||
# TODO(random-liu): Use prow for integration test.
|
||||
- cat /tmp/cri-containerd.log
|
||||
- cat /tmp/containerd.log
|
||||
|
15
Makefile
15
Makefile
@ -35,9 +35,11 @@ help:
|
||||
@echo " * 'install' - Install binaries to system locations"
|
||||
@echo " * 'binaries' - Build cri-containerd"
|
||||
@echo " * 'test' - Test cri-containerd"
|
||||
@echo " * 'test-cri' - Test cri-containerd with cri validation test"
|
||||
@echo " * 'clean' - Clean artifacts"
|
||||
@echo " * 'verify' - Execute the source code verification tools"
|
||||
@echo " * 'install.tools' - Installs tools used by verify"
|
||||
@echo " * 'install.tools' - Install tools used by verify"
|
||||
@echo " * 'install.deps' - Install dependencies of cri-containerd (containerd, runc, cni)"
|
||||
@echo " * 'uninstall' - Remove installed binaries from system locations"
|
||||
@echo " * 'version' - Print current cri-containerd release version"
|
||||
|
||||
@ -71,7 +73,10 @@ cri-containerd: check-gopath
|
||||
$(PROJECT)/cmd/cri-containerd
|
||||
|
||||
test:
|
||||
go test -timeout=10m -v -race ./pkg/... $(BUILD_TAGS)
|
||||
go test -timeout=10m -race ./pkg/... $(BUILD_TAGS)
|
||||
|
||||
test-cri:
|
||||
@./hack/test-cri.sh
|
||||
|
||||
clean:
|
||||
rm -f $(BUILD_DIR)/cri-containerd
|
||||
@ -84,6 +89,11 @@ install: check-gopath
|
||||
uninstall:
|
||||
rm -f $(BINDIR)/cri-containerd
|
||||
|
||||
.PHONY: install.deps
|
||||
|
||||
install.deps:
|
||||
@./hack/install-deps.sh
|
||||
|
||||
.PHONY: .gitvalidation
|
||||
# When this is running in travis, it will only check the travis commit range.
|
||||
# When running outside travis, it will check from $(EPOCH_TEST_COMMIT)..HEAD.
|
||||
@ -115,5 +125,6 @@ install.tools: .install.gitvalidation .install.gometalinter
|
||||
install \
|
||||
lint \
|
||||
test \
|
||||
test-cri \
|
||||
uninstall \
|
||||
version
|
||||
|
90
hack/install-deps.sh
Executable file
90
hack/install-deps.sh
Executable file
@ -0,0 +1,90 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License 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.
|
||||
|
||||
# Dependencies:
|
||||
# runc:
|
||||
# - libseccomp-dev(Ubuntu,Debian)/libseccomp-devel(Fedora, CentOS, RHEL). Note that
|
||||
# libseccomp in ubuntu <=trusty and debian <=jessie is not new enough, backport
|
||||
# is required.
|
||||
# - libapparmor-dev(Ubuntu,Debian)/libapparmor-devel(Fedora, CentOS, RHEL)
|
||||
# containerd:
|
||||
# - btrfs-tools(Ubuntu,Debian)/btrfs-progs-devel(Fedora, CentOS, RHEL)
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
. ${ROOT}/hack/versions
|
||||
|
||||
BUILD_IMAGE=golang:1.8
|
||||
RUNC_PKG=github.com/opencontainers/runc
|
||||
CNI_PKG=github.com/containernetworking/cni
|
||||
CNI_DIR=/opt/cni
|
||||
CNI_CONFIG_DIR=/etc/cni/net.d
|
||||
CONTAINERD_PKG=github.com/containerd/containerd
|
||||
|
||||
# Install runc
|
||||
go get -d ${RUNC_PKG}/...
|
||||
cd ${GOPATH}/src/${RUNC_PKG}
|
||||
git fetch --all
|
||||
git checkout ${RUNC_VERSION}
|
||||
make
|
||||
sudo make install
|
||||
which runc
|
||||
|
||||
# Install cni
|
||||
go get -d ${CNI_PKG}/...
|
||||
cd ${GOPATH}/src/${CNI_PKG}
|
||||
git fetch --all
|
||||
git checkout ${CNI_VERSION}
|
||||
./build
|
||||
sudo mkdir -p ${CNI_DIR}
|
||||
sudo cp -r ./bin ${CNI_DIR}
|
||||
sudo mkdir -p ${CNI_CONFIG_DIR}
|
||||
sudo bash -c 'cat >'${CNI_CONFIG_DIR}'/10-containerd-bridge.conf <<EOF
|
||||
{
|
||||
"cniVersion": "0.2.0",
|
||||
"name": "containerd-bridge",
|
||||
"type": "bridge",
|
||||
"bridge": "cni0",
|
||||
"isGateway": true,
|
||||
"ipMasq": true,
|
||||
"ipam": {
|
||||
"type": "host-local",
|
||||
"subnet": "10.88.0.0/16",
|
||||
"routes": [
|
||||
{ "dst": "0.0.0.0/0" }
|
||||
]
|
||||
}
|
||||
}
|
||||
EOF'
|
||||
sudo bash -c 'cat >'${CNI_CONFIG_DIR}'/99-loopback.conf <<EOF
|
||||
{
|
||||
"cniVersion": "0.2.0",
|
||||
"type": "loopback"
|
||||
}
|
||||
EOF'
|
||||
|
||||
# Install containerd
|
||||
go get -d ${CONTAINERD_PKG}/...
|
||||
cd ${GOPATH}/src/${CONTAINERD_PKG}
|
||||
git fetch --all
|
||||
git checkout ${CONTAINERD_VERSION}
|
||||
make
|
||||
sudo make install
|
||||
which containerd
|
||||
which containerd-shim
|
75
hack/test-cri.sh
Executable file
75
hack/test-cri.sh
Executable file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License 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 -o nounset
|
||||
set -o pipefail
|
||||
|
||||
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
|
||||
. ${ROOT}/hack/versions
|
||||
|
||||
# FOCUS focuses the test to run.
|
||||
FOCUS=${FOCUS:-}
|
||||
# SKIP skips the test to skip.
|
||||
SKIP=${SKIP:-"Streaming|RunAsUser|host port"}
|
||||
REPORT_DIR=${REPORT_DIR:-"/tmp"}
|
||||
|
||||
if [[ -z "${GOPATH}" ]]; then
|
||||
echo "GOPATH is not set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! "${PATH}" =~ (^|:)${GOPATH}/bin(|/)(:|$) ]]; then
|
||||
echo "GOPATH/bin is not in path"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -x ${ROOT}/_output/cri-containerd ]; then
|
||||
echo "cri-containerd is not built"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
CRITEST=critest
|
||||
CRITEST_PKG=github.com/kubernetes-incubator/cri-tools
|
||||
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock
|
||||
|
||||
# Install critest
|
||||
if [ ! -x "$(command -v ${CRITEST})" ]; then
|
||||
go get -d ${CRITEST_PKG}/...
|
||||
cd ${GOPATH}/src/${CRITEST_PKG}
|
||||
git fetch --all
|
||||
git checkout ${CRITEST_VERSION}
|
||||
make
|
||||
fi
|
||||
which ${CRITEST}
|
||||
|
||||
# Start containerd
|
||||
if [ ! -x "$(command -v containerd)" ]; then
|
||||
echo "containerd is not installed, please run hack/install-deps.sh"
|
||||
exit 1
|
||||
fi
|
||||
sudo pkill containerd
|
||||
sudo containerd &> ${REPORT_DIR}/containerd.log &
|
||||
|
||||
# Start cri-containerd
|
||||
cd ${ROOT}
|
||||
sudo _output/cri-containerd --alsologtostderr --v 4 &> ${REPORT_DIR}/cri-containerd.log &
|
||||
|
||||
# Run cri validation test
|
||||
sudo env PATH=${PATH} GOPATH=${GOPATH} ${CRITEST} --runtime-endpoint=${CRICONTAINERD_SOCK} --focus="${FOCUS}" --ginkgo-flags="--skip=\"${SKIP}\"" validation
|
||||
test_exit_code=$?
|
||||
|
||||
sudo pkill containerd
|
||||
|
||||
exit ${test_exit_code}
|
@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright 2014 The Kubernetes Authors.
|
||||
# Copyright 2017 The Kubernetes Authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
4
hack/versions
Normal file
4
hack/versions
Normal file
@ -0,0 +1,4 @@
|
||||
RUNC_VERSION=639454475cb9c8b861cc599f8bcd5c8c790ae402
|
||||
CNI_VERSION=v0.4.0
|
||||
CONTAINERD_VERSION=8ed1e24ae925b5c6d8195858ee89dddb0507d65f
|
||||
CRITEST_VERSION=2d59bc793e71ee324895ca422e87a863435aa8cd
|
Loading…
Reference in New Issue
Block a user