Skip to content

Commit 47e1f40

Browse files
committed
Increase number of attempts. Run check for sandbox too.
1 parent 1b705c7 commit 47e1f40

File tree

1 file changed

+26
-29
lines changed

1 file changed

+26
-29
lines changed

azure/templates/post-deploy.yml

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -80,41 +80,38 @@ steps:
8080
8181
- bash: |
8282
set -ex
83-
if ! [[ $APIGEE_ENVIRONMENT =~ .*-*sandbox ]]; then
84-
counter=0
85-
base_path="$SERVICE_BASE_PATH"
8683
87-
endpoint=""
84+
endpoint=""
85+
if [[ $APIGEE_ENVIRONMENT =~ "prod" ]]; then
86+
endpoint="https://api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
87+
else
88+
endpoint="https://${APIGEE_ENVIRONMENT}.api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
89+
fi
8890
89-
if [[ $APIGEE_ENVIRONMENT =~ "prod" ]]; then
90-
endpoint="https://api.service.nhs.uk/${base_path}/_status"
91+
counter=0
92+
while [[ $counter -lt 21 ]]; do
93+
response=$(curl -H "apikey: $(status-endpoint-api-key)" -s "$endpoint")
94+
response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "$response")
95+
response_body=$(jq -r '.checks.healthcheck.outcome' <<< "$response")
96+
status=$(jq -r '.status' <<< "$response")
97+
if [ "$response_code" -eq 200 ] && [ "$response_body" == "OK" ] && [ "$status" == "pass" ]; then
98+
echo "Status test successful"
99+
break
91100
else
92-
endpoint="https://${APIGEE_ENVIRONMENT}.api.service.nhs.uk/${base_path}/_status"
101+
echo "Waiting for $endpoint to return a 200 response with 'OK' body..."
102+
((counter=counter+1)) # Increment counter by 1
103+
echo "Attempt $counter"
104+
sleep 30
93105
fi
106+
done
94107
95-
while [[ $counter -lt 11 ]]; do
96-
response=$(curl -H "apikey: $(status-endpoint-api-key)" -s "$endpoint")
97-
response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "$response")
98-
response_body=$(jq -r '.checks.healthcheck.outcome' <<< "$response")
99-
status=$(jq -r '.status' <<< "$response")
100-
if [ "$response_code" -eq 200 ] && [ "$response_body" == "OK" ] && [ "$status" == "pass" ]; then
101-
echo "Status test successful"
102-
break
103-
else
104-
echo "Waiting for $endpoint to return a 200 response with 'OK' body..."
105-
((counter=counter+1)) # Increment counter by 1
106-
echo "Attempt $counter"
107-
sleep 30
108-
fi
109-
done
110-
if [ $counter -eq 21 ]; then
111-
echo "Status test failed: Maximum number of attempts reached"
112-
echo "Last response received:"
113-
echo "$response"
114-
exit 1
115-
fi
108+
if [ $counter -eq 21 ]; then
109+
echo "Status test failed: Maximum number of attempts reached"
110+
echo "Last response received:"
111+
echo "$response"
112+
exit 1
116113
fi
117-
displayName: Waiting for TF resources to be UP
114+
displayName: Waiting for API to be available
118115
workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)"
119116
120117
- bash: |

0 commit comments

Comments
 (0)