Skip to content

Commit

Permalink
Test SNAPSHOT in smoketests (#13147)
Browse files Browse the repository at this point in the history
Support "latest" in lagacy-managed and legacy-standalone-major-managed by testing snapshots.
  • Loading branch information
carsonip authored Jun 4, 2024
1 parent 763b64f commit 218cc96
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
17 changes: 12 additions & 5 deletions testing/smoke/legacy-managed/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eo pipefail

if [[ "${1}" != "7.17" ]]; then
if [[ "${1}" != "7.17" && "${1}" != "latest" ]]; then
echo "-> Skipping smoke test ['${1}' is not supported]..."
exit 0
fi
Expand All @@ -11,8 +11,15 @@ fi

VERSION=7.17
get_versions
get_latest_patch ${VERSION}
LATEST_VERSION=${VERSION}.${LATEST_PATCH}
if [[ "${1}" == "latest" ]]; then
get_latest_snapshot_for_version ${VERSION}
LATEST_VERSION=${LATEST_SNAPSHOT_VERSION}
ASSERTION_VERSION=${LATEST_SNAPSHOT_VERSION%-*} # strip -SNAPSHOT suffix
else
get_latest_patch ${VERSION}
LATEST_VERSION=${VERSION}.${LATEST_PATCH}
ASSERTION_VERSION=${LATEST_VERSION}
fi

echo "-> Running ${LATEST_VERSION} standalone to ${LATEST_VERSION} managed upgrade"

Expand All @@ -27,10 +34,10 @@ append_tfvar "integrations_server" ${INTEGRATIONS_SERVER}
terraform_apply
healthcheck 1
send_events
legacy_assertions ${LATEST_VERSION}
legacy_assertions ${ASSERTION_VERSION}

echo "-> Upgrading APM Server to managed mode"
upgrade_managed ${LATEST_VERSION} ${INTEGRATIONS_SERVER}
healthcheck 1
send_events
data_stream_assertions ${LATEST_VERSION}
data_stream_assertions ${ASSERTION_VERSION}
26 changes: 19 additions & 7 deletions testing/smoke/legacy-standalone-major-managed/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

set -eo pipefail

if [[ "${1}" != "7.17" ]]; then
if [[ "${1}" != "7.17" && "${1}" != "latest" ]]; then
echo "-> Skipping smoke test ['${1}' is not supported]..."
exit 0
fi
Expand All @@ -11,9 +11,21 @@ fi

VERSION=7.17
get_versions
get_latest_patch ${VERSION}
LATEST_VERSION=${VERSION}.${LATEST_PATCH}
NEXT_MAJOR_LATEST=$(echo ${VERSIONS} | jq -r '[.[] | select(. | startswith("8"))] | last')
if [[ "${1}" == "latest" ]]; then
# a SNAPSHOT version can only be upgraded to another SNAPSHOT version
get_latest_snapshot_for_version ${VERSION}
LATEST_VERSION=${LATEST_SNAPSHOT_VERSION}
ASSERTION_VERSION=${LATEST_SNAPSHOT_VERSION%-*} # strip -SNAPSHOT suffix
get_latest_snapshot
NEXT_MAJOR_LATEST=$(echo $VERSIONS | jq -r -c '.[-1]')
ASSERTION_NEXT_MAJOR_LATEST=${NEXT_MAJOR_LATEST%-*} # strip -SNAPSHOT suffix
else
get_latest_patch ${VERSION}
LATEST_VERSION=${VERSION}.${LATEST_PATCH}
ASSERTION_VERSION=${LATEST_VERSION}
NEXT_MAJOR_LATEST=$(echo ${VERSIONS} | jq -r '[.[] | select(. | startswith("8"))] | last')
ASSERTION_NEXT_MAJOR_LATEST=${NEXT_MAJOR_LATEST}
fi

echo "-> Running ${LATEST_VERSION} standalone to ${NEXT_MAJOR_LATEST} to ${NEXT_MAJOR_LATEST} managed"

Expand All @@ -28,19 +40,19 @@ append_tfvar "integrations_server" ${INTEGRATIONS_SERVER}
terraform_apply
healthcheck 1
send_events
legacy_assertions ${LATEST_VERSION}
legacy_assertions ${ASSERTION_VERSION}

cleanup_tfvar
append_tfvar "stack_version" ${NEXT_MAJOR_LATEST}
append_tfvar "integrations_server" ${INTEGRATIONS_SERVER}
terraform_apply
healthcheck 1
send_events
data_stream_assertions ${NEXT_MAJOR_LATEST}
data_stream_assertions ${ASSERTION_NEXT_MAJOR_LATEST}

upgrade_managed ${NEXT_MAJOR_LATEST}
healthcheck 1
send_events
# Assert there are 2 instances of the same event, since we ingested data twice
# using the same APM Server version.
data_stream_assertions ${NEXT_MAJOR_LATEST} 2
data_stream_assertions ${ASSERTION_NEXT_MAJOR_LATEST} 2
11 changes: 10 additions & 1 deletion testing/smoke/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ get_latest_snapshot() {
VERSIONS=$(echo "${RES}" | jq -r -c '[.stacks[].version | select(. | contains("-SNAPSHOT"))] | sort' | sed 's#-SNAPSHOT#.0#g' | jq -r -c ' sort_by(.| split(".") | map(tonumber))' | sed 's#.0"#-SNAPSHOT"#g' | jq -r -c .)
}

get_latest_snapshot_for_version() {
if [[ -z "${1}" ]]; then
echo "-> Version not set"
return 1
fi
get_latest_snapshot
LATEST_SNAPSHOT_VERSION=$(echo "$VERSIONS" | jq -r -c "map(select(. | startswith(\"${1}\"))) | .[-1]")
}

terraform_init() {
if [[ ! -f main.tf ]]; then cp ../main.tf .; fi
terraform init >> tf.log
Expand Down Expand Up @@ -103,7 +112,7 @@ assert_document() {
RESULT=$(curl_fail -u ${AUTH} -XGET "${URL}" -H 'Content-Type: application/json' -d"{\"query\":{\"bool\":{\"must\":[{\"match\":{\"${FIELD}\":\"${VALUE}\"}},{\"match\":{\"observer.version\":\"${VERSION}\"}}]}}}") || RC=$?
if [ $RC -ne 0 ]; then echo "${RESULT}"; fi

echo "-> Asserting ${INDEX} contains expected documents documents..."
echo "-> Asserting ${INDEX} contains expected documents..."
assert_entry ${FIELD} ${VALUE} ${ENTRIES}
}

Expand Down

0 comments on commit 218cc96

Please sign in to comment.