From 130b29be0288a6aac65983e126e262dded5246d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Tich=C3=A1k?= Date: Sun, 30 Nov 2025 12:28:54 +0100 Subject: [PATCH] goroutines stuck demonstration --- common/utils/safeacks/safeacks_test.go | 30 ++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/common/utils/safeacks/safeacks_test.go b/common/utils/safeacks/safeacks_test.go index 6a5103c2d..ac00897d4 100644 --- a/common/utils/safeacks/safeacks_test.go +++ b/common/utils/safeacks/safeacks_test.go @@ -1,11 +1,12 @@ package safeacks import ( - . "github.com/onsi/ginkgo/v2" - . "github.com/onsi/gomega" "sync" "testing" "time" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" ) var _ = Describe("SafeAcks", func() { @@ -110,6 +111,31 @@ var _ = Describe("SafeAcks", func() { Expect(sa.ExpectsAck("test")).To(BeTrue()) }, SpecTimeout(5*time.Second)) }) + + Describe("Goroutine stuck demonstration", func() { + It("stuck", func(ctx SpecContext) { + sa.RegisterAck("0") + + receivedAcks := 0 + + go func() { + sa.TryReceiveAck("0") + receivedAcks += 1 + }() + go func() { + sa.TryReceiveAck("0") + receivedAcks += 1 + }() + + time.Sleep(time.Second) + sa.TrySendAck("0") + time.Sleep(time.Second) + sa.TrySendAck("0") + // Expect(MyAmazingThing()).Should(Equal(3)) + + Expect(receivedAcks).Should(Equal(2)) + }, SpecTimeout(5*time.Second)) + }) }) func TestSafeAcks(t *testing.T) {