Skip to content

Commit

Permalink
#428 - Read document ids from downloaded files in github integration …
Browse files Browse the repository at this point in the history
…tests

- use grep/awk to extract the first id from an ontology and a codeable_concept file to use for checks
  • Loading branch information
michael-82 committed Jan 15, 2025
1 parent 5792b49 commit 2c36f82
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions .github/scripts/post-elastic-test-queries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)

Expand Down Expand Up @@ -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)
Expand All @@ -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)

Expand Down

0 comments on commit 2c36f82

Please sign in to comment.