From 2923a7d95818055a6ae9557d4b2f733b1af826f3 Mon Sep 17 00:00:00 2001 From: benclive Date: Thu, 30 May 2024 13:53:06 +0100 Subject: [PATCH] fix: Update expected patterns when pruning (#13079) --- pkg/pattern/ingester_querier_test.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pkg/pattern/ingester_querier_test.go b/pkg/pattern/ingester_querier_test.go index d1016b326df7..9d23662d419e 100644 --- a/pkg/pattern/ingester_querier_test.go +++ b/pkg/pattern/ingester_querier_test.go @@ -6,12 +6,13 @@ import ( "testing" "github.com/stretchr/testify/require" + "golang.org/x/exp/slices" "github.com/grafana/loki/v3/pkg/logproto" ) func Test_prunePatterns(t *testing.T) { - file, err := os.Open("testdata/patterns.txt") + file, err := os.Open(`testdata/patterns.txt`) require.NoError(t, err) defer file.Close() @@ -26,18 +27,20 @@ func Test_prunePatterns(t *testing.T) { prunePatterns(resp, 0) expectedPatterns := []string{ + `<_> caller=aggregator.go:139 level=info msg="received kafka message" topic=cortex-dev-01-aggregations partition=<_>`, + `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" <_> partitionID=<_> +0000 UTC, <_>`, + `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" result="user=9960, partitionID=<_> +0000 UTC, <_>`, + `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" result="user=9960, partitionID=<_> sampleTimestamp=2024-04-03 <_> +0000 UTC, <_>`, + `<_> caller=offset_committer.go:174 level=info msg="partition offset committer committed offset" topic=cortex-dev-01-aggregations partition=<_> +0000 UTC" <_> +0000 UTC" <_> currentBuckets="unsupported value type"`, + `<_> caller=offset_committer.go:174 level=info msg="partition offset committer committed offset" topic=cortex-dev-01-aggregations partition=<_> handledMessageTime="2024-04-03 <_> +0000 UTC" <_> +0000 UTC" <_> currentBuckets="unsupported value type"`, `<_> caller=wrapper.go:48 level=info component=distributor msg="sample remote write" eventType=bi <_>`, - `<_> caller=offset_committer.go:174 level=info msg="partition offset committer committed offset" topic=cortex-dev-01-aggregations <_> +0000 UTC" <_> +0000 UTC" <_> currentBuckets="unsupported value type"`, - `<_> caller=aggregator.go:139 level=info msg="received kafka message" topic=cortex-dev-01-aggregations <_>`, - `<_> caller=batcher.go:155 level=info msg="batcher: processing aggregation result" result="user=9960, <_> sampleTimestamp=2024-04-03 <_> +0000 UTC, <_>`, - `<_> caller=offset_committer.go:174 level=info msg="partition offset committer committed offset" topic=cortex-dev-01-aggregations <_> handledMessageTime="2024-04-03 <_> +0000 UTC" <_> +0000 UTC" <_> currentBuckets="unsupported value type"`, - `<_> caller=batcher.go:155 level=info msg="batcher: processing aggregation result" <_> +0000 UTC, <_>`, } patterns := make([]string, 0, len(resp.Series)) for _, p := range resp.Series { patterns = append(patterns, p.Pattern) } + slices.Sort(patterns) require.Equal(t, expectedPatterns, patterns) }