From 19a77591e1e416f332c27171ca9b37a7de5dbd79 Mon Sep 17 00:00:00 2001 From: PrasannaHegde1 <109784806+PrasannaHegde1@users.noreply.github.com> Date: Fri, 11 Nov 2022 18:25:33 +0530 Subject: [PATCH] correcting audit integration test script file (#4071) * correcting audit integration test script file Signed-off-by: PrasannaHegde1 * correcting audit integration test script file Signed-off-by: PrasannaHegde1 * correcting audit integration test script file Signed-off-by: PrasannaHegde1 * e2e-audit should fail if tests fail Signed-off-by: Lee Surprenant * disable TTY for docker-compose exec To fix issue where the script bombs out with 'the input device is not a TTY'. From the man page for docker-compose exec `-T`: Disable pseudo-tty allocation. By default docker-compose exec allocates a TTY. Signed-off-by: Lee Surprenant * Copy over tenant1 derby datasource definitions Signed-off-by: Lee Surprenant * adding overrides target to docker compose file Signed-off-by: PrasannaHegde1 * adding erase operation config to fhir-server-config-audit-cicd.json Signed-off-by: PrasannaHegde1 * adding X-FHIR-FORWARDED-URL config to fhir-server-config-audit-cicd.json Signed-off-by: PrasannaHegde1 Signed-off-by: PrasannaHegde1 Signed-off-by: Lee Surprenant Co-authored-by: Lee Surprenant --- .github/workflows/audit.yml | 3 ++- build/audit/bin/gather-logs.sh | 14 +++++++++----- build/audit/bin/pre-integration-test.sh | 3 +++ build/audit/kafka/docker-compose.yml | 4 ++++ build/audit/kafka/integration-test.sh | 5 ++--- build/audit/kafka/pre-integration-test.sh | 8 ++++++-- build/notifications/bin/gather-logs.sh | 14 +++++++++----- build/persistence/bin/gather-logs.sh | 6 ++++-- .../default/fhir-server-config-audit-cicd.json | 10 ++++++++++ 9 files changed, 49 insertions(+), 18 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index 0bd54229845..dab26d24f1a 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -34,7 +34,8 @@ jobs: - name: Server Integration Tests - Audit env: WORKSPACE: ${{ github.workspace }} - shell: 'script -q -e -c "bash {0}"' + # fail-fast behavior is set when `shell: bash` is explicitly specified. It is not applied by default. + shell: bash run: | bash build/audit/bin/pre-integration-test.sh ${{matrix.audit}} bash build/audit/bin/integration-test.sh ${{matrix.audit}} diff --git a/build/audit/bin/gather-logs.sh b/build/audit/bin/gather-logs.sh index 668faf2cf58..a63b1967de0 100644 --- a/build/audit/bin/gather-logs.sh +++ b/build/audit/bin/gather-logs.sh @@ -34,11 +34,15 @@ package_logs(){ docker cp -L $containerId:/logs ${it_results}/server-logs fi - echo "Gathering integration test output" - cp -pr ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test - - echo "Move the ${1} Elements too the output area'" - cp -pr ${WORKSPACE}/build/audit/${1}/workarea/* ${it_results} + if [ -d "${WORKSPACE}/fhir-server-test/target/surefire-reports" ]; then + echo "Gathering integration test output" + cp -r ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test + fi + + if [ -d "${WORKSPACE}/build/audit/${1}/workarea" ]; then + echo "Move the ${1} files to the output area'" + cp -r ${WORKSPACE}/build/audit/${1}/workarea/* ${it_results} + fi } ############################################################################### diff --git a/build/audit/bin/pre-integration-test.sh b/build/audit/bin/pre-integration-test.sh index 220d2f83342..67bdf750b81 100755 --- a/build/audit/bin/pre-integration-test.sh +++ b/build/audit/bin/pre-integration-test.sh @@ -31,6 +31,9 @@ pushd $(pwd) > /dev/null # Change to the audit_pre cd "${WORKSPACE}" +# Source the tenant1 datastore variables +. ${WORKSPACE}/build/common/set-tenant1-datastore-vars.sh + audit_pre "${1}" # Reset to Original Directory diff --git a/build/audit/kafka/docker-compose.yml b/build/audit/kafka/docker-compose.yml index 70d4d9099fc..db584da4997 100644 --- a/build/audit/kafka/docker-compose.yml +++ b/build/audit/kafka/docker-compose.yml @@ -59,6 +59,10 @@ services: source: ./workarea/volumes/dist/config target: /opt/ol/wlp/usr/servers/defaultServer/config read_only: true + - type: bind + source: ./workarea/volumes/dist/overrides + target: /opt/ol/wlp/usr/servers/defaultServer/configDropins/overrides + read_only: true - type: bind source: ./workarea/volumes/dist/userlib/ target: /opt/ol/wlp/usr/servers/defaultServer/userlib diff --git a/build/audit/kafka/integration-test.sh b/build/audit/kafka/integration-test.sh index 825be38086d..cf7eba7afff 100644 --- a/build/audit/kafka/integration-test.sh +++ b/build/audit/kafka/integration-test.sh @@ -5,8 +5,7 @@ # # SPDX-License-Identifier: Apache-2.0 ############################################################################### - -set -o errexit +set -e set -o nounset set -o pipefail @@ -28,7 +27,7 @@ mvn -B -nsu -ntp test -DskipTests=false -f fhir-server-test -DskipWebSocketTest= # The following test should always Run echo "TEST_CONFIGURATION: check that there is output and the configuration works" -docker-compose -f build/audit/kafka/docker-compose.yml exec kafka-1 bash /bin/kafka-console-consumer --timeout-ms 60000 --bootstrap-server=kafka-1:19092,kafka-2:29092 \ +docker-compose -f build/audit/kafka/docker-compose.yml exec -T kafka-1 bash /bin/kafka-console-consumer --timeout-ms 60000 --bootstrap-server=kafka-1:19092,kafka-2:29092 \ --topic FHIR_AUDIT --max-messages 25 --property print.timestamp=true --offset earliest \ --consumer.config /etc/kafka/secrets/client-ssl.properties \ --partition 1 > ${WORKSPACE}/build/audit/kafka/workarea/output/fhir_audit-messages.log diff --git a/build/audit/kafka/pre-integration-test.sh b/build/audit/kafka/pre-integration-test.sh index aa4fb73e574..ffa25c6817b 100644 --- a/build/audit/kafka/pre-integration-test.sh +++ b/build/audit/kafka/pre-integration-test.sh @@ -7,6 +7,7 @@ ############################################################################### set -ex +export WORKSPACE=$(pwd) DIST="${WORKSPACE}/build/audit/kafka/workarea/volumes/dist" # pre_integration @@ -21,7 +22,7 @@ config(){ mkdir -p ${DIST}/userlib mkdir -p ${DIST}/ mkdir -p ${WORKSPACE}/build/audit/kafka/workarea/output - + mkdir -p ${DIST}/overrides touch ${WORKSPACE}/build/audit/kafka/workarea/output/fhir_audit-messages.log chmod +rwx ${WORKSPACE}/build/audit/kafka/workarea/output/fhir_audit-messages.log chmod -R 777 ${WORKSPACE}/build/audit/kafka/workarea/output/ @@ -29,6 +30,8 @@ config(){ echo "Copying fhir configuration files..." cp -r ${WORKSPACE}/fhir-server-webapp/src/main/liberty/config/config $DIST/ cp -r ${WORKSPACE}/fhir-server-webapp/src/test/liberty/config/config/* $DIST/config/ + # Copy over the tenant1 derby datasource definitions + cp ${WORKSPACE}/fhir-server-webapp/src/test/liberty/config/configDropins/overrides/datasource-derby.xml $DIST/overrides/datasource-derby.xml echo "Copying test artifacts to install location..." USERLIB="${DIST}/userlib" @@ -36,6 +39,7 @@ config(){ find ${WORKSPACE}/conformance -iname 'fhir-ig*.jar' -not -iname 'fhir*-tests.jar' -not -iname 'fhir*-test-*.jar' -exec cp -f {} ${USERLIB} \; cp ${WORKSPACE}/operation/fhir-operation-test/target/fhir-operation-*.jar ${USERLIB} cp ${WORKSPACE}/term/operation/fhir-operation-term-cache/target/fhir-operation-*.jar ${USERLIB} + echo "Finished copying fhir-server dependencies..." # Move over the test configurations @@ -117,7 +121,7 @@ bringup(){ echo "The fhir-server appears to be running..." # Create the FHIR_AUDIT topic - docker-compose -f build/audit/kafka/docker-compose.yml exec kafka-1 bash /bin/kafka-topics \ + docker-compose -f build/audit/kafka/docker-compose.yml exec -T kafka-1 bash /bin/kafka-topics \ --bootstrap-server kafka-1:19092,kafka-2:29092 --command-config /etc/kafka/secrets/client-ssl.properties \ --create --topic FHIR_AUDIT --partitions 10 --replication-factor 2 [ $? -eq 0 ] || exit 9 diff --git a/build/notifications/bin/gather-logs.sh b/build/notifications/bin/gather-logs.sh index 7c74848be15..1d56171ff59 100644 --- a/build/notifications/bin/gather-logs.sh +++ b/build/notifications/bin/gather-logs.sh @@ -34,11 +34,15 @@ package_logs(){ docker cp -L $containerId:/logs ${it_results}/server-logs fi - echo "Gathering integration test output" - cp -pr ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test - - echo "Move the ${1} Elements too the output area'" - cp -pr ${WORKSPACE}/build/notifications/${1}/workarea/* ${it_results} + if [ -d "${WORKSPACE}/fhir-server-test/target/surefire-reports" ]; then + echo "Gathering integration test output" + cp -r ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test + fi + + if [ -d "${WORKSPACE}/build/notifications/${1}/workarea" ]; then + echo "Move the ${1} files to the output area'" + cp -r ${WORKSPACE}/build/notifications/${1}/workarea/* ${it_results} + fi } ############################################################################### diff --git a/build/persistence/bin/gather-logs.sh b/build/persistence/bin/gather-logs.sh index 292ee57bbfd..a1f6be87c9e 100644 --- a/build/persistence/bin/gather-logs.sh +++ b/build/persistence/bin/gather-logs.sh @@ -34,8 +34,10 @@ package_logs(){ docker cp -L $containerId:/logs ${it_results}/server-logs fi - echo "Gathering integration test output" - cp -pr ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test + if [ -d "${WORKSPACE}/fhir-server-test/target/surefire-reports" ]; then + echo "Gathering integration test output" + cp -r ${WORKSPACE}/fhir-server-test/target/surefire-reports/* ${it_results}/fhir-server-test + fi } ############################################################################### diff --git a/fhir-server-webapp/src/test/liberty/config/config/default/fhir-server-config-audit-cicd.json b/fhir-server-webapp/src/test/liberty/config/config/default/fhir-server-config-audit-cicd.json index 52f7e73c2b9..6e60da9fcef 100644 --- a/fhir-server-webapp/src/test/liberty/config/config/default/fhir-server-config-audit-cicd.json +++ b/fhir-server-webapp/src/test/liberty/config/config/default/fhir-server-config-audit-cicd.json @@ -4,6 +4,7 @@ "core": { "tenantIdHeaderName": "X-FHIR-TENANT-ID", "datastoreIdHeaderName": "X-FHIR-DSID", + "originalRequestUriHeaderName": "X-FHIR-FORWARDED-URL", "checkReferenceTypes": true, "conditionalDeleteMaxNumber": 10, "__comment": "The CI changes this to true, and the false is intentional as we recommend for performance reasons.", @@ -142,6 +143,15 @@ }, "bulkdata": { "enabled": false + }, + "operations": { + "erase": { + "enabled": true, + "allowedRoles": [ + "FHIROperationAdmin", + "FHIRUsers" + ] + } } } }