Add node e2e test CI.

Signed-off-by: Lantao Liu <lantaol@google.com>
This commit is contained in:
Lantao Liu
2017-08-20 07:36:55 +00:00
parent dcc3cb2a05
commit c05a7e74ee
12 changed files with 166 additions and 79 deletions

View File

@@ -16,31 +16,20 @@
set -o nounset
set -o pipefail
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
. ${ROOT}/hack/versions
source $(dirname "${BASH_SOURCE[0]}")/test-utils.sh
# FOCUS focuses the test to run.
FOCUS=${FOCUS:-}
# SKIP skips the test to skip.
SKIP=${SKIP:-"attach|RunAsUser|host port"}
REPORT_DIR=${REPORT_DIR:-"/tmp"}
REPORT_DIR=${REPORT_DIR:-"/tmp/test-cri"}
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=${GOPATH}/bin/critest
CRITEST_PKG=github.com/kubernetes-incubator/cri-tools
CRICONTAINERD_SOCK=/var/run/cri-containerd.sock
@@ -54,32 +43,13 @@ if [ ! -x "$(command -v ${CRITEST})" ]; then
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 -l debug &> ${REPORT_DIR}/containerd.log &
# 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
MAX_ATTEMPTS=5
attempt_num=1
until sudo ctr version &> /dev/null || (( attempt_num == MAX_ATTEMPTS ))
do
echo "Attempt $attempt_num to connect to containerd failed! Trying again in $attempt_num seconds..."
sleep $(( attempt_num++ ))
done
# Start cri-containerd
cd ${ROOT}
sudo _output/cri-containerd --alsologtostderr --v 4 &> ${REPORT_DIR}/cri-containerd.log &
mkdir -p ${REPORT_DIR}
start_cri_containerd ${REPORT_DIR}
# 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
kill_cri_containerd
exit ${test_exit_code}

61
hack/test-e2e-node.sh Executable file
View File

@@ -0,0 +1,61 @@
#!/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
source $(dirname "${BASH_SOURCE[0]}")/test-utils.sh
DEFAULT_SKIP="\[Flaky\]|\[Slow\]|\[Serial\]"
DEFAULT_SKIP+="|runAsUser"
DEFAULT_SKIP+="|scheduling\sa\sGuaranteed\sPod"
DEFAULT_SKIP+="|scheduling\sa\sBurstable\sPod"
DEFAULT_SKIP+="|AllowPrivilegeEscalation"
DEFAULT_SKIP+="|scheduling\sa\sBestEffort\sPod"
DEFAULT_SKIP+="|querying\s\/stats\/summary"
DEFAULT_SKIP+="|set\sto\sthe\smanifest\sdigest"
DEFAULT_SKIP+="|AppArmor"
DEFAULT_SKIP+="|Top\slevel\sQoS\scontainers"
DEFAULT_SKIP+="|pull\sfrom\sprivate\sregistry\swith\ssecret"
# FOCUS focuses the test to run.
export FOCUS=${FOCUS:-""}
# SKIP skips the test to skip.
export SKIP=${SKIP:-${DEFAULT_SKIP}}
REPORT_DIR=${REPORT_DIR:-"/tmp/test-e2e-node"}
if [[ -z "${GOPATH}" ]]; then
echo "GOPATH is not set"
exit 1
fi
# Get kubernetes
KUBERNETES_REPO="https://github.com/kubernetes/kubernetes"
KUBERNETES_PATH="${GOPATH}/src/k8s.io/kubernetes"
if [ ! -d "${KUBERNETES_PATH}" ]; then
mkdir -p ${KUBERNETES_PATH}
cd ${KUBERNETES_PATH}
git clone ${KUBERNETES_REPO} .
fi
cd ${KUBERNETES_PATH}
git fetch --all
git checkout ${KUBERNETES_VERSION}
mkdir -p ${REPORT_DIR}
start_cri_containerd ${REPORT_DIR}
make test-e2e-node RUNTIME=remote CONTAINER_RUNTIME_ENDPOINT=unix:///var/run/cri-containerd.sock ARTIFACTS=${REPORT_DIR}
kill_cri_containerd

53
hack/test-utils.sh Normal file
View File

@@ -0,0 +1,53 @@
#!/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.
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
. ${ROOT}/hack/versions
# start_cri_containerd starts containerd and cri-containerd.
start_cri_containerd() {
local report_dir=$1
if [ ! -x ${ROOT}/_output/cri-containerd ]; then
echo "cri-containerd is not built"
exit 1
fi
# Start containerd
if [ ! -x "$(command -v containerd)" ]; then
echo "containerd is not installed, please run hack/install-deps.sh"
exit 1
fi
kill_cri_containerd
sudo containerd -l debug &> ${report_dir}/containerd.log &
# 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 MAX_ATTEMPTS=5
local attempt_num=1
until sudo ctr version &> /dev/null || (( attempt_num == MAX_ATTEMPTS ))
do
echo "attempt $attempt_num to connect to containerd failed! Trying again in $attempt_num seconds..."
sleep $(( attempt_num++ ))
done
# Start cri-containerd
sudo ${ROOT}/_output/cri-containerd --alsologtostderr --v 4 &> ${report_dir}/cri-containerd.log &
}
# kill_cri_containerd kills containerd and cri-containerd.
kill_cri_containerd() {
sudo pkill containerd
}

View File

@@ -2,3 +2,4 @@ RUNC_VERSION=e775f0fba3ea329b8b766451c892c41a3d49594d
CNI_VERSION=v0.4.0
CONTAINERD_VERSION=938810e706bbcdbcb937ce63ba3e7c9ca329af64
CRITEST_VERSION=74bbd4e142f752f13c648d9dde23defed3e472a2
KUBERNETES_VERSION=d779e9c9561b732adf06263c5424889e7564fdbd