Skip to content

Commit

Permalink
test(e2e): fix concurrency issue in pgbouncer tests
Browse files Browse the repository at this point in the history
Fix an issue in the pgbouncer tests where the tests could fail if
multiple pgbouncer tests were running in parallel.

Fixes cloudnative-pg#6905

Signed-off-by: Francesco Canovai <francesco.canovai@enterprisedb.com>
  • Loading branch information
fcanovai committed Feb 21, 2025
1 parent 209162d commit 9e2e185
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tests/e2e/pgbouncer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,9 @@ var _ = Describe("PGBouncer Connections", Label(tests.LabelServiceConnectivity),
})

By("executing psql within the pgbouncer pod", func() {
pod, err := getPgbouncerPod(poolerBasicAuthRWSampleFile)
pod, err := getPgbouncerPod(namespace, poolerBasicAuthRWSampleFile)
Expect(err).ToNot(HaveOccurred())

GinkgoWriter.Println(pod.Name)

err = runShowHelpInPod(pod)
Expect(err).ToNot(HaveOccurred())
})
Expand Down Expand Up @@ -194,7 +192,7 @@ var _ = Describe("PGBouncer Connections", Label(tests.LabelServiceConnectivity),
})
})

func getPgbouncerPod(sampleFile string) (*corev1.Pod, error) {
func getPgbouncerPod(namespace, sampleFile string) (*corev1.Pod, error) {
poolerKey, err := yaml.GetResourceNameFromYAML(env.Scheme, sampleFile)
if err != nil {
return nil, err
Expand All @@ -203,7 +201,7 @@ func getPgbouncerPod(sampleFile string) (*corev1.Pod, error) {
Expect(err).ToNot(HaveOccurred())

var podList corev1.PodList
err = env.Client.List(env.Ctx, &podList, ctrlclient.InNamespace(""),
err = env.Client.List(env.Ctx, &podList, ctrlclient.InNamespace(namespace),
ctrlclient.MatchingLabels{utils.PgbouncerNameLabel: poolerKey})
Expect(err).ToNot(HaveOccurred())
Expect(len(podList.Items)).Should(BeEquivalentTo(1))
Expand Down

0 comments on commit 9e2e185

Please sign in to comment.