From 868418f4bcb64cc3bc81db8f74013af612c82a49 Mon Sep 17 00:00:00 2001 From: Jon Stutters Date: Wed, 31 Jan 2024 14:50:50 +0000 Subject: [PATCH] Improve orthanc-anon check The existing test script checked the orthanc-anon log for receipt of a DICOM but this was not catching that the received DICOM was not being stored due problems during anonymisation. The new check script queries the orthanc-anon API to make sure it has received and stored the test DICOMs. --- test/run-system-test.sh | 2 +- test/scripts/check_entry_in_orthanc_anon.py | 15 +++++++++++++++ test/scripts/check_entry_in_orthanc_anon.sh | 19 ------------------- 3 files changed, 16 insertions(+), 20 deletions(-) create mode 100755 test/scripts/check_entry_in_orthanc_anon.py delete mode 100755 test/scripts/check_entry_in_orthanc_anon.sh diff --git a/test/run-system-test.sh b/test/run-system-test.sh index 2817acd54..7a65e963f 100755 --- a/test/run-system-test.sh +++ b/test/run-system-test.sh @@ -32,7 +32,7 @@ pixl populate "${PACKAGE_DIR}/test/resources/omop" pixl start sleep 65 # need to wait until the DICOM image is "stable" = 60s ./scripts/check_entry_in_pixl_anon.sh -./scripts/check_entry_in_orthanc_anon.sh +./scripts/check_entry_in_orthanc_anon.py ./scripts/check_max_storage_in_orthanc_raw.sh pixl extract-radiology-reports "${PACKAGE_DIR}/test/resources/omop" diff --git a/test/scripts/check_entry_in_orthanc_anon.py b/test/scripts/check_entry_in_orthanc_anon.py new file mode 100755 index 000000000..88f7c9343 --- /dev/null +++ b/test/scripts/check_entry_in_orthanc_anon.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 + +# After pixl has run this script will query the orthanc-anon REST API to check +# that the correct number of instances have been received. + +import json +import shlex +import subprocess + + +instances_cmd = shlex.split('docker exec -it system-test-orthanc-anon-1 curl -u "orthanc_anon_username:orthanc_anon_password" http://orthanc-anon:8042/instances') +instances_output = subprocess.run(instances_cmd, capture_output=True, check=True, text=True) +instances = json.loads(instances_output.stdout) +print("orthanc-anon instances:", instances) +assert len(instances) == 2 diff --git a/test/scripts/check_entry_in_orthanc_anon.sh b/test/scripts/check_entry_in_orthanc_anon.sh deleted file mode 100755 index 253e981df..000000000 --- a/test/scripts/check_entry_in_orthanc_anon.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash -# Copyright (c) University College London Hospitals NHS Foundation Trust -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -set -euxo pipefail - -# This could be much improved by having more realistic test data some of -# which actually was persisted -docker logs system-test-orthanc-anon-1 2>&1 | grep "DICOM instance received"