@@ -84,38 +84,38 @@ steps:
8484
8585 - bash : |
8686 set -ex
87- if ! [[ $APIGEE_ENVIRONMENT =~ .*-*sandbox ]]; then
88- counter=0
89- base_path="$SERVICE_BASE_PATH"
9087
91- endpoint=""
88+ endpoint=""
89+ if [[ $APIGEE_ENVIRONMENT =~ "prod" ]]; then
90+ endpoint="https://api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
91+ else
92+ endpoint="https://${APIGEE_ENVIRONMENT}.api.service.nhs.uk/${SERVICE_BASE_PATH}/_status"
93+ fi
9294
93- if [[ $APIGEE_ENVIRONMENT =~ "prod" ]]; then
94- endpoint="https://api.service.nhs.uk/${base_path}/_status"
95+ counter=0
96+ while [[ $counter -lt 31 ]]; do
97+ response=$(curl -H "apikey: $(status-endpoint-api-key)" -s "$endpoint")
98+ response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "$response")
99+ response_body=$(jq -r '.checks.healthcheck.outcome' <<< "$response")
100+ status=$(jq -r '.status' <<< "$response")
101+ if [ "$response_code" -eq 200 ] && [ "$response_body" == "OK" ] && [ "$status" == "pass" ]; then
102+ echo "Status test successful"
103+ break
95104 else
96- endpoint="https://${APIGEE_ENVIRONMENT}.api.service.nhs.uk/${base_path}/_status"
105+ echo "Waiting for $endpoint to return a 200 response with 'OK' body..."
106+ ((counter=counter+1)) # Increment counter by 1
107+ echo "Attempt $counter"
108+ sleep 30
97109 fi
110+ done
98111
99- while [[ $counter -lt 11 ]]; do
100- response=$(curl -H "apikey: $(status-endpoint-api-key)" -s "$endpoint")
101- response_code=$(jq -r '.checks.healthcheck.responseCode' <<< "$response")
102- response_body=$(jq -r '.checks.healthcheck.outcome' <<< "$response")
103- if [ "$response_code" -eq 200 ] && [ "$response_body" == "OK" ]; then
104- echo "Status test successful"
105- break
106- else
107- echo "Waiting for $endpoint to return a 200 response with 'OK' body..."
108- ((counter=counter+1)) # Increment counter by 1
109- echo "Attempt $counter"
110- sleep 30
111- fi
112- done
113- if [ $counter -eq 11 ]; then
114- echo "Status test failed: Maximum number of attempts reached"
115- exit 1
116- fi
112+ if [ $counter -eq 31 ]; then
113+ echo "Status test failed: Maximum number of attempts reached"
114+ echo "Last response received:"
115+ echo "$response"
116+ exit 1
117117 fi
118- displayName: Waiting for TF resources to be UP
118+ displayName: Wait for API to be available
119119 workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)"
120120
121121 - bash : |
@@ -168,7 +168,7 @@ steps:
168168 export DEFAULT_CLIENT_SECRET="$(INT_CLIENT_SECRET)"
169169 echo "running: $test_cmd -v -c test_deployment.py test_proxy.py"
170170 $test_cmd -v -c test_deployment.py test_proxy.py
171-
171+
172172 elif [[ $APIGEE_ENVIRONMENT == "prod" ]]; then
173173 echo "Proxy test completed successfully as part of terraform resource up status check"
174174
@@ -179,35 +179,35 @@ steps:
179179 workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/e2e"
180180 displayName: Run Full Test Suite
181181
182-
182+
183183
184184 - bash : |
185185 set -e
186186 if ! [[ "$APIGEE_ENVIRONMENT" == "prod" || "$APIGEE_ENVIRONMENT" == "int" || "$APIGEE_ENVIRONMENT" == *"sandbox" ]]; then
187187 echo "Running E2E batch folder test cases"
188-
188+
189189 export AWS_PROFILE="apim-dev"
190190 aws_account_no="$(aws sts get-caller-identity --query Account --output text)"
191191 echo "Using AWS Account: $aws_account_no"
192-
192+
193193 service_name="${FULLY_QUALIFIED_SERVICE_NAME}"
194-
194+
195195 pr_no=$(echo "$service_name" | { grep -oE '[0-9]+$' || true; })
196196 if [ -z "$pr_no" ]; then
197197 workspace="$APIGEE_ENVIRONMENT"
198198 else
199199 workspace="pr-$pr_no"
200200 fi
201-
201+
202202 poetry install --no-root # Install dependencies defined in pyproject.toml
203-
203+
204204 ENV="$workspace" poetry run python -m unittest -v -c
205-
205+
206206 echo "E2E batch folder test cases executed successfully"
207207 else
208208 echo "Skipping E2E batch folder test cases as the environment is prod-int-sandbox"
209209 fi
210-
210+
211211 displayName: Run full batch test suite
212212 workingDirectory: "$(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/e2e_batch"
213213 condition: eq(1, 2) # Disable task but make this step visible in the pipeline
@@ -217,4 +217,4 @@ steps:
217217 condition : always()
218218 inputs :
219219 testResultsFiles : ' $(Pipeline.Workspace)/s/$(SERVICE_NAME)/$(SERVICE_ARTIFACT_NAME)/tests/test-report.xml'
220- failTaskOnFailedTests : true
220+ failTaskOnFailedTests : true
0 commit comments