From 7abf152a6bce92b529374aa8c6055b6531f7507e Mon Sep 17 00:00:00 2001 From: Vihas Makwana <121151420+VihasMakwana@users.noreply.github.com> Date: Tue, 3 Dec 2024 22:53:45 +0530 Subject: [PATCH] [chore][pkg/stanza] - Fix Flaky test TestMatcher (#36640) Fixes https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/36623 We're using a map to store groups and we then do a `for .. range` over keys. https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/6119d51a5a85565c409bb225027d6d1ab353aecc/pkg/stanza/fileconsumer/matcher/matcher.go#L200-L206 For maps, the ordering of keys is not guaranteed. Hence, the check fails. We should instead check with `assert.ElementsMatch` (which was previously the case, but https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/36518 changed it to `assert.Equal`) --- pkg/stanza/fileconsumer/matcher/matcher_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/stanza/fileconsumer/matcher/matcher_test.go b/pkg/stanza/fileconsumer/matcher/matcher_test.go index e192536550ce..7ae3eac47762 100644 --- a/pkg/stanza/fileconsumer/matcher/matcher_test.go +++ b/pkg/stanza/fileconsumer/matcher/matcher_test.go @@ -853,7 +853,7 @@ func TestMatcher(t *testing.T) { } else { assert.NoError(t, err) } - assert.Equal(t, tc.expected, files) + assert.ElementsMatch(t, tc.expected, files) }) } }