Skip to content

Commit 24f0325

Browse files
committed
Skip Tests that Write to Job Status During EnvTest Existing Runs
1 parent d3ea3a9 commit 24f0325

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

@@ -180,6 +182,9 @@ func TestReconcileVolumeSnapshots(t *testing.T) {
180182
})
181183

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

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

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

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

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

@@ -864,6 +881,9 @@ func TestGetLatestCompleteBackupJob(t *testing.T) {
864881
})
865882

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

0 commit comments

Comments
 (0)