Skip to content
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

Add a threshold for expected zero values in the SPM script #5753

Merged
merged 3 commits into from
Jul 17, 2024
Merged
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
13 changes: 10 additions & 3 deletions scripts/spm-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,24 @@ validate_service_metrics() {
# Store the values in an array
mapfile -t metric_points < <(echo "$response" | jq -r '.metrics[0].metricPoints[].gaugeValue.doubleValue')
echo "Metric datapoints found for service '$service': " "${metric_points[@]}"
# Check that all values are non-zero
# Check that atleast some values are non-zero after the threshold
local non_zero_count=0
local expected_non_zero_count=3
local zero_count=0
local expected_max_zero_count=3
for value in "${metric_points[@]}"; do
if [[ $(echo "$value > 0.0" | bc) == "1" ]]; then
non_zero_count=$((non_zero_count + 1))
else
echo "❌ ERROR: Zero values not expected"
zero_count=$((zero_count + 1))
fi

if [[ $zero_count -gt $expected_max_zero_count ]]; then
echo "❌ ERROR: Zero values crossing threshold limit not expected (Threshold limit - '$expected_max_zero_count')"
return 1
fi
done
if [ $non_zero_count -lt 3 ]; then
if [ $non_zero_count -lt $expected_non_zero_count ]; then
echo "⏳ Expecting at least 3 non-zero data points"
return 1
fi
Expand Down
Loading