Skip to content

Commit

Permalink
Reintroduce smoke tests using AKS now
Browse files Browse the repository at this point in the history
  • Loading branch information
saliceti committed Dec 12, 2023
1 parent 3d4ea88 commit 18ee781
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
29 changes: 16 additions & 13 deletions .github/workflows/actions/deploy_v2/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ inputs:
required: true
outputs:
deploy-url:
value: ${{ steps.set_env_var.outputs.deploy_url }}
value: https://${{ steps.set_env_var.outputs.deploy_url }}
runs:
using: composite
steps:
Expand All @@ -22,15 +22,16 @@ runs:
run: |
tf_vars_file=terraform/aks/config/${{ inputs.environment }}.tfvars.json
terraform_version=$(awk '/{/{f=/^terraform/;next}f' terraform/aks/provider.tf | grep -o [0-9\.]*)
echo "cluster=$(jq -r '.cluster' ${tf_vars_file})" >> $GITHUB_ENV
echo "aks_app_environment=$(jq -r '.environment' ${tf_vars_file})" >> $GITHUB_ENV
cluster=$(jq -r '.cluster' ${tf_vars_file})
aks_app_environment=$(jq -r '.environment' ${tf_vars_file})
echo "TERRAFORM_VERSION=$terraform_version" >> $GITHUB_ENV
echo "namespace=$(jq -r '.namespace' ${tf_vars_file})" >> $GITHUB_ENV
if [[ $cluster == 'production' ]]; then
echo "deploy_url=https://getintoteachingapi-${{ env.aks_app_environment }}.teacherservices.cloud" >> $GITHUB_OUTPUT
else
echo "deploy_url=https://getintoteachingapi-${{ env.aks_app_environment }}.${cluster}.teacherservices.cloud" >> $GITHUB_OUTPUT
app_hostname=getintoteachingapi-${aks_app_environment}.teacherservices.cloud
else
app_hostname=getintoteachingapi-${aks_app_environment}.${cluster}.teacherservices.cloud
fi
echo "app_hostname=${app_hostname}" >> $GITHUB_OUTPUT
- name: Use Terraform ${{ env.TERRAFORM_VERSION }}
uses: hashicorp/setup-terraform@v2
Expand All @@ -41,14 +42,16 @@ runs:
with:
azure-credentials: ${{ inputs.azure-credentials }}

- name: Print Sha
id: print-sha
shell: bash
run: |
echo "${{ inputs.sha }}"
- name: Terraform init, plan & apply
shell: bash
run: make ci ${{ inputs.environment }} terraform-apply
env:
IMAGE_TAG: ${{ inputs.sha }}

- name: Smoke tests
shell: bash
run: |
tests/confidence/healthcheck.sh "${APP_HOSTNAME}" "${IMAGE_TAG#sha-}"
env:
APP_HOSTNAME: ${{ steps.set_env_var.outputs.app_hostname }}
IMAGE_TAG: ${{ inputs.sha }}
22 changes: 12 additions & 10 deletions tests/confidence/healthcheck.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,27 @@
### check the SHA against a passed in parameter
###
### Input parameters ( not validated )
### 1 URL
### 1 HOSTNAME
### 2 SHA
###
### Returns
### 1 on failure
### 0 on sucess
###
#################################################################################################
URL=${1}
set -eu

HOSTNAME=${1}
EXPECTED_SHA=${2}

#URL="get-into-teaching-api-dev"
#EXPECTED_SHA="730ff0a"
# Example:
# HOSTNAME="getintoteachingapi-test.test.teacherservices.cloud"
# EXPECTED_SHA="730ff0a"

rval=0
FULL_URL="https://${URL}.london.cloudapps.digital/api/operations/health_check"
http_status=$(curl -o /dev/null -s -w "%{http_code}" ${FULL_URL})
if [ "${http_status}" != "200" ]
FULL_URL="https://${HOSTNAME}/api/operations/health_check"
http_status=$(curl -o /dev/null -s -w "%{http_code}" ${FULL_URL})
if [ "${http_status}" != "200" ]
then
echo "HTTP Status ${http_status}"
rval=1
Expand All @@ -30,7 +33,7 @@ else

json=$(curl -s -X GET ${FULL_URL})
status=$( echo ${json} | jq -r .status)
if [ "${status}" == "unhealthy" ]
if [ "${status}" == "unhealthy" ]
then
echo "Application Status is Unhealthy"
rval=1
Expand All @@ -39,7 +42,7 @@ else
fi

sha=$( echo ${json} | jq -r .gitCommitSha)
if [ "${sha}" != "${EXPECTED_SHA}" ]
if [ "${sha}" != "${EXPECTED_SHA}" ]
then
echo "SHA is not ${EXPECTED_SHA}"
rval=1
Expand All @@ -48,4 +51,3 @@ else
fi
fi
exit ${rval}

0 comments on commit 18ee781

Please sign in to comment.