-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathci-e2e.sh
executable file
·109 lines (90 loc) · 3.96 KB
/
ci-e2e.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash
# Copyright 2018 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 errexit
set -o pipefail
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}" || exit 1
# shellcheck source=./scripts/ci-e2e-lib.sh
source "${REPO_ROOT}/scripts/ci-e2e-lib.sh"
# shellcheck source=./hack/ensure-go.sh
source "${REPO_ROOT}/hack/ensure-go.sh"
# shellcheck source=./hack/ensure-kubectl.sh
source "${REPO_ROOT}/hack/ensure-kubectl.sh"
# shellcheck source=./hack/ensure-kind.sh
source "${REPO_ROOT}/hack/ensure-kind.sh"
# Make sure the tools binaries are on the path.
export PATH="${REPO_ROOT}/hack/tools/bin:${PATH}"
# Builds CAPI (and CAPD) images.
capi:buildDockerImages
# Prepare kindest/node images for all the required Kubernetes version; this implies
# 1. Kubernetes version labels (e.g. latest) to the corresponding version numbers.
# 2. Pre-pulling the corresponding kindest/node image if available; if not, building the image locally.
# Following variables are currently checked (if defined):
# - KUBERNETES_VERSION
# - KUBERNETES_VERSION_UPGRADE_TO
# - KUBERNETES_VERSION_UPGRADE_FROM
k8s::prepareKindestImages
# pre-pull all the images that will be used in the e2e, thus making the actual test run
# less sensible to the network speed. This includes:
# - cert-manager images
kind:prepullAdditionalImages
# Configure e2e tests
export GINKGO_NODES=3
export GINKGO_NOCOLOR=true
export GINKGO_ARGS="${GINKGO_ARGS:-"--fail-fast"}"
export E2E_CONF_FILE="${REPO_ROOT}/test/e2e/config/docker.yaml"
export ARTIFACTS="${ARTIFACTS:-${REPO_ROOT}/_artifacts}"
export SKIP_RESOURCE_CLEANUP=false
export USE_EXISTING_CLUSTER=false
# Setup local output directory
ARTIFACTS_LOCAL="${ARTIFACTS}/localhost"
mkdir -p "${ARTIFACTS_LOCAL}"
echo "This folder contains logs from the local host where the tests ran." > "${ARTIFACTS_LOCAL}/README.md"
# Configure the containerd socket, otherwise 'ctr' would not work
export CONTAINERD_ADDRESS=/var/run/docker/containerd/containerd.sock
# ensure we retrieve additional info for debugging when we leave the script
cleanup() {
# shellcheck disable=SC2046
kill $(pgrep -f 'docker events') || true
# shellcheck disable=SC2046
kill $(pgrep -f 'ctr -n moby events') || true
cp /var/log/docker.log "${ARTIFACTS_LOCAL}/docker.log" || true
docker ps -a > "${ARTIFACTS_LOCAL}/docker-ps.txt" || true
docker images > "${ARTIFACTS_LOCAL}/docker-images.txt" || true
docker info > "${ARTIFACTS_LOCAL}/docker-info.txt" || true
docker system df > "${ARTIFACTS_LOCAL}/docker-system-df.txt" || true
docker version > "${ARTIFACTS_LOCAL}/docker-version.txt" || true
ctr namespaces list > "${ARTIFACTS_LOCAL}/containerd-namespaces.txt" || true
ctr -n moby tasks list > "${ARTIFACTS_LOCAL}/containerd-tasks.txt" || true
ctr -n moby containers list > "${ARTIFACTS_LOCAL}/containerd-containers.txt" || true
ctr -n moby images list > "${ARTIFACTS_LOCAL}/containerd-images.txt" || true
ctr -n moby version > "${ARTIFACTS_LOCAL}/containerd-version.txt" || true
# Verify that no containers are running at this time
# Note: This verifies that all our tests clean up clusters correctly.
if [[ ! "$(docker ps -q | wc -l)" -eq "0" ]]
then
echo "ERROR: Found unexpected running containers:"
echo ""
docker ps
exit 1
fi
}
trap "cleanup" EXIT SIGINT
docker events > "${ARTIFACTS_LOCAL}/docker-events.txt" 2>&1 &
ctr -n moby events > "${ARTIFACTS_LOCAL}/containerd-events.txt" 2>&1 &
# Run e2e tests
mkdir -p "$ARTIFACTS"
echo "+ run tests!"
make test-e2e