Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix issue: service-api failed to run on gce env created by test-setup.sh #98

Merged
merged 1 commit into from
Jul 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hack/test-config.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

# gcloud multiplexing for shared GCE/GKE tests.
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

SIM_NUM=${SIM_NUM:-2}
CLIENT_NUM=${CLIENT_NUM:-4}
Expand Down
81 changes: 46 additions & 35 deletions hack/test-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
### export CLIENT_ZONE=us-west3-b,us-east4-b,asia-south2-a,australia-southeast1-b,northamerica-northeast1-a,us-west2-c
################

GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

source "${GRS_ROOT}/test-config.sh"
source "${GRS_ROOT}/hack/test-config.sh"

function create-image {
local image_name="$1"
Expand Down Expand Up @@ -109,12 +109,14 @@ function create-instance-group {
--project "${PROJECT}" \
--quiet
fi
gcloud compute instance-groups managed create \
gcloud beta compute instance-groups managed create \
"${group_name}" \
--project "${PROJECT}" \
--zone "${instance_zone}" \
--template "${template_name}" \
--size "${instance_num}" \
--stateful-internal-ip enabled,auto-delete=on-permanent-instance-deletion \
--stateful-external-ip enabled,auto-delete=on-permanent-instance-deletion \
--quiet
}

Expand Down Expand Up @@ -285,42 +287,51 @@ fi
echo "Waiting 60 seconds to get all resource started"
sleep 60

SIM_IPS=""
if [ ${#INSTANCE_SIM_ZONE[@]} == 1 ]; then
SIM_IPS="$(get-mig-ips ${SIM_INSTANCE_PREFIX}-${INSTANCE_SIM_ZONE[0]}-mig ${INSTANCE_SIM_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_SIM_ZONE[@]}"; do
SIM_IPS+="$(get-instance-ip ${SIM_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done
if [ ${SIM_NUM} -gt 0 ]; then
SIM_IPS=""
if [ ${#INSTANCE_SIM_ZONE[@]} == 1 ]; then
SIM_IPS="$(get-mig-ips ${SIM_INSTANCE_PREFIX}-${INSTANCE_SIM_ZONE[0]}-mig ${INSTANCE_SIM_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_SIM_ZONE[@]}"; do
SIM_IPS+="$(get-instance-ip ${SIM_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done

fi
echo "Simulators started at ip addresss: ${SIM_IPS}"
fi
echo "Simulators started at ip addresss: ${SIM_IPS}"
CLIENT_IPS=""
if [ ${#INSTANCE_CLIENT_ZONE[@]} == 1 ]; then
CLIENT_IPS="$(get-mig-ips ${CLIENT_INSTANCE_PREFIX}-${INSTANCE_CLIENT_ZONE[0]}-mig ${INSTANCE_CLIENT_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_CLIENT_ZONE[@]}"; do
CLIENT_IPS+="$(get-instance-ip ${CLIENT_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done

if [ ${CLIENT_NUM} -gt 0 ]; then
CLIENT_IPS=""
if [ ${#INSTANCE_CLIENT_ZONE[@]} == 1 ]; then
CLIENT_IPS="$(get-mig-ips ${CLIENT_INSTANCE_PREFIX}-${INSTANCE_CLIENT_ZONE[0]}-mig ${INSTANCE_CLIENT_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_CLIENT_ZONE[@]}"; do
CLIENT_IPS+="$(get-instance-ip ${CLIENT_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done

fi
echo "Client schedulers started at ip addresss: ${CLIENT_IPS}"
fi
echo "Client schedulers started at ip addresss: ${CLIENT_IPS}"
SERVER_IPS=""
if [ ${#INSTANCE_SERVER_ZONE[@]} == 1 ]; then
start-mig-redis "${SERVER_INSTANCE_PREFIX}-${INSTANCE_SERVER_ZONE[0]}-mig" "${INSTANCE_SERVER_ZONE[0]}"
SERVER_IPS="$(get-mig-ips ${SERVER_INSTANCE_PREFIX}-${INSTANCE_SERVER_ZONE[0]}-mig ${INSTANCE_SERVER_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_SERVER_ZONE[@]}"; do
start-instance-redis "${SERVER_INSTANCE_PREFIX}-${zone}-${index}" "${zone}"
SERVER_IPS+="$(get-instance-ip ${SERVER_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done

if [ ${SERVER_NUM} -gt 0 ]; then
SERVER_IPS=""
if [ ${#INSTANCE_SERVER_ZONE[@]} == 1 ]; then
start-mig-redis "${SERVER_INSTANCE_PREFIX}-${INSTANCE_SERVER_ZONE[0]}-mig" "${INSTANCE_SERVER_ZONE[0]}"
SERVER_IPS="$(get-mig-ips ${SERVER_INSTANCE_PREFIX}-${INSTANCE_SERVER_ZONE[0]}-mig ${INSTANCE_SERVER_ZONE[0]})"
else
index=0
for zone in "${INSTANCE_SERVER_ZONE[@]}"; do
start-instance-redis "${SERVER_INSTANCE_PREFIX}-${zone}-${index}" "${zone}"
SERVER_IPS+="$(get-instance-ip ${SERVER_INSTANCE_PREFIX}-${zone}-${index} ${zone}),"
index=$((index + 1))
done

fi
echo "Servers started at ip addresss: ${SERVER_IPS}"
fi
echo "Servers started at ip addresss: ${SERVER_IPS}"

echo "Done to create and start all required resouce"
12 changes: 6 additions & 6 deletions hack/test-teardown.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

### Only support gcloud
### Please ensure gcloud is installed before run this script
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")/..

source "${GRS_ROOT}/test-config.sh"
source "${GRS_ROOT}/hack/test-config.sh"

echo "Tear down region simulator and clients... "
echo "Tear down server, region simulator and clients... "

function delete-image {
local image_name="$1"
Expand Down Expand Up @@ -70,7 +70,7 @@ function delete-machine-image {
# main function
###############

if [ "${SIM_AUTO_DELETE}" == "true" ]; then
if [[ "${SIM_AUTO_DELETE}" == "true" && ${SIM_NUM} -gt 0 ]]; then
echo "Deleting simulator resources"
IFS=','; INSTANCE_SIM_ZONE=($SIM_ZONE); unset IFS;
if [ ${#INSTANCE_SIM_ZONE[@]} == 1 ]; then
Expand All @@ -90,7 +90,7 @@ if [ "${SIM_AUTO_DELETE}" == "true" ]; then
fi
fi

if [ "${CLIENT_AUTO_DELETE}" == "true" ]; then
if [[ "${CLIENT_AUTO_DELETE}" == "true" && ${CLIENT_NUM} -gt 0 ]]; then
echo "Deleting client scheduler resources"
IFS=','; INSTANCE_CLIENT_ZONE=($CLIENT_ZONE); unset IFS;
if [ ${#INSTANCE_CLIENT_ZONE[@]} == 1 ]; then
Expand All @@ -110,7 +110,7 @@ if [ "${CLIENT_AUTO_DELETE}" == "true" ]; then
fi
fi

if [ "${SERVER_AUTO_DELETE}" == "true" ]; then
if [[ "${SERVER_AUTO_DELETE}" == "true" && ${SERVER_NUM} -gt 0 ]]; then
echo "Deleting server resources"
IFS=','; INSTANCE_SERVER_ZONE=($SERVER_ZONE); unset IFS;
if [ ${#INSTANCE_SERVER_ZONE[@]} == 1 ]; then
Expand Down