-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathgke-e2e.sh
executable file
·115 lines (98 loc) · 4.26 KB
/
gke-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
110
111
112
113
114
115
#!/bin/bash
#
# Copyright (C) Extensible Service Proxy Authors
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
################################################################################
#
SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
ESP_ROOT="$(cd "${SCRIPT_PATH}/../" && pwd)"
. ${ESP_ROOT}/script/jenkins-utilities || { echo "Cannot load Jenkins Bash utilities" ; exit 1 ; }
e2e_options "${@}"
if [[ "${BACKEND}" == 'bookstore' ]]; then
YAML_FILE_TEMP="${ESP_ROOT}/test/bookstore/gke/deploy_secure_template.yaml"
SERVICE_IDL="${ESP_ROOT}/test/bookstore/swagger_template.json"
# GKE service name in the deploy.yaml
GKE_SERVICE_NAME="bookstore"
TEST_ID_SUFFIX="secure"
CREATE_SERVICE_ARGS="${SERVICE_IDL}"
elif [[ "${BACKEND}" == 'interop' ]]; then
YAML_FILE_TEMP="${ESP_ROOT}/test/grpc/gke/interop.yaml.temp"
SERVICE_IDL="${ESP_ROOT}/test/grpc/grpc-interop.yaml"
# GKE service name in the deploy.yaml
GKE_SERVICE_NAME="interop"
TEST_ID_SUFFIX="grpc-ssl"
CREATE_SERVICE_ARGS="${SERVICE_IDL} bazel-genfiles/test/grpc/grpc-interop.descriptor"
fi
TEST_ID="gke-${COUPLING_OPTION}-${TEST_TYPE}-${BACKEND}-${TEST_ID_SUFFIX}"
ESP_SERVICE="${TEST_ID}.${PROJECT_ID}.appspot.com"
NAMESPACE="${UNIQUE_ID}"
sed -i "s|\${ENDPOINT_SERVICE}|${ESP_SERVICE}|g" "${SERVICE_IDL}"
# Deploy new service config
create_service "${ESP_SERVICE}" "${CREATE_SERVICE_ARGS}"
YAML_FILE="$(mktemp /tmp/yaml.XXXX)"
sed -e "s|\$BACKEND_IMAGE|${BOOKSTORE_IMAGE}|g" \
-e "s|\$ESP_IMAGE|${ESP_IMAGE}|g" \
-e "s|\${ENDPOINT_SERVICE}|${ESP_SERVICE}|g" \
${YAML_FILE_TEMP} > ${YAML_FILE}
cat ${YAML_FILE}
trap gke_namespace_cleanup EXIT
# Testing protocol
run kubectl create namespace "${NAMESPACE}" || error_exit "Namespace already exists"
if [[ "${BACKEND}" == 'interop' ]]; then
run kubectl -n "${NAMESPACE}" create secret generic grpc-ssl \
--from-file=${ESP_ROOT}/src/nginx/t/testdata/grpc/cacert.pem \
--from-file=${ESP_ROOT}/src/nginx/t/testdata/grpc/servercert.pem \
--from-file=${ESP_ROOT}/src/nginx/t/testdata/grpc/serverkey.pem
fi
run gsutil cp gs://esp-testing-secret-files/endpoints-jenkins-ea2e9cc046a6.json \
/tmp/service_account_key.json
run kubectl -n "${NAMESPACE}" create secret generic sa-file \
--from-file=/tmp/service_account_key.json
run kubectl create -f ${YAML_FILE} --namespace "${NAMESPACE}"
run kubectl get services -o yaml --namespace "${NAMESPACE}"
run kubectl get deployments -o yaml --namespace "${NAMESPACE}"
SERVICE_IP=$(get_gke_service_ip "${NAMESPACE}" "${GKE_SERVICE_NAME}")
if [[ "${BACKEND}" == 'bookstore' ]]; then
HOST="http://${SERVICE_IP}"
elif [[ "${BACKEND}" == 'interop' ]]; then
HOST="${SERVICE_IP}:8080"
fi
echo "=== Use the host: ${HOST}";
LOG_DIR="$(mktemp -d /tmp/log.XXXX)"
# Running Test
run_nonfatal long_running_test \
"${HOST}" \
"${DURATION_IN_HOUR}" \
"${API_KEY}" \
"${ESP_SERVICE}" \
"${LOG_DIR}" \
"${TEST_ID}" \
"${UNIQUE_ID}"
STATUS=${?}
if [[ -n $REMOTE_LOG_DIR ]]; then
upload_logs "${REMOTE_LOG_DIR}" "${LOG_DIR}"
rm -rf "${LOG_DIR}"
fi
exit ${STATUS}