Skip to content

Commit

Permalink
CIV-0000 import ccd definition sh errors on smoke test (#942)
Browse files Browse the repository at this point in the history
* changes required similar to civil service

* adding http 1.1

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* Update ccd-import-definition.sh

* version changes
  • Loading branch information
vasudevganesanhmcts authored Apr 10, 2024
1 parent f33665f commit ff0f21b
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 3 deletions.
4 changes: 3 additions & 1 deletion Jenkinsfile_CNP
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,14 @@ withPipeline(type, product, component) {


before('smoketest:preview') {
sh """
retry (3) {
sh """
eval \$(./bin/variables/load-preview-environment-variables.sh ${CHANGE_ID})
./bin/add-roles.sh
./bin/pull-latest-ccd-files.sh ${ccdBranch}
./bin/import-ccd-definition.sh "-e *-prod.json,*HNL-nonprod.json,*-shuttered.json"
"""
}
env.URL="https://xui-civil-camunda-pr-${CHANGE_ID}.preview.platform.hmcts.net"
env.CIVIL_SERVICE_URL="https://civil-camunda-pr-${CHANGE_ID}.preview.platform.hmcts.net"
yarnBuilder.yarn('yarn-update')
Expand Down
35 changes: 33 additions & 2 deletions bin/utils/ccd-import-definition.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,46 @@ uploadFilename="$(date +"%Y%m%d-%H%M%S")-${filename}"
userToken=$(${dir}/idam-lease-user-token.sh ${CCD_CONFIGURER_IMPORTER_USERNAME:-ccd.docker.default@hmcts.net} ${CCD_CONFIGURER_IMPORTER_PASSWORD:-Password12!})
serviceToken=$(${dir}/idam-lease-service-token.sh ccd_gw $(docker run --rm toolbelt/oathtool --totp -b ${CCD_API_GATEWAY_S2S_SECRET:-AAAAAAAAAAAAAAAC}))

uploadResponse=$(curl --insecure --silent -w "\n%{http_code}" --show-error -X POST \
version="n/a"
newVersion="n/a"

if [[ "${ENVIRONMENT}" == "preview" ]]; then
version=$(curl --insecure --silent --show-error -X GET \
${CCD_DEFINITION_STORE_API_BASE_URL:-http://localhost:4451}/api/data/case-type/CIVIL/version \
-H "Authorization: Bearer ${userToken}" \
-H "ServiceAuthorization: Bearer ${serviceToken}" || echo 'bypass-if-error')

echo "Current version is ${version}"
fi

uploadResponse=$(curl --insecure --silent -w "\n%{http_code}" --show-error --max-time 60 -X POST \
${CCD_DEFINITION_STORE_API_BASE_URL:-http://localhost:4451}/import \
-H "Authorization: Bearer ${userToken}" \
-H "ServiceAuthorization: Bearer ${serviceToken}" \
-F "file=@${filepath};filename=${uploadFilename}")
-F "file=@${filepath};filename=${uploadFilename}" || echo 'bypass-if-error')

upload_http_code=$(echo "$uploadResponse" | tail -n1)
upload_response_content=$(echo "$uploadResponse" | sed '$d')

if [ "${ENVIRONMENT}" == "preview" ] && [ "${upload_http_code}" != "201" ]; then
echo "Bypassing audit check as on preview - will wait 45s and then verify the version has changed"
sleep 45

newVersion=$(curl --insecure --silent --show-error -X GET \
${CCD_DEFINITION_STORE_API_BASE_URL:-http://localhost:4451}/api/data/case-type/CIVIL/version \
-H "Authorization: Bearer ${userToken}" \
-H "ServiceAuthorization: Bearer ${serviceToken}" || echo 'bypass-if-error')

echo "Current version is ${newVersion}"
if [[ "$newVersion" == "$version" ]]; then
echo "Version has not changed - the definition was not imported successfully"
exit 1
fi

echo "CCD definition version has changed, definition successfully uploaded"
exit 0
fi

if [[ "${upload_http_code}" == '504' ]]; then
for try in {1..10}
do
Expand Down
2 changes: 2 additions & 0 deletions charts/civil-camunda/values.aat.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ ccd:
DEFINITION_STORE_IDAM_KEY: ${CCD_DEFINITION_STORE_S2S_SECRET}
IDAM_USER_URL: https://idam-web-public.aat.platform.hmcts.net
RELEASE_REVISION: "{{ .Release.Revision }}"
DEFINITION_STORE_TX_TIMEOUT_DEFAULT: 60
WELSH_TRANSLATION_ENABLED: false
disableKeyVaults: true
ingressHost: civil-camunda-definition-store-staging-aat.service.core-compute-aat.internal

Expand Down
2 changes: 2 additions & 0 deletions charts/civil-camunda/values.preview.template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ ccd:
environment:
APPLICATION_LOGGING_LEVEL: DEBUG
SPRING_DATASOURCE_HIKARI_CONNECTIONTIMEOUT: 90000
DEFINITION_STORE_TX_TIMEOUT_DEFAULT: 60
WELSH_TRANSLATION_ENABLED: false
DEFINITION_STORE_DB_HOST: ${SERVICE_NAME}-postgresql
DEFINITION_STORE_IDAM_KEY: ${CCD_DEFINITION_STORE_S2S_SECRET}
IDAM_USER_URL: https://idam-web-public.aat.platform.hmcts.net
Expand Down

0 comments on commit ff0f21b

Please sign in to comment.