Skip to content

Commit

Permalink
fix: avoid random failures on tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aamoyel committed Jun 3, 2024
1 parent 878f5f0 commit 7054bb0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions internal/controllers/ipcidr_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ var _ = Describe("IPCidr controller", func() {
}
return createdIpCidr.Status.Registered, nil
}, timeout, interval).Should(Equal(false))
By("Deleting the bad cidr")
Expect(k8sClient.Delete(ctx, createdIpCidr)).Should(Succeed())

By("Creating a new IPCidr that overlap a created one")
ipCidrName = "overlap-cidr"
Expand Down
8 changes: 4 additions & 4 deletions internal/controllers/ipclaim_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@ var _ = Describe("IPClaim controller", func() {
ipcidr := getIpCidr(ipClaimCidr, "172.16.0.0/16")
Expect(k8sClient.Create(ctx, ipcidr)).Should(Succeed())

By("Creating a new IPClaim with bad prefix")
By("Creating a new IPClaim to claim an IP addr")
ipClaimName := "test-ip"
ipclaim := getIPClaim("IP", false, ipClaimName, ipClaimCidr)
Expect(k8sClient.Create(ctx, ipclaim)).Should(Succeed())

By("Checking if the 'registered' status field is set to 'true'")
ipClaimLookupKey := types.NamespacedName{Name: ipClaimName}
claimedIP := &ipamv1alpha1.IPClaim{}
ipClaimCR := &ipamv1alpha1.IPClaim{}
Eventually(func() (bool, error) {
err := k8sClient.Get(ctx, ipClaimLookupKey, claimedIP)
err := k8sClient.Get(ctx, ipClaimLookupKey, ipClaimCR)
if err != nil {
return false, err
}
return claimedIP.Status.Registered, nil
return ipClaimCR.Status.Registered, nil
}, timeout, interval).Should(Equal(true))
})
})
Expand Down

0 comments on commit 7054bb0

Please sign in to comment.