Skip to content

Commit 7ecf60c

Browse files
jmckulkcbandy
authored andcommitted
Skip some tests with check-envtest-existing
Tests for reconciling resources that require a postgrescluster object as an owner are failing due to the garbage collector. The collector will delete these resource before the test completes when the owner does not exist. Until we find a better solution for running these tests without creating the owning object, we are skipping them when running against a live cluster.
1 parent e78e673 commit 7ecf60c

File tree

3 files changed

+25
-0
lines changed

3 files changed

+25
-0
lines changed

internal/controller/postgrescluster/patroni_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package postgrescluster
2020
import (
2121
"context"
2222
"fmt"
23+
"os"
2324
"strconv"
2425
"strings"
2526
"testing"
@@ -41,6 +42,11 @@ import (
4142
)
4243

4344
func TestPatroniReplicationSecret(t *testing.T) {
45+
// Garbage collector cleans up test resources before the test completes
46+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
47+
t.Skip("USE_EXISTING_CLUSTER: Test fails due to garbage collection")
48+
}
49+
4450
// setup the test environment and ensure a clean teardown
4551
tEnv, tClient, cfg := setupTestEnv(t, ControllerName)
4652
t.Cleanup(func() { teardownTestEnv(t, tEnv) })

internal/controller/postgrescluster/pgbackrest_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import (
2222
"errors"
2323
"fmt"
2424
"io"
25+
"os"
2526
"strconv"
27+
"strings"
2628
"testing"
2729
"time"
2830

@@ -121,6 +123,10 @@ func fakePostgresCluster(clusterName, namespace, clusterUID string,
121123
}
122124

123125
func TestReconcilePGBackRest(t *testing.T) {
126+
// Garbage collector cleans up test resources before the test completes
127+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
128+
t.Skip("USE_EXISTING_CLUSTER: Test fails due to garbage collection")
129+
}
124130

125131
// setup the test environment and ensure a clean teardown
126132
tEnv, tClient, cfg := setupTestEnv(t, ControllerName)
@@ -434,6 +440,10 @@ func TestReconcilePGBackRest(t *testing.T) {
434440
}
435441

436442
func TestReconcilePGBackRestRBAC(t *testing.T) {
443+
// Garbage collector cleans up test resources before the test completes
444+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
445+
t.Skip("USE_EXISTING_CLUSTER: Test fails due to garbage collection")
446+
}
437447

438448
// setup the test environment and ensure a clean teardown
439449
tEnv, tClient, cfg := setupTestEnv(t, ControllerName)
@@ -1332,6 +1342,10 @@ func TestReconcileManualBackup(t *testing.T) {
13321342
}
13331343

13341344
func TestGetPGBackRestResources(t *testing.T) {
1345+
// Garbage collector cleans up test resources before the test completes
1346+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
1347+
t.Skip("USE_EXISTING_CLUSTER: Test fails due to garbage collection")
1348+
}
13351349

13361350
// setup the test environment and ensure a clean teardown
13371351
tEnv, tClient, cfg := setupTestEnv(t, ControllerName)

internal/controller/postgrescluster/pki_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ import (
4343
)
4444

4545
func TestReconcileCerts(t *testing.T) {
46+
// Garbage collector cleans up test resources before the test completes
47+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
48+
t.Skip("USE_EXISTING_CLUSTER: Test fails due to garbage collection")
49+
}
50+
4651
// setup the test environment and ensure a clean teardown
4752
tEnv, tClient, _ := setupTestEnv(t, ControllerName)
4853
ctx := context.Background()

0 commit comments

Comments
 (0)