Skip to content

Commit

Permalink
test(e2e): AssertConnection must retry before failing (cloudnative-pg…
Browse files Browse the repository at this point in the history
…#6293)

Fix a regression in the E2E testing suite introduced in cloudnative-pg#5898

Signed-off-by: Marco Nenciarini <[email protected]>
(cherry picked from commit d699efa)
  • Loading branch information
mnencia committed Dec 6, 2024
1 parent a734741 commit 6dcfb07
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions tests/e2e/asserts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
}

Expand Down

0 comments on commit 6dcfb07

Please sign in to comment.