From 390d7288fd13d3cb74480c4d73dd820469059e3a Mon Sep 17 00:00:00 2001 From: Alok Kumar Singh <62210712+akstron@users.noreply.github.com> Date: Sat, 2 Nov 2024 09:16:27 +0530 Subject: [PATCH] Added Label Validation in SPM Integration Test (#6142) ## Which problem is this PR solving? - Part of #5608 ## Description of the changes - The changes include requesting metric with `groupByOperation` to get labels along with `operation`. This is then compared with the expected label set = `"operation service_name"` ## How was this change tested? - jaeger/scripts/spm-integration-test.sh ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Alok Kumar Singh Co-authored-by: Yuri Shkuro --- scripts/spm-integration-test.sh | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/scripts/spm-integration-test.sh b/scripts/spm-integration-test.sh index 4e8573cd61d..c38db71a41e 100755 --- a/scripts/spm-integration-test.sh +++ b/scripts/spm-integration-test.sh @@ -111,6 +111,18 @@ validate_service_metrics() { echo "⏳ Expecting at least 4 non-zero data points" return 1 fi + + # Validate if labels are correct + local url="http://localhost:16686/api/metrics/calls?service=${service}&groupByOperation=true&endTs=&lookback=${fiveMinutes}&step=${fifteenSec}&ratePer=${oneMinute}" + + local labels + labels=$(curl -s "$url" | jq -r '.metrics[0].labels[].name' | sort | tr '\n' ' ') + local exp_labels="operation service_name " + + if [[ "$labels" != "$exp_labels" ]]; then + echo "❌ ERROR: Obtained labels: '$labels' are not same as expected labels: '$exp_labels'" + return 1 + fi return 0 }