Skip to content

Commit cfe60ab

Browse files
andrewlecuyerdsessler7
authored andcommitted
Skip Tests that Write to Job Status During EnvTest Existing Runs
1 parent 133d3da commit cfe60ab

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

internal/controller/postgrescluster/postgres_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import (
99
"errors"
1010
"fmt"
1111
"io"
12+
"os"
13+
"strings"
1214
"testing"
1315

1416
"github.com/go-logr/logr/funcr"
@@ -526,6 +528,9 @@ volumeMode: Filesystem
526528
})
527529

528530
t.Run("DataVolumeSourceClusterWithGoodSnapshot", func(t *testing.T) {
531+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
532+
t.Skip("requires mocking of Job conditions")
533+
}
529534
cluster := testCluster()
530535
ns := setupNamespace(t, tClient)
531536
cluster.Namespace = ns.Name

internal/controller/postgrescluster/snapshots_test.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ package postgrescluster
66

77
import (
88
"context"
9+
"os"
10+
"strings"
911
"testing"
1012
"time"
1113

@@ -181,6 +183,9 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
181183
})
182184

183185
t.Run("SnapshotsEnabledReadySnapshotsExist", func(t *testing.T) {
186+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
187+
t.Skip("requires mocking of Job conditions")
188+
}
184189
// Create a volume snapshot class
185190
volumeSnapshotClassName := "my-snapshotclass"
186191
volumeSnapshotClass := &volumesnapshotv1.VolumeSnapshotClass{
@@ -455,6 +460,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
455460
})
456461

457462
t.Run("SnapshotsEnabledBackupExistsCreateRestore", func(t *testing.T) {
463+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
464+
t.Skip("requires mocking of Job conditions")
465+
}
458466
// Create cluster with snapshots enabled
459467
ns := setupNamespace(t, cc)
460468
cluster := testCluster()
@@ -500,6 +508,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
500508
})
501509

502510
t.Run("SnapshotsEnabledSuccessfulRestoreExists", func(t *testing.T) {
511+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
512+
t.Skip("requires mocking of Job conditions")
513+
}
503514
// Create cluster with snapshots enabled
504515
ns := setupNamespace(t, cc)
505516
cluster := testCluster()
@@ -562,6 +573,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
562573
})
563574

564575
t.Run("SnapshotsEnabledFailedRestoreExists", func(t *testing.T) {
576+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
577+
t.Skip("requires mocking of Job conditions")
578+
}
565579
// Create cluster with snapshots enabled
566580
ns := setupNamespace(t, cc)
567581
cluster := testCluster()
@@ -838,6 +852,9 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
838852
})
839853

840854
t.Run("OneCompleteBackupJob", func(t *testing.T) {
855+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
856+
t.Skip("requires mocking of Job conditions")
857+
}
841858
currentTime := metav1.Now()
842859
currentStartTime := metav1.NewTime(currentTime.AddDate(0, 0, -1))
843860

@@ -865,6 +882,9 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
865882
})
866883

867884
t.Run("TwoCompleteBackupJobs", func(t *testing.T) {
885+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
886+
t.Skip("requires mocking of Job conditions")
887+
}
868888
currentTime := metav1.Now()
869889
currentStartTime := metav1.NewTime(currentTime.AddDate(0, 0, -1))
870890
earlierTime := metav1.NewTime(currentTime.AddDate(-1, 0, 0))

0 commit comments

Comments
 (0)