From 79d81e1186adf9648360efd8526a73caddc5df2a Mon Sep 17 00:00:00 2001 From: kruskal <99559985+kruskall@users.noreply.github.com> Date: Tue, 17 Dec 2024 22:18:25 +0100 Subject: [PATCH] test: acquire lock before checking pendingRequests in controller test fix race condition in TestQueueProducerBlocksUntilOutputIsSet --- 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")