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 659f096
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions .github/scripts/post-elastic-test-queries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,42 @@

curl "$ELASTIC_HOST/_cat/indices"

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 found in elastic search"
else
echo "Empty or nonexistent response from elastic search"
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 found in elastic search"
else
echo "Empty or nonexistent response from elastic search"
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 \
--header 'Content-Type: application/x-www-form-urlencoded' \
Expand All @@ -27,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 @@ -43,5 +95,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 659f096

Please sign in to comment.