From 2c36f82a3c05ce9060766346916cbae83f0bcc3f Mon Sep 17 00:00:00 2001 From: Michael Folz Date: Wed, 15 Jan 2025 14:16:09 +0100 Subject: [PATCH] #428 - Read document ids from downloaded files in github integration tests - use grep/awk to extract the first id from an ontology and a codeable_concept file to use for checks --- .github/scripts/post-elastic-test-queries.sh | 25 +++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/.github/scripts/post-elastic-test-queries.sh b/.github/scripts/post-elastic-test-queries.sh index e6db4a06..a917705d 100755 --- a/.github/scripts/post-elastic-test-queries.sh +++ b/.github/scripts/post-elastic-test-queries.sh @@ -2,7 +2,10 @@ curl "$ELASTIC_HOST/_cat/indices" -response=$(curl -s -w "%{http_code}" -o response_body "$ELASTIC_HOST/ontology/_doc/9c2328b0-ac4e-3d69-8f2f-d8b905875348") +onto_example_id=$(grep '"_id":' elastic/onto_es__ontology_* | awk -F'"_id": "' '{print $2}' | awk -F'"' '{print $1}' | head -n 1) +cc_example_id=$(grep '"_id":' elastic/onto_es__codeable_concept_* | awk -F'"_id": "' '{print $2}' | awk -F'"' '{print $1}' | head -n 1) + +response=$(curl -s -w "%{http_code}" -o response_body "$ELASTIC_HOST/ontology/_doc/$onto_example_id") http_code="${response: -3}" json_body=$(cat response_body) @@ -19,7 +22,7 @@ else fi -response=$(curl -s -w "%{http_code}" -o response_body "$ELASTIC_HOST/codeable_concept/_doc/d676be36-7f34-3ea6-9838-c0c9e1ca3dcc") +response=$(curl -s -w "%{http_code}" -o response_body "$ELASTIC_HOST/codeable_concept/_doc/$cc_example_id") http_code="${response: -3}" json_body=$(cat response_body) @@ -60,6 +63,22 @@ else exit 1 fi +response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer $access_token" -o response_body "http://localhost:8091/api/v4/terminology/entry/$onto_example_id") +http_code="${response: -3}" +json_body=$(cat response_body) + +if [ "$http_code" -eq 200 ]; then + if echo "$json_body" | jq '.totalHits > 0' | grep -q true; then + echo "OK response with non-empty array" + else + echo "Empty or nonexistent response" + exit 1 + fi +else + echo "Response code $http_code" + exit 1 +fi + response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer $access_token" -o response_body "http://localhost:8091/api/v4/codeable-concept/entry/search?searchterm=Vectorcardiogram") http_code="${response: -3}" json_body=$(cat response_body) @@ -76,7 +95,7 @@ else exit 1 fi -response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer $access_token" -o response_body "http://localhost:8091/api/v4/codeable-concept/entry/d676be36-7f34-3ea6-9838-c0c9e1ca3dcc") +response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer $access_token" -o response_body "http://localhost:8091/api/v4/codeable-concept/entry/$cc_example_id") http_code="${response: -3}" json_body=$(cat response_body)