-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from medizininformatik-initiative/feature/341…
…-add-elastic-search-to-github-integration-tests #341 - Add elastic search to github integration tests
- Loading branch information
Showing
6 changed files
with
186 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/bin/bash -e | ||
|
||
mkdir --parents .github/integration-test/ontology/ui_profiles .github/integration-test/ontology/migration | ||
curl -L https://github.com/medizininformatik-initiative/fhir-ontology-generator/raw/v3.0.0-test.1/example/fdpg-ontology/backend.zip -o .github/integration-test/ontology/backend.zip | ||
curl -L https://github.com/medizininformatik-initiative/fhir-ontology-generator/raw/${ONTOLOGY_GIT_TAG}/example/fdpg-ontology/backend.zip -o .github/integration-test/ontology/backend.zip | ||
unzip -jod .github/integration-test/ontology/ui_profiles/ .github/integration-test/ontology/backend.zip | ||
mv .github/integration-test/ontology/ui_profiles/R__Load_latest_ui_profile.sql .github/integration-test/ontology/migration/ | ||
rm .github/integration-test/ontology/backend.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/bin/bash -e | ||
|
||
ABSOLUTE_FILEPATH="${ELASTIC_FILEPATH//TAGPLACEHOLDER/$ONTOLOGY_GIT_TAG}$ELASTIC_FILENAME" | ||
echo "Downloading $ABSOLUTE_FILEPATH" | ||
response_onto_dl=$(curl --write-out "%{http_code}" -sLO "$ABSOLUTE_FILEPATH") | ||
|
||
if [ "$response_onto_dl" -ne 200 ]; then | ||
echo "Could not download ontology file. Maybe the tag $ONTOLOGY_GIT_TAG does not exist? Error code was $response_onto_dl" | ||
exit 1 | ||
fi | ||
|
||
unzip -o "$ELASTIC_FILENAME" | ||
|
||
echo "(Trying to) delete existing indices" | ||
curl --request DELETE "$ELASTIC_HOST/ontology" | ||
curl --request DELETE "$ELASTIC_HOST/codeable_concept" | ||
|
||
echo "Creating ontology index..." | ||
response_onto=$(curl --write-out "%{http_code}" -s --output /dev/null -XPUT -H 'Content-Type: application/json' "$ELASTIC_HOST/ontology" -d @elastic/ontology_index.json) | ||
echo "Creating codeable concept index..." | ||
response_cc=$(curl --write-out "%{http_code}" -s --output /dev/null -XPUT -H 'Content-Type: application/json' "$ELASTIC_HOST/codeable_concept" -d @elastic/codeable_concept_index.json) | ||
echo "Done." | ||
|
||
for FILE in elastic/*; do | ||
if [ -f "$FILE" ]; then | ||
BASENAME=$(basename "$FILE") | ||
if [[ $BASENAME == onto_es__ontology* && $BASENAME == *.json ]]; then | ||
if [[ "$response_onto" -eq 200 || "$OVERRIDE_EXISTING" = "true" ]]; then | ||
echo "Uploading $BASENAME" | ||
curl -s --output /dev/null -XPOST -H 'Content-Type: application/json' --data-binary @"$FILE" "$ELASTIC_HOST/ontology/_bulk" | ||
else | ||
echo "Skipping $BASENAME because index was already existing. Set OVERRIDE_EXISTING to true to force creating a new index" | ||
fi | ||
fi | ||
if [[ $BASENAME == onto_es__codeable_concept* && $BASENAME == *.json ]]; then | ||
if [[ "$response_cc" -eq 200 || "$OVERRIDE_EXISTING" = "true" ]]; then | ||
echo "Uploading $BASENAME" | ||
curl -s --output /dev/null -XPOST -H 'Content-Type: application/json' --data-binary @"$FILE" "$ELASTIC_HOST/codeable_concept/_bulk" | ||
else | ||
echo "Skipping $BASENAME because index was already existing. Set OVERRIDE_EXISTING to true to force creating a new index" | ||
fi | ||
fi | ||
fi | ||
done | ||
|
||
echo "All done" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash -e | ||
|
||
curl "$ELASTIC_HOST/_cat/indices" | ||
|
||
response=$(curl -s -w "%{http_code}" -o response_body "$ELASTIC_HOST/ontology/_doc/9c2328b0-ac4e-3d69-8f2f-d8b905875348") | ||
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/d676be36-7f34-3ea6-9838-c0c9e1ca3dcc") | ||
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' \ | ||
--data grant_type=password \ | ||
--data client_id=dataportal-webapp \ | ||
--data username=testuser \ | ||
--data password=testpassword \ | ||
--data scope=openid | jq '.access_token' | tr -d '"')" | ||
|
||
response=$(curl -s -w "%{http_code}" --header "Authorization: Bearer $access_token" -o response_body "http://localhost:8091/api/v4/terminology/entry/search?searchterm=Blutdruck") | ||
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) | ||
|
||
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/d676be36-7f34-3ea6-9838-c0c9e1ca3dcc") | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters