-
Notifications
You must be signed in to change notification settings - Fork 123
/
run.sh
executable file
·46 lines (38 loc) · 1.22 KB
/
run.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
#!/usr/bin/env bash
# Copyright 2021-2023 Zenauth Ltd.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
E2E_CLUSTER=${E2E_CLUSTER:-"cerbos-e2e"}
E2E_SKIP_CLUSTER=${E2E_SKIP_CLUSTER:-"false"}
E2E_NO_CLEANUP=${E2E_NO_CLEANUP:-"false"}
check_prerequisites() {
for EXE in helm helmfile kind kubectl telepresence; do
command -v "$EXE" >/dev/null 2>&1 || { echo "$EXE is required but cannot be found in PATH"; exit 1; }
done
}
start_kind() {
if [[ "$E2E_SKIP_CLUSTER" == "false" ]]; then
kind create cluster --name="$E2E_CLUSTER" --config="${SCRIPT_DIR}/kind.yaml"
fi
}
stop_kind() {
if [[ "$E2E_SKIP_CLUSTER" == "false" && "$E2E_NO_CLEANUP" == "false" ]]; then
kind delete cluster --name="$E2E_CLUSTER"
fi
}
run_tests() {
(
cd "$SCRIPT_DIR"
telepresence helm upgrade
telepresence connect --no-report -- go test -v -failfast -p=1 -cover -coverprofile=../e2e.cover --tags="tests e2e" "$@"
)
}
check_prerequisites
start_kind
trap stop_kind EXIT
if [[ "$#" -gt "0" ]]; then
# E.g. e2e/run.sh ./mysql/... -args -run-id=xxxxx -no-cleanup
run_tests "$@"
else
run_tests ./... -args -no-cleanup="$E2E_NO_CLEANUP" -command-timeout=5m
fi