From ff0f21ba879f96efd0fe6557e39eb8cfaf7ae371 Mon Sep 17 00:00:00 2001 From: vasudevganesanhmcts <100689363+vasudevganesanhmcts@users.noreply.github.com> Date: Wed, 10 Apr 2024 15:29:15 +0100 Subject: [PATCH] CIV-0000 import ccd definition sh errors on smoke test (#942) * 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 --- Jenkinsfile_CNP | 4 ++- bin/utils/ccd-import-definition.sh | 35 +++++++++++++++++-- charts/civil-camunda/values.aat.template.yaml | 2 ++ .../values.preview.template.yaml | 2 ++ 4 files changed, 40 insertions(+), 3 deletions(-) diff --git a/Jenkinsfile_CNP b/Jenkinsfile_CNP index 75d8c7bb6..1ac8e05fa 100644 --- a/Jenkinsfile_CNP +++ b/Jenkinsfile_CNP @@ -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') diff --git a/bin/utils/ccd-import-definition.sh b/bin/utils/ccd-import-definition.sh index 465f958af..5199cbfe0 100755 --- a/bin/utils/ccd-import-definition.sh +++ b/bin/utils/ccd-import-definition.sh @@ -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 diff --git a/charts/civil-camunda/values.aat.template.yaml b/charts/civil-camunda/values.aat.template.yaml index da2585350..d05ae3468 100644 --- a/charts/civil-camunda/values.aat.template.yaml +++ b/charts/civil-camunda/values.aat.template.yaml @@ -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 diff --git a/charts/civil-camunda/values.preview.template.yaml b/charts/civil-camunda/values.preview.template.yaml index 392f6e6e7..5c99385cb 100644 --- a/charts/civil-camunda/values.preview.template.yaml +++ b/charts/civil-camunda/values.preview.template.yaml @@ -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