-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathe2e_test_job.sh
More file actions
executable file
·81 lines (69 loc) · 2.47 KB
/
e2e_test_job.sh
File metadata and controls
executable file
·81 lines (69 loc) · 2.47 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 2023 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.
###
# This script is used by the E2E test job defined in .build/e2e_test.yaml
# to prepare the Cloud Build environment and run the end-to-end tests.
#
echo "TIME: $(date) Begin Script"
set -euxo
mkdir -p bin
echo "Using installed gcloud"
gcloud version
gcloud components install --quiet gke-gcloud-auth-plugin
# Install helm
if ! which helm ; then
echo "TIME: $(date) Install Helm"
curl -L -o bin/helm.tar.gz https://get.helm.sh/helm-v3.10.3-linux-amd64.tar.gz
( cd bin && tar -zxf helm.tar.gz && ls -al)
export PATH=$PATH:$PWD/bin/linux-amd64
which helm
else
echo "Using installed helm"
helm version
fi
echo "Using installed go"
go version
# Set the e2e test project id and other params from
# the Cloud Build environment
echo "TIME: $(date) Configure Make Env"
# Don't log the command, it contains secrets
set +x
cat > build.env <<EOF
E2E_PROJECT_ID=$E2E_PROJECT_ID
NODEPOOL_SERVICEACCOUNT_EMAIL=$NODEPOOL_SERVICEACCOUNT_EMAIL
WORKLOAD_ID_SERVICEACCOUNT_EMAIL=$WORKLOAD_ID_SERVICEACCOUNT_EMAIL
TFSTATE_STORAGE_BUCKET=$TFSTATE_STORAGE_BUCKET
EOF
set -x
echo "TIME: $(date) Run Tests"
echo "Running tests on environment ${ENVIRONMENT_NAME:-undefined}"
echo "Starting the tests"
# Run e2e test, filtering the stdout so that it only logs go test results.
if make e2e_test_job > bin/e2e_test.log 2>&1 ; then
echo "STATUS: E2E Test Passed"
test_exit_code=0
else
echo "STATUS: E2E Test Failed"
test_exit_code=1
fi
if test -f bin/e2e_test.log ; then
# Upload full e2e log to the storage bucket
gcloud storage cp bin/e2e_test.log "gs://$TFSTATE_STORAGE_BUCKET/github-action-log/run-$GITHUB_RUN_ID.log"
echo "Uploaded full e2e log to <storage-bucket>/github-action-logs/run-$GITHUB_RUN_ID.log"
# Print go test results to stdout, ignore error
egrep '(---)|(github.com/GoogleCloudPlatform/cloud-sql-proxy-operator/tests)' bin/e2e_test.log || true
fi
echo "TIME: $(date) Done"
exit $test_exit_code