Skip to content

Commit

Permalink
Revert 999 workaround for velero tests
Browse files Browse the repository at this point in the history
This is a partial revert of c7d6052, which worked around a [breaking
change in controller-runtime 0.8.0](kubernetes-sigs/controller-runtime#1306).

A subsequent commit will fix the tests to disregard ResourceVersion.
  • Loading branch information
2uasimojo committed Jun 10, 2021
1 parent 0cb678d commit 8f5cb7f
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
32 changes: 16 additions & 16 deletions pkg/controller/velerobackup/velerobackup_controller_test.go
Expand Up @@ -116,9 +116,9 @@ func TestReconcile(t *testing.T) {
},
expectedResult: reconcile.Result{},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")),
testdnszone.Build(dnsZoneBase(), testdnszone.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
testsyncset.Build(syncSetBase()),
testdnszone.Build(dnsZoneBase()),
testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum(
[]runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase()),
Expand Down Expand Up @@ -150,7 +150,7 @@ func TestReconcile(t *testing.T) {
},
expectedResult: reconcile.Result{},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
testcheckpoint.Build(checkpointBase(),
testcheckpoint.WithLastBackupRef(hivev1.BackupReference{Name: "notarealbackup", Namespace: namespace}),
testcheckpoint.WithLastBackupTime(fiveHoursAgo),
Expand Down Expand Up @@ -186,8 +186,8 @@ func TestReconcile(t *testing.T) {
RequeueAfter: ((3 * time.Minute) - twoMinuteDuration),
},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
testsyncset.Build(syncSetBase()),
testcheckpoint.Build(checkpointBase(),
testcheckpoint.WithLastBackupRef(hivev1.BackupReference{Name: "notarealbackup", Namespace: namespace}),
testcheckpoint.WithLastBackupTime(twoMinutesAgo),
Expand Down Expand Up @@ -218,8 +218,8 @@ func TestReconcile(t *testing.T) {
},
expectedResult: reconcile.Result{},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
testsyncset.Build(syncSetBase()),
testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum(
[]runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase()),
Expand Down Expand Up @@ -249,8 +249,8 @@ func TestReconcile(t *testing.T) {
},
expectedResult: reconcile.Result{},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testsyncset.Build(syncSetBase(), testsyncset.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
testsyncset.Build(syncSetBase()),
testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum(calculateRuntimeObjectsChecksum(
[]runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase()),
Expand Down Expand Up @@ -331,17 +331,17 @@ func TestGetRuntimeObjects(t *testing.T) {
testclusterdeployment.Build(clusterDeploymentBase()),
},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
},
},
{
name: "2 ClusterDeployments in different namespaces",
existingObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase()),
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.Generic(generic.WithNamespace("not the correct namespace")), testclusterdeployment.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.Generic(generic.WithNamespace("not the correct namespace"))),
},
expectedObjects: []runtime.Object{
testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
testclusterdeployment.Build(clusterDeploymentBase()),
},
},
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func TestGetNamespaceCheckpoint(t *testing.T) {
name: "Existing Checkpoint",
expectedFound: true,
existingObjects: []runtime.Object{testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"))},
expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"), testcheckpoint.WithTypeMeta(), testcheckpoint.WithResourceVersion("999")),
expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL"), testcheckpoint.WithTypeMeta()),
expectedError: nil,
},
}
Expand Down Expand Up @@ -441,7 +441,7 @@ func TestCreateOrUpdateNamespaceCheckpoint(t *testing.T) {
existingObjects: []runtime.Object{
testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE")),
},
expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE"), testcheckpoint.WithTypeMeta(), testcheckpoint.WithResourceVersion("999")),
expectedCheckpoint: testcheckpoint.Build(checkpointBase(), testcheckpoint.WithLastBackupChecksum("NOTREAL-BEFORE"), testcheckpoint.WithTypeMeta()),
expectedError: statusErr,
},
{
Expand Down Expand Up @@ -480,7 +480,7 @@ func TestCalculateObjectsChecksumWithoutStatus(t *testing.T) {
}{
{
name: "Valid ClusterDeployment Checksum",
object: testclusterdeployment.Build(clusterDeploymentBase(), testclusterdeployment.WithResourceVersion("999")),
object: testclusterdeployment.Build(clusterDeploymentBase()),
expectedChecksum: calculateClusterDeploymentChecksum(testclusterdeployment.Build(clusterDeploymentBase())),
},
{
Expand Down
5 changes: 0 additions & 5 deletions pkg/test/clusterdeployment/clusterdeployment.go
Expand Up @@ -81,11 +81,6 @@ func WithName(name string) Option {
return Generic(generic.WithName(name))
}

// WithResourceVersion sets the specified resource version on the supplied object.
func WithResourceVersion(resourceVersion string) Option {
return Generic(generic.WithResourceVersion(resourceVersion))
}

// WithNamespace sets the object.Namespace field when building an object with Build.
func WithNamespace(namespace string) Option {
return Generic(generic.WithNamespace(namespace))
Expand Down
5 changes: 0 additions & 5 deletions pkg/test/syncset/syncset.go
Expand Up @@ -127,8 +127,3 @@ func WithPatches(patches ...hivev1.SyncObjectPatch) Option {
syncSet.Spec.Patches = patches
}
}

// WithResourceVersion sets the specified resource version on the supplied object.
func WithResourceVersion(resourceVersion string) Option {
return Generic(generic.WithResourceVersion(resourceVersion))
}

0 comments on commit 8f5cb7f

Please sign in to comment.