Skip to content

[8.19] (backport #17028) Smoke test os retry event assertions #17067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ output:
hosts: [ ${elasticsearch_url} ]
username: ${elasticsearch_username}
password: ${elasticsearch_password}
flush_interval: 100ms
logging.level: debug
logging.to_files: true
logging.files:
Expand Down
32 changes: 26 additions & 6 deletions testing/smoke/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ assert_entry() {
if [[ ${HITS} -ne ${ENTRIES} ]]; then
echo "Didn't find ${ENTRIES} indexed documents ${MSG}, total hits ${HITS}"
echo ${RESULT}
exit 2
return 2
else
echo "-> Asserted ${ENTRIES} ${MSG} exists"
fi
Expand All @@ -141,7 +141,7 @@ send_events() {
curl_fail --data-binary @${INTAKE_DATA} -H "${APM_AUTH_HEADER}" -H "${INTAKE_HEADER}" ${APM_SERVER_INTAKE}

# TODO(marclop). It would be best to query Elasticsearch until at least X documents have been ingested.
sleep 10
sleep 5
}

delete_all() {
Expand Down Expand Up @@ -169,10 +169,10 @@ data_stream_assert_events() {
local METRICS_INDEX="metrics-apm.internal-*"
local VERSION=${1}
local ENTRIES=${2}
assert_document ${ERRORS_INDEX} "error.id" "9876543210abcdeffedcba0123456789" ${VERSION} ${ENTRIES}
assert_document ${TRACES_INDEX} "span.id" "1234567890aaaade" ${VERSION} ${ENTRIES}
assert_document ${TRACES_INDEX} "transaction.id" "4340a8e0df1906ecbfa9" ${VERSION} ${ENTRIES}
assert_document ${METRICS_INDEX} "transaction.type" "request" ${VERSION} ${ENTRIES}
retry 6 assert_document ${ERRORS_INDEX} "error.id" "9876543210abcdeffedcba0123456789" ${VERSION} ${ENTRIES}
retry 6 assert_document ${TRACES_INDEX} "span.id" "1234567890aaaade" ${VERSION} ${ENTRIES}
retry 6 assert_document ${TRACES_INDEX} "transaction.id" "4340a8e0df1906ecbfa9" ${VERSION} ${ENTRIES}
retry 6 assert_document ${METRICS_INDEX} "transaction.type" "request" ${VERSION} ${ENTRIES}
}

healthcheck() {
Expand Down Expand Up @@ -418,3 +418,23 @@ is_curl_fail_with_body() {
fi
return $HAS_FAIL_WITH_BODY
}

retry() {
local retries=$1
shift

local count=0
until "$@"; do
exit=$?
wait=$((2 ** count))
count=$((count + 1))
if [ $count -lt "$retries" ]; then
echo "-> Retry cmd: '$*'; $count/$retries exited $exit, retrying in $wait seconds..."
sleep $wait
else
echo "-> Retry cmd: '$*'; $count/$retries exited $exit, no more retries left."
return $exit
fi
done
return 0
}