From 406d18986552825af8b9217ab76912e3143e7363 Mon Sep 17 00:00:00 2001 From: Timofei Larkin Date: Tue, 25 Jun 2024 15:52:49 +0300 Subject: [PATCH] allow time for async things to finish in e2e tests --- test/e2e/e2e_test.go | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index aadc826f..9b18844f 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -21,6 +21,7 @@ import ( "os" "os/exec" "sync" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -95,6 +96,15 @@ var _ = Describe("etcd-operator", Ordered, func() { ExpectWithOffset(1, err).NotTo(HaveOccurred()) }) + Eventually(func() error { + cmd := exec.Command("kubectl", "get", + "statefulset/test", + "--namespace", namespace, + ) + _, err = utils.Run(cmd) + return err + }, time.Second*20, time.Second*2).Should(Succeed()) + By("wait for statefulset is ready", func() { cmd := exec.Command("kubectl", "wait", "statefulset/test", @@ -144,6 +154,15 @@ var _ = Describe("etcd-operator", Ordered, func() { ExpectWithOffset(1, err).NotTo(HaveOccurred()) }) + Eventually(func() error { + cmd := exec.Command("kubectl", "get", + "statefulset/test", + "--namespace", namespace, + ) + _, err = utils.Run(cmd) + return err + }, time.Second*20, time.Second*2).Should(Succeed()) + By("wait for statefulset is ready", func() { cmd := exec.Command("kubectl", "wait", "statefulset/test", @@ -192,6 +211,15 @@ var _ = Describe("etcd-operator", Ordered, func() { ExpectWithOffset(1, err).NotTo(HaveOccurred()) }) + Eventually(func() error { + cmd := exec.Command("kubectl", "get", + "statefulset/test", + "--namespace", namespace, + ) + _, err = utils.Run(cmd) + return err + }, time.Second*20, time.Second*2).Should(Succeed()) + By("wait for statefulset is ready", func() { cmd := exec.Command("kubectl", "wait", "statefulset/test", @@ -217,8 +245,10 @@ var _ = Describe("etcd-operator", Ordered, func() { auth := clientv3.NewAuth(client) By("check root role is created", func() { - _, err = auth.RoleGet(ctx, "root") - Expect(err).NotTo(HaveOccurred()) + Eventually(func() error { + _, err = auth.RoleGet(ctx, "root") + return err + }, time.Second*20, time.Second*2).Should(Succeed()) }) By("check root user is created and has root role", func() {