From 217de1664d2a5f27769e7a9705a84a04bca08e2e Mon Sep 17 00:00:00 2001 From: Berkeli Halmyradov Date: Fri, 24 Nov 2023 03:42:01 +0000 Subject: [PATCH] bug: fix flaky test TestQueuedRetry_RequeuingEnabled (#8989) fixes a flaky test Fixing a bug - TestQueuedRetry_RequeuingEnabled has been failing occasionally. Upon investigation, `be.send` calls the underlying `observabilityConsumerSender.send` which calls `wg.Done()`, so we need to add `wg.Add(1)` before that Fixes #6624 **Testing:** Ran the same test multiple times before/after change: `go test -race -run TestQueuedRetry_RequeuingEnabled -count 1000` --- exporter/exporterhelper/queue_sender_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exporter/exporterhelper/queue_sender_test.go b/exporter/exporterhelper/queue_sender_test.go index 6caceb115e2..38049ed1707 100644 --- a/exporter/exporterhelper/queue_sender_test.go +++ b/exporter/exporterhelper/queue_sender_test.go @@ -243,9 +243,9 @@ func TestQueuedRetry_RequeuingEnabled(t *testing.T) { traceErr := consumererror.NewTraces(errors.New("some error"), testdata.GenerateTraces(1)) mockR := newMockRequest(1, traceErr) ocs.run(func() { + ocs.waitGroup.Add(1) // necessary because we'll call send() again after requeueing // This is asynchronous so it should just enqueue, no errors expected. require.NoError(t, be.send(context.Background(), mockR)) - ocs.waitGroup.Add(1) // necessary because we'll call send() again after requeueing }) ocs.awaitAsyncProcessing()