-
Notifications
You must be signed in to change notification settings - Fork 238
/
run-e2e
executable file
·94 lines (79 loc) · 2.84 KB
/
run-e2e
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
#!/usr/bin/env bash
# Copyright 2024 Google LLC
#
# 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 nounset
set -o pipefail
REPO_ROOT="$(git rev-parse --show-toplevel)"
cd ${REPO_ROOT}
if [[ -z "${KUBEBUILDER_ASSETS:-}" ]]; then
echo "Downloading envtest assets..."
export KUBEBUILDER_ASSETS=$(go run sigs.k8s.io/controller-runtime/tools/setup-envtest@latest use -p path)
fi
if [[ -z "${KCC_USE_DIRECT_RECONCILERS:-}" ]]; then
KCC_USE_DIRECT_RECONCILERS=ComputeForwardingRule,GKEHubFeatureMembership
fi
echo "Using direct controllers: $KCC_USE_DIRECT_RECONCILERS"
export KCC_USE_DIRECT_RECONCILERS
if [[ -z "${RUN_TESTS:-}" ]]; then
RUN_TESTS=TestAllInSeries/fixtures
fi
echo "Running tests matching: ${RUN_TESTS}"
if [[ -z "${E2E_GCP_TARGET:-}" ]]; then
E2E_GCP_TARGET=mock
fi
echo "Using E2E_GCP_TARGET: ${E2E_GCP_TARGET}"
export E2E_GCP_TARGET
if [[ -z "${E2E_KUBE_TARGET:-}" ]]; then
E2E_KUBE_TARGET=envtest
fi
echo "Using E2E_KUBE_TARGET: ${E2E_KUBE_TARGET}"
export E2E_KUBE_TARGET
if [[ -z "${ARTIFACTS:-}" ]]; then
ARTIFACTS=${REPO_ROOT}/artifactz/${E2E_GCP_TARGET}
fi
echo "Using ARTIFACTS: ${ARTIFACTS}"
export ARTIFACTS
if [[ "${E2E_GCP_TARGET}" == "real" ]]; then
if [[ -z "${GCP_PROJECT_ID:-}" ]]; then
GCP_PROJECT_ID=$(gcloud config get-value project)
fi
echo "Using GCP_PROJECT_ID: ${GCP_PROJECT_ID}"
export GCP_PROJECT_ID
TEST_FOLDER_ID=$(gcloud projects describe ${GCP_PROJECT_ID} --format='value(parent.id)')
export TEST_FOLDER_ID
TEST_ORG_ID=$(gcloud projects get-ancestors ${GCP_PROJECT_ID} | grep organization | cut -f1 -d ' ')
export TEST_ORG_ID
if [[ -z "${TEST_BILLING_ACCOUNT_ID:-}" ]]; then
TEST_BILLING_ACCOUNT_ID=$(gcloud billing projects describe ${GCP_PROJECT_ID} --format='value(billingAccountName)' | cut -f2 -d/)
fi
echo "TEST_BILLING_ACCOUNT_ID=${TEST_BILLING_ACCOUNT_ID}"
export TEST_BILLING_ACCOUNT_ID
fi
if [[ -z "${TEST_TIMEOUT:-}" ]]; then
TEST_TIMEOUT=120m
fi
echo "Using TEST_TIMEOUT=${TEST_TIMEOUT}"
if [[ -z "${PREBUILT_TEST_BINARY:-}" ]]; then
echo "Prebuilding e2e tests"
PREBUILT_TEST_BINARY=${REPO_ROOT}/.build/tests-e2e
go test -c -o ${PREBUILT_TEST_BINARY} ./tests/e2e
fi
# Run e2e tests
cd tests/e2e
GOLDEN_REQUEST_CHECKS=1 \
GOLDEN_OBJECT_CHECKS=1 \
WRITE_GOLDEN_OUTPUT=1 \
RUN_E2E=1 \
${PREBUILT_TEST_BINARY} -test.timeout ${TEST_TIMEOUT} -test.v -test.run $RUN_TESTS