Hopefully fix E2E flake related to deletion of a test Service (#3336)

* Wrap Delete call in Eventually to hopefully prevent flakes where Service deletion fails

* Simplify logic and properly handle the case where the Service is not
found during the delete call

* After deleting the Service, confirm that it's gone
This commit is contained in:
Kipp Morris 2024-01-31 09:52:00 -06:00 коммит произвёл GitHub
Родитель 2a0ef0e1a1
Коммит 087e40929a
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
1 изменённых файлов: 8 добавлений и 5 удалений

Просмотреть файл

@ -51,13 +51,16 @@ var _ = Describe("[Admin API] Delete managed resource action", func() {
defer func() {
By("cleaning up the k8s loadbalancer service")
err := clients.Kubernetes.CoreV1().Services("default").Delete(ctx, "test", metav1.DeleteOptions{})
Expect(err).NotTo(HaveOccurred())
// wait for deletion to prevent flakes on retries
Eventually(func(g Gomega, ctx context.Context) {
_, err = clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(kerrors.IsNotFound(err)).To(BeTrue(), "expect Service to be deleted")
err := clients.Kubernetes.CoreV1().Services("default").Delete(ctx, "test", metav1.DeleteOptions{})
g.Expect((err == nil || kerrors.IsNotFound(err))).To(BeTrue(), "expect Service to be deleted")
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
By("confirming that the k8s loadbalancer service is gone")
Eventually(func(g Gomega, ctx context.Context) {
_, err := clients.Kubernetes.CoreV1().Services("default").Get(ctx, "test", metav1.GetOptions{})
g.Expect(kerrors.IsNotFound(err)).To(BeTrue())
}).WithContext(ctx).WithTimeout(DefaultEventuallyTimeout).Should(Succeed())
}()