Skip to content

Commit 44856cb

Browse files
author
Thomas Wiest
committed
Add retry logic to e2e-test.sh
1 parent d8eee4b commit 44856cb

File tree

1 file changed

+118
-15
lines changed

1 file changed

+118
-15
lines changed

hack/e2e-test.sh

100644100755
Lines changed: 118 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
set -e
44

5+
max_tries=60
6+
sleep_between_tries=10
57
component=hive
68
TEST_IMAGE=$(eval "echo $IMAGE_FORMAT")
79
component=installer
@@ -15,17 +17,69 @@ curl -O -L https://github.com/kubernetes-sigs/kustomize/releases/download/v2.0.0
1517
mv kustomize_2.0.0_linux_amd64 kustomize
1618
chmod u+x kustomize
1719

18-
oc new-project cluster-test
20+
21+
i=1
22+
while [ $i -le ${max_tries} ]; do
23+
if [ $i -gt 1 ]; then
24+
# Don't sleep on first loop
25+
echo "sleeping ${sleep_between_tries} seconds"
26+
sleep ${sleep_between_tries}
27+
fi
28+
29+
echo -n "Creating project cluster-test. Try #${i}/${max_tries}... "
30+
if oc new-project cluster-test ; then
31+
echo "Success"
32+
break
33+
else
34+
echo -n "Failed, "
35+
fi
36+
37+
i=$((i + 1))
38+
done
39+
40+
if [ $i -ge ${max_tries} ] ; then
41+
# Failed the maximum amount of times.
42+
echo "exiting"
43+
exit 10
44+
fi
45+
1946

2047
# Install Hive
2148
make deploy DEPLOY_IMAGE="${TEST_IMAGE}"
2249

2350
CLOUD_CREDS_DIR="/tmp/cluster"
51+
CLUSTER_DEPLOYMENT_FILE="/tmp/cluster-deployment.json"
52+
53+
54+
i=1
55+
while [ $i -le ${max_tries} ]; do
56+
if [ $i -gt 1 ]; then
57+
# Don't sleep on first loop
58+
echo "sleeping ${sleep_between_tries} seconds"
59+
sleep ${sleep_between_tries}
60+
fi
61+
62+
echo -n "Getting cluster name. Try #${i}/${max_tries}... "
63+
if CLUSTER_NAME="$(oc get clusters.machine.openshift.io -n openshift-machine-api -o jsonpath='{ .items[].metadata.name }')-1" ; then
64+
echo "Success"
65+
break
66+
else
67+
echo -n "Failed, "
68+
fi
69+
70+
i=$((i + 1))
71+
done
72+
73+
if [ $i -ge ${max_tries} ] ; then
74+
# Failed the maximum amount of times.
75+
echo "exiting"
76+
exit 10
77+
fi
78+
2479

2580
# Create a new cluster deployment
2681
# TODO: Determine which domain to use to create Hive clusters
2782
export BASE_DOMAIN="hive-ci.openshift.com"
28-
export CLUSTER_NAME="$(oc get cluster.cluster.k8s.io -n openshift-cluster-api -o jsonpath='{ .items[].metadata.name }')-1"
2983
export SSH_PUB_KEY="$(cat ${CLOUD_CREDS_DIR}/ssh-publickey)"
3084
export PULL_SECRET="$(cat ${CLOUD_CREDS_DIR}/pull-secret)"
3185
export AWS_ACCESS_KEY_ID="$(cat ${CLOUD_CREDS_DIR}/.awscred | awk '/aws_access_key_id/ { print $3; exit; }')"
@@ -42,19 +96,68 @@ trap 'teardown' EXIT
4296
# TODO: Determine how to wait for readiness of the validation webhook
4397
sleep 120
4498

45-
echo "Creating ClusterDeployment ${CLUSTER_NAME}"
46-
47-
oc process -f config/templates/cluster-deployment.yaml \
48-
CLUSTER_NAME="${CLUSTER_NAME}" \
49-
SSH_KEY="${SSH_PUB_KEY}" \
50-
PULL_SECRET="${PULL_SECRET}" \
51-
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
52-
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
53-
BASE_DOMAIN="${BASE_DOMAIN}" \
54-
INSTALLER_IMAGE="${INSTALLER_IMAGE}" \
55-
OPENSHIFT_RELEASE_IMAGE="" \
56-
TRY_INSTALL_ONCE="true" \
57-
| oc apply -f -
99+
100+
i=1
101+
while [ $i -le ${max_tries} ]; do
102+
if [ $i -gt 1 ]; then
103+
# Don't sleep on first loop
104+
echo "sleeping ${sleep_between_tries} seconds"
105+
sleep ${sleep_between_tries}
106+
fi
107+
108+
echo "Generating ClusterDeployment File ${CLUSTER_NAME}. Try #${i}/${max_tries}:"
109+
if oc process -f config/templates/cluster-deployment.yaml \
110+
CLUSTER_NAME="${CLUSTER_NAME}" \
111+
SSH_KEY="${SSH_PUB_KEY}" \
112+
PULL_SECRET="${PULL_SECRET}" \
113+
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID}" \
114+
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY}" \
115+
BASE_DOMAIN="${BASE_DOMAIN}" \
116+
INSTALLER_IMAGE="${INSTALLER_IMAGE}" \
117+
OPENSHIFT_RELEASE_IMAGE="" \
118+
TRY_INSTALL_ONCE="true" \
119+
> ${CLUSTER_DEPLOYMENT_FILE} ; then
120+
echo "Success"
121+
break
122+
else
123+
echo -n "Failed, "
124+
fi
125+
126+
i=$((i + 1))
127+
done
128+
129+
if [ $i -ge ${max_tries} ] ; then
130+
# Failed the maximum amount of times.
131+
echo "exiting"
132+
exit 10
133+
fi
134+
135+
136+
i=1
137+
while [ $i -le ${max_tries} ]; do
138+
if [ $i -gt 1 ]; then
139+
# Don't sleep on first loop
140+
echo "sleeping ${sleep_between_tries} seconds"
141+
sleep ${sleep_between_tries}
142+
fi
143+
144+
echo "Applying ClusterDeployment File ${CLUSTER_NAME}. Try #${i}/${max_tries}:"
145+
if oc apply -f ${CLUSTER_DEPLOYMENT_FILE} ; then
146+
echo "Success"
147+
break
148+
else
149+
echo -n "Failed, "
150+
fi
151+
152+
i=$((i + 1))
153+
done
154+
155+
if [ $i -ge ${max_tries} ] ; then
156+
# Failed the maximum amount of times.
157+
echo "exiting"
158+
exit 10
159+
fi
160+
58161

59162
# Wait for the cluster deployment to be installed
60163
SRC_ROOT=$(git rev-parse --show-toplevel)

0 commit comments

Comments
 (0)