-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathrun-e2e-tests.sh
More file actions
executable file
·81 lines (65 loc) · 2.52 KB
/
run-e2e-tests.sh
File metadata and controls
executable file
·81 lines (65 loc) · 2.52 KB
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
#!/usr/bin/env bash
# Copyright 2026 The kcp 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 -euo pipefail
source hack/lib.sh
# have a place to store things
if [ -z "${ARTIFACTS:-}" ]; then
ARTIFACTS=.e2e/artifacts
mkdir -p "$ARTIFACTS"
fi
echodate "Build artifacts will be placed in $ARTIFACTS."
export ARTIFACTS="$(realpath "$ARTIFACTS")"
# build the agent, we will start it many times during the tests
echodate "Building the init-agent…"
make build
# start a shared kcp process
KCP="$(UGET_PRINT_PATH=relative make --no-print-directory install-kcp)"
KCP_ROOT_DIRECTORY=.kcp.e2e
KCP_LOGFILE="$ARTIFACTS/kcp.log"
KCP_TOKENFILE=hack/ci/testdata/e2e-kcp.tokens
echodate "Starting kcp…"
rm -rf "$KCP_ROOT_DIRECTORY" "$KCP_LOGFILE"
"$KCP" start \
-v4 \
--token-auth-file "$KCP_TOKENFILE" \
--root-directory "$KCP_ROOT_DIRECTORY" 1>"$KCP_LOGFILE" 2>&1 &
stop_kcp() {
echodate "Stopping kcp processes (set \$KEEP_KCP=true to not do this)…"
pkill -e kcp
}
if [[ -v KEEP_KCP ]] && $KEEP_KCP; then
echodate "\$KEEP_KCP is set, will not stop kcp once the script is finished."
else
append_trap stop_kcp EXIT
fi
# make the token available to the Go tests
export KCP_AGENT_TOKEN="$(grep e2e "$KCP_TOKENFILE" | cut -f1 -d,)"
# Wait for kcp to be ready; this env name is also hardcoded in the Go tests.
export KCP_KUBECONFIG="$KCP_ROOT_DIRECTORY/admin.kubeconfig"
# the tenancy API becomes available pretty late during startup, so it's a good readiness check
KUBECTL="$(UGET_PRINT_PATH=relative make --no-print-directory install-kubectl)"
if ! retry_linear 3 20 "$KUBECTL" --kubeconfig "$KCP_KUBECONFIG" get workspaces; then
echodate "kcp never became ready."
exit 1
fi
# makes it easier to reference these files from various _test.go files.
export ROOT_DIRECTORY="$(realpath .)"
export KCP_KUBECONFIG="$(realpath "$KCP_KUBECONFIG")"
export AGENT_BINARY="$(realpath _build/init-agent)"
# time to run the tests
echodate "Running e2e tests…"
WHAT="${WHAT:-./test/e2e/...}"
(set -x; go test -tags e2e -timeout 2h -v $WHAT)
echodate "Done. :-)"