@@ -6,12 +6,13 @@ import (
6
6
"testing"
7
7
8
8
"github.com/stretchr/testify/require"
9
+ "golang.org/x/exp/slices"
9
10
10
11
"github.com/grafana/loki/v3/pkg/logproto"
11
12
)
12
13
13
14
func Test_prunePatterns (t * testing.T ) {
14
- file , err := os .Open (" testdata/patterns.txt" )
15
+ file , err := os .Open (` testdata/patterns.txt` )
15
16
require .NoError (t , err )
16
17
defer file .Close ()
17
18
@@ -26,18 +27,20 @@ func Test_prunePatterns(t *testing.T) {
26
27
prunePatterns (resp , 0 )
27
28
28
29
expectedPatterns := []string {
30
+ `<_> caller=aggregator.go:139 level=info msg="received kafka message" topic=cortex-dev-01-aggregations partition=<_>` ,
31
+ `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" <_> partitionID=<_> +0000 UTC, <_>` ,
32
+ `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" result="user=9960, partitionID=<_> +0000 UTC, <_>` ,
33
+ `<_> caller=batcher.go:155 level=info msg="batcher:processing aggregation result" result="user=9960, partitionID=<_> sampleTimestamp=2024-04-03 <_> +0000 UTC, <_>` ,
34
+ `<_> 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"` ,
35
+ `<_> 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"` ,
29
36
`<_> caller=wrapper.go:48 level=info component=distributor msg="sample remote write" eventType=bi <_>` ,
30
- `<_> 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"` ,
31
- `<_> caller=aggregator.go:139 level=info msg="received kafka message" topic=cortex-dev-01-aggregations <_>` ,
32
- `<_> caller=batcher.go:155 level=info msg="batcher: processing aggregation result" result="user=9960, <_> sampleTimestamp=2024-04-03 <_> +0000 UTC, <_>` ,
33
- `<_> 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"` ,
34
- `<_> caller=batcher.go:155 level=info msg="batcher: processing aggregation result" <_> +0000 UTC, <_>` ,
35
37
}
36
38
37
39
patterns := make ([]string , 0 , len (resp .Series ))
38
40
for _ , p := range resp .Series {
39
41
patterns = append (patterns , p .Pattern )
40
42
}
43
+ slices .Sort (patterns )
41
44
42
45
require .Equal (t , expectedPatterns , patterns )
43
46
}
0 commit comments