Skip to content

Commit 0bb7e47

Browse files
andrewlecuyerdsessler7
authored andcommitted
Skip Tests that Write to Job Status During EnvTest Existing Runs
1 parent d4d4330 commit 0bb7e47

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
@@ -8,6 +8,8 @@ import (
88
"context"
99
"fmt"
1010
"io"
11+
"os"
12+
"strings"
1113
"testing"
1214

1315
"github.com/go-logr/logr/funcr"
@@ -282,6 +284,9 @@ volumeMode: Filesystem
282284
})
283285

284286
t.Run("DataVolumeSourceClusterWithGoodSnapshot", func(t *testing.T) {
287+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
288+
t.Skip("requires mocking of Job conditions")
289+
}
285290
cluster := testCluster()
286291
ns := setupNamespace(t, tClient)
287292
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

@@ -190,6 +192,9 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
190192
})
191193

192194
t.Run("SnapshotsEnabledReadySnapshotsExist", func(t *testing.T) {
195+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
196+
t.Skip("requires mocking of Job conditions")
197+
}
193198
// Create a volume snapshot class
194199
volumeSnapshotClassName := "my-snapshotclass"
195200
volumeSnapshotClass := &volumesnapshotv1.VolumeSnapshotClass{
@@ -481,6 +486,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
481486
})
482487

483488
t.Run("SnapshotsEnabledBackupExistsCreateRestore", func(t *testing.T) {
489+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
490+
t.Skip("requires mocking of Job conditions")
491+
}
484492
// Create cluster with snapshots enabled
485493
ns := setupNamespace(t, cc)
486494
cluster := testCluster()
@@ -529,6 +537,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
529537
})
530538

531539
t.Run("SnapshotsEnabledSuccessfulRestoreExists", func(t *testing.T) {
540+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
541+
t.Skip("requires mocking of Job conditions")
542+
}
532543
// Create cluster with snapshots enabled
533544
ns := setupNamespace(t, cc)
534545
cluster := testCluster()
@@ -596,6 +607,9 @@ func TestReconcileDedicatedSnapshotVolume(t *testing.T) {
596607
})
597608

598609
t.Run("SnapshotsEnabledFailedRestoreExists", func(t *testing.T) {
610+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
611+
t.Skip("requires mocking of Job conditions")
612+
}
599613
// Create cluster with snapshots enabled
600614
ns := setupNamespace(t, cc)
601615
cluster := testCluster()
@@ -881,6 +895,9 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
881895
})
882896

883897
t.Run("OneCompleteBackupJob", func(t *testing.T) {
898+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
899+
t.Skip("requires mocking of Job conditions")
900+
}
884901
currentTime := metav1.Now()
885902
currentStartTime := metav1.NewTime(currentTime.AddDate(0, 0, -1))
886903

@@ -910,6 +927,9 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
910927
})
911928

912929
t.Run("TwoCompleteBackupJobs", func(t *testing.T) {
930+
if strings.EqualFold(os.Getenv("USE_EXISTING_CLUSTER"), "true") {
931+
t.Skip("requires mocking of Job conditions")
932+
}
913933
currentTime := metav1.Now()
914934
currentStartTime := metav1.NewTime(currentTime.AddDate(0, 0, -1))
915935
earlierTime := metav1.NewTime(currentTime.AddDate(-1, 0, 0))

0 commit comments

Comments
 (0)