Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: flaky webhook nil labels/annotations test #719

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions controllers/admissionpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,12 @@ var _ = Describe("AdmissionPolicy controller", func() {
HaveField("Webhooks", Equal(originalValidatingWebhookConfiguration.Webhooks)),
),
)
})

It("should reconcile unitialized label and annotation maps (behavior of Kubewarden <= 1.9.0))", func() {
By("changing the ValidatingWebhookConfiguration")
validatingWebhookConfiguration, err := getTestValidatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalValidatingWebhookConfiguration := validatingWebhookConfiguration.DeepCopy()
// simulate unitialized labels and annotation maps (behaviour of Kubewarden <= 1.9.0), or user change
By("setting the ValidatingWebhookConfiguration labels and annotation to nil")
validatingWebhookConfiguration, err = getTestValidatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalValidatingWebhookConfiguration = validatingWebhookConfiguration.DeepCopy()
validatingWebhookConfiguration.Labels = nil
validatingWebhookConfiguration.Annotations = nil
Expect(
Expand Down Expand Up @@ -230,14 +228,12 @@ var _ = Describe("AdmissionPolicy controller", func() {
HaveField("Webhooks", Equal(originalMutatingWebhookConfiguration.Webhooks)),
),
)
})

It("should reconcile unitialized label and annotation maps (behavior of Kubewarden <= 1.9.0))", func() {
By("changing the MutatingWebhookConfiguration")
mutatingWebhookConfiguration, err := getTestMutatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalMutatingWebhookConfiguration := mutatingWebhookConfiguration.DeepCopy()
// simulate unitialized labels and annotation maps (behaviour of Kubewarden <= 1.9.0), or user change
By("by setting the MutatingWebhookConfiguration labels and annotation to nil")
mutatingWebhookConfiguration, err = getTestMutatingWebhookConfiguration(fmt.Sprintf("namespaced-%s-%s", policyNamespace, policyName))
Expect(err).ToNot(HaveOccurred())
originalMutatingWebhookConfiguration = mutatingWebhookConfiguration.DeepCopy()
mutatingWebhookConfiguration.Labels = nil
mutatingWebhookConfiguration.Annotations = nil
Expect(
Expand Down
Loading