Skip to content

Commit

Permalink
ssa: fix flaky test TestPatch/Test patch with Machine
Browse files Browse the repository at this point in the history
During the test at the additional Patch calls the defaulting webhook did always
set the .spec.infrastructureRef.namespace field.

This caused flaky behaviour because there was a chance for the resourceVersion
to getting bumped with the only change being the timestamp in managedFields.
  • Loading branch information
chrischdi committed Dec 22, 2023
1 parent 235d965 commit 6900d3b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/util/ssa/patch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"time"

. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/utils/ptr"
Expand Down Expand Up @@ -111,6 +112,11 @@ func TestPatch(t *testing.T) {
Bootstrap: clusterv1.Bootstrap{
DataSecretName: ptr.To("data-secret"),
},
InfrastructureRef: corev1.ObjectReference{
// The namespace needs to get set here. Otherwise the defaulting webhook always sets this field again
// which would lead to an resourceVersion bump at the 3rd step and to a flaky test.
Namespace: ns.Name,
},
},
}
fieldManager := "test-manager"
Expand Down

0 comments on commit 6900d3b

Please sign in to comment.