From 09a2c7864ec00aec4a340592748a23c1a04373f5 Mon Sep 17 00:00:00 2001 From: FlamingSaint Date: Tue, 16 Jul 2024 22:41:57 +0530 Subject: [PATCH] Add a threshold for expected zero values in the SPM script Signed-off-by: FlamingSaint --- scripts/spm-integration-test.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/spm-integration-test.sh b/scripts/spm-integration-test.sh index a0270586130..5d3da930c91 100755 --- a/scripts/spm-integration-test.sh +++ b/scripts/spm-integration-test.sh @@ -61,13 +61,18 @@ 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 threshold=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" + threshold=$((threshold - 1)) + fi + + if [[ $threshold -eq 0 ]]; then + echo "❌ ERROR: Zero values above threshold limit not expected" return 1 fi done