From aa2bbaa0322626ba345fdfce632275208d5af8da Mon Sep 17 00:00:00 2001 From: Alexandre Mahdhaoui Date: Mon, 25 Mar 2024 10:19:52 +0100 Subject: [PATCH] add blocking runnable to m1 --- pkg/manager/manager_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pkg/manager/manager_test.go b/pkg/manager/manager_test.go index a65d55ffdd..01ce17db64 100644 --- a/pkg/manager/manager_test.go +++ b/pkg/manager/manager_test.go @@ -419,8 +419,10 @@ var _ = Describe("manger.Manager", func() { Expect(m2).ToNot(BeNil()) Expect(rl.Describe()).To(Equal("default/test-leader-election-id")) + m1done := make(chan struct{}) Expect(m1.Add(RunnableFunc(func(ctx context.Context) error { defer GinkgoRecover() + <-m1done return nil }))).To(Succeed()) @@ -437,7 +439,7 @@ var _ = Describe("manger.Manager", func() { Expect(m2.Add(electionRunnable)).To(Succeed()) - ctx2, cancel := context.WithCancel(context.Background()) + ctx2, cancel2 := context.WithCancel(context.Background()) m2done := make(chan struct{}) go func() { defer GinkgoRecover() @@ -450,8 +452,9 @@ var _ = Describe("manger.Manager", func() { defer GinkgoRecover() Consistently(electionRunnable.ch).ShouldNot(Receive()) }() - cancel() + cancel2() <-m2done + <-m1done }) It("should default ID to controller-runtime if ID is not set", func() {