Skip to content

Commit d858310

Browse files
committed
Update TestGetRepoHostVolumeRequests
Autogrow statuses for volumes that no longer exist are now cleared. This commit updates the underlying PostgresCluster used for testing to conform to the new behavior. The test previously used partially constructed objects that wouldn't exist in a real cluster.
1 parent 23bb0bd commit d858310

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

internal/controller/postgrescluster/pgbackrest_test.go

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/types"
3030
"k8s.io/apimachinery/pkg/util/rand"
3131
"k8s.io/apimachinery/pkg/util/wait"
32+
"k8s.io/client-go/tools/record"
3233
"sigs.k8s.io/controller-runtime/pkg/client"
3334
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3435
"sigs.k8s.io/controller-runtime/pkg/manager"
@@ -4430,8 +4431,9 @@ func TestGetRepoHostVolumeRequests(t *testing.T) {
44304431
require.ParallelCapacity(t, 1)
44314432

44324433
reconciler := &Reconciler{
4433-
Client: tClient,
4434-
Owner: client.FieldOwner(t.Name()),
4434+
Client: tClient,
4435+
Owner: client.FieldOwner(t.Name()),
4436+
Recorder: new(record.FakeRecorder),
44354437
}
44364438

44374439
testCases := []struct {
@@ -4505,11 +4507,41 @@ func TestGetRepoHostVolumeRequests(t *testing.T) {
45054507
t.Cleanup(func() { assert.Check(t, tClient.Delete(ctx, repoHost)) })
45064508
}
45074509

4510+
// A limit is expected otherwise an empty string ("") is returned
4511+
testRepoPVC := func() *v1beta1.RepoPVC {
4512+
return &v1beta1.RepoPVC{
4513+
VolumeClaimSpec: v1beta1.VolumeClaimSpec{
4514+
AccessModes: []corev1.PersistentVolumeAccessMode{corev1.ReadWriteOnce},
4515+
Resources: corev1.VolumeResourceRequirements{
4516+
Limits: map[corev1.ResourceName]resource.Quantity{
4517+
corev1.ResourceStorage: resource.MustParse("1Gi"),
4518+
},
4519+
}}}
4520+
}
4521+
45084522
cluster := &v1beta1.PostgresCluster{
45094523
ObjectMeta: metav1.ObjectMeta{
45104524
Name: "orange",
45114525
Namespace: namespace,
45124526
},
4527+
Spec: v1beta1.PostgresClusterSpec{
4528+
Backups: v1beta1.Backups{
4529+
PGBackRest: v1beta1.PGBackRestArchive{
4530+
Repos: []v1beta1.PGBackRestRepo{
4531+
{
4532+
Name: "repo1",
4533+
Volume: testRepoPVC(),
4534+
}, {
4535+
Name: "repo2",
4536+
Volume: testRepoPVC(),
4537+
}, {
4538+
Name: "repo3",
4539+
Volume: testRepoPVC(),
4540+
}, {
4541+
Name: "repo4",
4542+
Volume: testRepoPVC(),
4543+
},
4544+
}}}},
45134545
Status: v1beta1.PostgresClusterStatus{
45144546
PGBackRest: &v1beta1.PGBackRestStatus{},
45154547
},

0 commit comments

Comments
 (0)