Skip to content

Commit e4af5df

Browse files
committed
Fix intermittent GatewayMonitor unit tests failures
The fake K8s client has a very intermittent concurrency issue where a notification can be missed if a resource is created while the informer is starting. This was seen with a GlobalEgressIP so create the GlobalEgressIP before the controllers are started. Signed-off-by: Tom Pantelis <[email protected]>
1 parent f3f3145 commit e4af5df

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

pkg/globalnet/controllers/gateway_monitor_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,17 @@ var _ = Describe("Endpoint monitoring", func() {
6565
})
6666

6767
Context("", func() {
68+
BeforeEach(func() {
69+
t.createGlobalEgressIP(newGlobalEgressIP(globalEgressIPName, nil, nil))
70+
})
71+
6872
AfterEach(func() {
6973
t.awaitGlobalnetChainsCleared()
7074
})
7175

7276
It("should start the controllers", func() {
7377
t.awaitControllersStarted()
7478

75-
t.createGlobalEgressIP(newGlobalEgressIP(globalEgressIPName, nil, nil))
7679
t.awaitGlobalEgressIPStatusAllocated(globalEgressIPName, 1)
7780

7881
t.createServiceExport(t.createService(newClusterIPService()))
@@ -84,7 +87,12 @@ var _ = Describe("Endpoint monitoring", func() {
8487
backendPod := newHeadlessServicePod(service.Name)
8588
t.createPod(backendPod)
8689
t.createServiceExport(t.createService(service))
87-
t.awaitHeadlessGlobalIngressIP(service.Name, backendPod.Name)
90+
91+
Eventually(func(g Gomega) {
92+
gip := t.awaitHeadlessGlobalIngressIP(service.Name, backendPod.Name)
93+
g.Expect(gip.Status.AllocatedIP).NotTo(BeEmpty(), resource.ToJSON(gip))
94+
}).To(Succeed())
95+
8896
t.awaitGatewayGlobalIP("")
8997
})
9098
})

0 commit comments

Comments
 (0)