ci: Always use _search API instead of _count

Makes it easier to troubleshoot returned documents by inspecting the
logs of CI runs.
This commit is contained in:
Antoine Cotten 2021-11-06 12:06:31 +01:00
parent e9903fecf6
commit b826d7bbdf
No known key found for this signature in database
GPG Key ID: 94637E68D4A79DD0
2 changed files with 5 additions and 4 deletions

View File

@ -36,6 +36,7 @@ curl -X POST -D- "http://${ip_kb}:5601/api/saved_objects/index-pattern" \
log 'Searching index pattern via Kibana API'
response="$(curl "http://${ip_kb}:5601/api/saved_objects/_find?type=index-pattern" -s -u elastic:testpasswd)"
echo "$response"
declare -i count
count="$(jq -rn --argjson data "${response}" '$data.total')"
if (( count != 1 )); then
echo "Expected 1 index pattern, got ${count}"
@ -66,9 +67,9 @@ curl -X POST "http://${ip_es}:9200/_refresh" -u elastic:testpasswd \
-s -w '\n'
log 'Searching message in Elasticsearch'
response="$(curl "http://${ip_es}:9200/logstash-*/_count?q=message:dockerelk&pretty" -s -u elastic:testpasswd)"
response="$(curl "http://${ip_es}:9200/logstash-*/_search?q=message:dockerelk&pretty" -s -u elastic:testpasswd)"
echo "$response"
count="$(jq -rn --argjson data "${response}" '$data.count')"
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
if (( count != 1 )); then
echo "Expected 1 document, got ${count}"
exit 1

View File

@ -20,10 +20,10 @@ log 'Waiting for readiness of Enterprise Search'
poll_ready "$cid_en" "http://${ip_en}:3002/api/ent/v1/internal/health" -u 'elastic:testpasswd'
log 'Ensuring that App Search API keys were created in Elasticsearch'
response="$(curl "http://${ip_es}:9200/.ent-search-actastic-app_search_api_tokens_v3/_count?pretty" -s -u elastic:testpasswd)"
response="$(curl "http://${ip_es}:9200/.ent-search-actastic-app_search_api_tokens_v3/_search?q=*:*&pretty" -s -u elastic:testpasswd)"
echo "$response"
declare -i count
count="$(jq -rn --argjson data "${response}" '$data.count')"
count="$(jq -rn --argjson data "${response}" '$data.hits.total.value')"
if (( count != 2)); then
echo "Expected search and private keys, got ${count} result(s)"
exit 1