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 0c73e13 commit a64afdc
Showing 1 changed file with 70 additions and 0 deletions.
70 changes: 70 additions & 0 deletions .github/scripts/post-elastic-test-queries.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,44 @@
#!/bin/bash -e

curl "$ELASTIC_HOST/_cat/indices"
ls -la
ls -la elastic

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)

if [ "$http_code" -eq 200 ]; then
if echo "$json_body" | jq '.found == true' | grep -q true; then
echo "Ontology Document with id $onto_example_id found in elastic search"
else
echo "Empty or nonexistent response from elastic search for ontology document with id $onto_example_id"
exit 1
fi
else
echo "Response code $http_code"
exit 1
fi


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)

if [ "$http_code" -eq 200 ]; then
if echo "$json_body" | jq '.found == true' | grep -q true; then
echo "Codeable Concept Document with id $cc_example_id found in elastic search"
else
echo "Empty or nonexistent response from elastic search for codeable_concept document with id $cc_example_id"
exit 1
fi
else
echo "Response code $http_code"
exit 1
fi

access_token="$(curl -s --request POST \
--url http://localhost:8083/auth/realms/dataportal/protocol/openid-connect/token \
Expand All @@ -27,6 +65,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 @@ -43,5 +97,21 @@ 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/$cc_example_id")
http_code="${response: -3}"
json_body=$(cat response_body)

if [ "$http_code" -eq 200 ]; then
if echo "$json_body" | jq -e '.code and .code != ""' | 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

echo "All elastic search tests completed"
exit 0

0 comments on commit a64afdc

Please sign in to comment.