From c2e9e797b3339c4722fcc3128b61fcbd7400379d Mon Sep 17 00:00:00 2001 From: Shirley <4163034+fridgepoet@users.noreply.github.com> Date: Fri, 28 Oct 2022 16:05:55 +0200 Subject: [PATCH] CloudWatch: fix non-deterministic test (#57831) --- pkg/tsdb/cloudwatch/models/cloudwatch_query_test.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/tsdb/cloudwatch/models/cloudwatch_query_test.go b/pkg/tsdb/cloudwatch/models/cloudwatch_query_test.go index 87380878fb3..307a1533556 100644 --- a/pkg/tsdb/cloudwatch/models/cloudwatch_query_test.go +++ b/pkg/tsdb/cloudwatch/models/cloudwatch_query_test.go @@ -3,6 +3,7 @@ package models import ( "encoding/json" "fmt" + "sort" "testing" "time" @@ -948,9 +949,12 @@ func Test_ParseMetricDataQueries_migrate_alias_to_label(t *testing.T) { res, err := ParseMetricDataQueries(query, time.Now(), time.Now(), true) assert.NoError(t, err) - require.Len(t, res, 2) + sort.Slice(res, func(i, j int) bool { + return res[i].RefId < res[j].RefId + }) + require.NotNil(t, res[0]) assert.Equal(t, "{{period}} {{any_other_word}}", res[0].Alias) assert.Equal(t, "${PROP('Period')} ${PROP('Dim.any_other_word')}", res[0].Label)