-
Notifications
You must be signed in to change notification settings - Fork 950
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2198 from Starnop/cri-e2e-ci
test: add node e2e test in CI
- Loading branch information
Showing
8 changed files
with
312 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# keep the first one only | ||
GOPATH="${GOPATH%%:*}" | ||
|
||
# add bin folder into PATH. | ||
export PATH="${GOPATH}/bin:${PATH}" | ||
|
||
|
||
# cni::install_cni installs cni plugins. | ||
cni::install_cni() { | ||
echo "install cni..." | ||
|
||
local workdir pkg | ||
|
||
# for multiple GOPATHs, keep the first one only | ||
pkg="github.com/containernetworking/plugins" | ||
workdir="${GOPATH}/src/${pkg}" | ||
|
||
# downloads github.com/containernetworking/plugins | ||
go get -u -d "${pkg}"/... | ||
|
||
# build and copy into /opt/cni/bin | ||
"${workdir}"/build.sh | ||
mkdir -p /etc/cni/net.d /opt/cni/bin | ||
cp "${workdir}"/bin/* /opt/cni/bin | ||
|
||
# setup the config | ||
sh -c 'cat >/etc/cni/net.d/10-mynet.conflist <<-EOF | ||
{ | ||
"cniVersion": "0.3.1", | ||
"name": "mynet", | ||
"plugins": [ | ||
{ | ||
"type": "bridge", | ||
"bridge": "cni0", | ||
"isGateway": true, | ||
"ipMasq": true, | ||
"ipam": { | ||
"type": "host-local", | ||
"subnet": "10.30.0.0/16", | ||
"routes": [ | ||
{ "dst": "0.0.0.0/0" } | ||
] | ||
} | ||
}, | ||
{ | ||
"type": "portmap", | ||
"capabilities": {"portMappings": true}, | ||
"snat": true | ||
} | ||
] | ||
} | ||
EOF' | ||
|
||
sh -c 'cat >/etc/cni/net.d/99-loopback.conf <<-EOF | ||
{ | ||
"cniVersion": "0.3.1", | ||
"type": "loopback" | ||
} | ||
EOF' | ||
|
||
echo | ||
} | ||
|
||
main() { | ||
cni::install_cni | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
ETCD_VERSION=v3.3.5 | ||
ARCH=amd64 | ||
|
||
# keep the first one only | ||
GOPATH="${GOPATH%%:*}" | ||
|
||
# add bin folder into PATH. | ||
export PATH="${GOPATH}/bin:${PATH}" | ||
|
||
# etcd::check_version checks the command and the version. | ||
etcd::check_version() { | ||
local has_installed | ||
|
||
has_installed="$(command -v etcd || echo false)" | ||
if [[ "${has_installed}" = "false" ]]; then | ||
echo false | ||
exit 0 | ||
fi | ||
|
||
echo true | ||
} | ||
|
||
# etcd::install downloads the package and build. | ||
etcd::install() { | ||
wget --quiet "https://github.com/coreos/etcd/releases/download/${ETCD_VERSION}/etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz" | ||
tar -xf "etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz" -C "/usr/local" | ||
rm etcd-${ETCD_VERSION}-linux-${ARCH}.tar.gz | ||
export PATH="/usr/local/etcd-${ETCD_VERSION}-linux-${ARCH}:${PATH}" | ||
} | ||
|
||
main() { | ||
local has_installed | ||
|
||
has_installed="$(etcd::check_version)" | ||
if [[ "${has_installed}" = "true" ]]; then | ||
echo "etcd-${ETCD_VERSION} has been installed." | ||
exit 0 | ||
fi | ||
|
||
echo ">>>> install etcd-${ETCD_VERSION} <<<<" | ||
etcd::install | ||
|
||
command -v etcd > /dev/null | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
# keep the first one only | ||
GOPATH="${GOPATH%%:*}" | ||
|
||
# add bin folder into PATH. | ||
export PATH="${GOPATH}/bin:${PATH}" | ||
|
||
|
||
# ginkgo::install_ginkgo installs ginkgo if missing. | ||
ginkgo::install_ginkgo() { | ||
local has_installed pkg | ||
|
||
pkg="github.com/onsi/ginkgo/ginkgo" | ||
has_installed="$(command -v ginkgo || echo false)" | ||
if [[ "${has_installed}" = "false" ]]; then | ||
go get -u "${pkg}" | ||
fi | ||
|
||
command -v ginkgo > /dev/null | ||
} | ||
|
||
main() { | ||
ginkgo::install_ginkgo | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
cd "$(dirname "${BASH_SOURCE[0]}")" | ||
source utils.sh | ||
|
||
cd ../../ | ||
readonly REPO_BASE="$(pwd -P)" | ||
|
||
# keep the first one only | ||
GOPATH="${GOPATH%%:*}" | ||
|
||
# add bin folder into PATH so that pouch-e2e is available. | ||
export PATH="${REPO_BASE}/bin:${PATH}" | ||
|
||
# add bin folder into PATH. | ||
export PATH="${GOPATH}/bin:${PATH}" | ||
|
||
# CRI_SKIP skips the test to skip. | ||
DEFAULT_SKIP="\[Flaky\]|\[Slow\]|\[Serial\]" | ||
DEFAULT_SKIP+="|querying\s\/stats\/summary" | ||
DEFAULT_SKIP+="|should execute prestop exec hook properly" | ||
DEFAULT_SKIP+="|should execute poststart exec hook properly" | ||
DEFAULT_SKIP+="|should function for intra-pod communication: http*" | ||
DEFAULT_SKIP+="|should function for intra-pod communication: udp*" | ||
DEFAULT_SKIP+="|should project all components that make up the projection API*" | ||
export SKIP=${SKIP:-${DEFAULT_SKIP}} | ||
|
||
# FOCUS focuses the test to run. | ||
export FOCUS=${FOCUS:-} | ||
|
||
POUCH_SOCK="/var/run/pouchcri.sock" | ||
|
||
# tmplog_dir stores the background job log data | ||
tmplog_dir="$(mktemp -d /tmp/e2e-daemon-cri-testing-XXXXX)" | ||
pouchd_log="${tmplog_dir}/pouchd.log" | ||
local_persist_log="${tmplog_dir}/local_persist.log" | ||
trap 'rm -rf /tmp/e2e-daemon-cri-testing-*' EXIT | ||
|
||
# integration::install_cni installs cni plugins. | ||
integration::install_cni() { | ||
hack/install/install_cni.sh | ||
} | ||
|
||
# integration::install_ginkgo installs ginkgo. | ||
integration::install_ginkgo() { | ||
hack/install/install_ginkgo.sh | ||
} | ||
|
||
# integration::install_etcd installs etcd. | ||
integration::install_etcd() { | ||
hack/install/install_etcd.sh | ||
} | ||
|
||
# integration::run_daemon_cri_test_e2e_cases runs CRI e2e test cases. | ||
integration::run_daemon_cri_test_e2e_cases() { | ||
local cri_runtime code KUBERNETES_VERSION | ||
cri_runtime=$1 | ||
|
||
if [[ "${cri_runtime}" == "v1alpha1" ]]; then | ||
KUBERNETES_VERSION="release-1.9" | ||
else | ||
KUBERNETES_VERSION="release-1.10" | ||
fi | ||
|
||
KUBERNETES_REPO="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 https://${KUBERNETES_REPO} . | ||
fi | ||
cd "${KUBERNETES_PATH}" | ||
git fetch --all | ||
git checkout ${KUBERNETES_VERSION} | ||
|
||
echo "start pouch daemon cri-${cri_runtime} e2e test..." | ||
set +e | ||
|
||
make test-e2e-node \ | ||
RUNTIME=remote \ | ||
CONTAINER_RUNTIME_ENDPOINT=unix://${POUCH_SOCK} \ | ||
SKIP="${SKIP}" \ | ||
FOCUS="${FOCUS}" \ | ||
PARALLELISM=8 | ||
|
||
code=$? | ||
|
||
integration::stop_local_persist | ||
integration::stop_pouchd | ||
set -e | ||
|
||
if [[ "${code}" != "0" ]]; then | ||
echo "failed to pass e2e cases!" | ||
echo "there is daemon logs..." | ||
cat "${pouchd_log}" | ||
exit ${code} | ||
fi | ||
|
||
# sleep for pouchd stop and got the coverage | ||
sleep 5 | ||
} | ||
|
||
integration::run_cri_e2e_test(){ | ||
local cri_runtime cmd flags coverage_profile | ||
cri_runtime=$1 | ||
|
||
# daemon cri integration coverage profile | ||
coverage_profile="${REPO_BASE}/coverage/e2e_daemon_cri_${cri_runtime}_profile.out" | ||
rm -rf "${coverage_profile}" | ||
|
||
cmd="pouchd-integration" | ||
flags=" -test.coverprofile=${coverage_profile} DEVEL" | ||
flags="${flags} --enable-cri --cri-version ${cri_runtime} --sandbox-image=gcr.io/google_containers/pause-amd64:3.0" | ||
|
||
|
||
integration::stop_local_persist | ||
integration::run_local_persist_background "${local_persist_log}" | ||
integration::stop_pouchd | ||
integration::run_pouchd_background "${cmd}" "${flags}" "${pouchd_log}" | ||
|
||
set +e; integration::ping_pouchd; code=$?; set -e | ||
if [[ "${code}" != "0" ]]; then | ||
echo "there is daemon logs..." | ||
cat "${pouchd_log}" | ||
exit ${code} | ||
fi | ||
integration::run_daemon_cri_test_e2e_cases "${cri_runtime}" | ||
} | ||
|
||
main() { | ||
local cri_runtime | ||
cri_runtime=$1 | ||
|
||
integration::install_cni | ||
integration::install_ginkgo | ||
integration::install_etcd | ||
integration::run_cri_e2e_test "${cri_runtime}" | ||
} | ||
|
||
main "$@" |
Oops, something went wrong.