-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc78850
commit 8db04b3
Showing
3 changed files
with
65 additions
and
4 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
File renamed without changes.
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,61 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
IFS=$'\n\t' | ||
|
||
#/ Usage: review_results.sh path/to/baseline.json path/to/otel.json 200 | ||
#/ Description: A script to reviewing and failing if we go over our performance budget | ||
#/ Options: | ||
#/ --help: Display this help message | ||
usage() { grep '^#/' "$0" | cut -c4- ; exit 0 ; } | ||
expr "$*" : ".*--help" > /dev/null && usage | ||
|
||
echoerr() { printf "%s\n" "$*" >&2 ; } | ||
info() { echoerr "[INFO] $*" ; } | ||
warning() { echoerr "[WARNING] $*" ; } | ||
error() { echoerr "[ERROR] $*" ; } | ||
fatal() { echoerr "[FATAL] $*" ; exit 1 ; } | ||
|
||
if [[ "${BASH_SOURCE[0]}" = "$0" ]]; then | ||
BASELINE_FILE=$1 | ||
OTEL_FILE=$2 | ||
BUDGET=$3 | ||
|
||
info "Starting performance review..." | ||
|
||
fails_baseline=$(cat ${BASELINE_FILE} | jq -r .metrics.http_req_duration.avg) | ||
fails_otel=$(cat ${OTEL_FILE} | jq -r .metrics.http_req_duration.avg) | ||
|
||
# Convert to integer. | ||
fails_baseline=${fails_baseline%.*} | ||
fails_otel=${fails_otel%.*} | ||
|
||
if (( $fails_baseline > 0 )); then | ||
fatal "Baseline test had failed k6 checks ($fails_baseline)" | ||
fi | ||
|
||
if (( $fails_otel > 0 )); then | ||
fatal "Baseline test had failed k6 checks ($fails_otel)" | ||
fi | ||
|
||
http_req_duration_baseline=$(cat ${BASELINE_FILE} | jq -r .metrics.http_req_duration.avg) | ||
http_req_duration_otel=$(cat ${OTEL_FILE} | jq -r .metrics.http_req_duration.avg) | ||
|
||
# Convert to integer. | ||
http_req_duration_baseline=${http_req_duration_baseline%.*} | ||
http_req_duration_otel=${http_req_duration_otel%.*} | ||
|
||
info "http_req_duration = ${http_req_duration_baseline}" | ||
info "http_req_duration with otel enabled= ${http_req_duration_otel}" | ||
|
||
if (( $http_req_duration_baseline > $http_req_duration_otel )); then | ||
fatal "OpenTelemetry is more performant than with it off. This cannot be! See output above for stats." | ||
fi | ||
|
||
http_req_duration_diff=`expr $http_req_duration_otel - $http_req_duration_baseline` | ||
|
||
info "http_req_duration diff = ${http_req_duration_diff}" | ||
|
||
if (( $http_req_duration_diff > $BUDGET )); then | ||
fatal "We have failed our performance budget (${http_req_duration_diff} > ${BUDGET})" | ||
fi | ||
fi |