From 253e3fb582dbc6d9fccb69c7bc9e6362cfa25312 Mon Sep 17 00:00:00 2001 From: kruskall <99559985+kruskall@users.noreply.github.com> Date: Fri, 10 Jan 2025 14:20:29 +0100 Subject: [PATCH] test: acquire lock before checking pendingRequests in controller test (#42096) fix race condition in TestQueueProducerBlocksUntilOutputIsSet (cherry picked from commit 57eae3abb96dc24833c33b4fa879a9bf4d02c805) --- libbeat/publisher/pipeline/controller_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libbeat/publisher/pipeline/controller_test.go b/libbeat/publisher/pipeline/controller_test.go index 5e48fbb79b8f..cc7129c398b4 100644 --- a/libbeat/publisher/pipeline/controller_test.go +++ b/libbeat/publisher/pipeline/controller_test.go @@ -231,6 +231,8 @@ func TestQueueProducerBlocksUntilOutputIsSet(t *testing.T) { }() } allStarted := waitUntilTrue(time.Second, func() bool { + controller.queueLock.Lock() + defer controller.queueLock.Unlock() return len(controller.pendingRequests) == producerCount }) assert.True(t, allStarted, "All queueProducer requests should be saved as pending requests by outputController")