From 6dcfb07672fb235e73c5fbba78237742cb97ac32 Mon Sep 17 00:00:00 2001 From: Marco Nenciarini Date: Fri, 6 Dec 2024 15:49:07 +0100 Subject: [PATCH] test(e2e): AssertConnection must retry before failing (#6293) Fix a regression in the E2E testing suite introduced in #5898 Signed-off-by: Marco Nenciarini (cherry picked from commit d699efa07575ca6068800137488b1f29ab1d4e0b) --- tests/e2e/asserts_test.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/e2e/asserts_test.go b/tests/e2e/asserts_test.go index b879b5a3ab..d64de08643 100644 --- a/tests/e2e/asserts_test.go +++ b/tests/e2e/asserts_test.go @@ -415,19 +415,21 @@ func AssertConnection( }) By(fmt.Sprintf("connecting to the %v service as %v", service, user), func() { - forwardConn, conn, err := testsUtils.ForwardPSQLServiceConnection(env, namespace, service, - dbname, user, password) - defer func() { - _ = conn.Close() - forwardConn.Close() - }() - Expect(err).ToNot(HaveOccurred()) + Eventually(func(g Gomega) { + forwardConn, conn, err := testsUtils.ForwardPSQLServiceConnection(env, namespace, service, + dbname, user, password) + defer func() { + _ = conn.Close() + forwardConn.Close() + }() + g.Expect(err).ToNot(HaveOccurred()) - var rawValue string - row := conn.QueryRow("SELECT 1") - err = row.Scan(&rawValue) - Expect(err).ToNot(HaveOccurred()) - Expect(strings.TrimSpace(rawValue)).To(BeEquivalentTo("1")) + var rawValue string + row := conn.QueryRow("SELECT 1") + err = row.Scan(&rawValue) + g.Expect(err).ToNot(HaveOccurred()) + g.Expect(strings.TrimSpace(rawValue)).To(BeEquivalentTo("1")) + }, RetryTimeout).Should(Succeed()) }) }