Skip to content

Commit 40094d2

Browse files
(ci) - fix cleanup to allow tests broken for 1.33 work
1 parent 5d3e33b commit 40094d2

File tree

1 file changed

+25
-28
lines changed

1 file changed

+25
-28
lines changed

test/e2e/v4/plugin_cluster_test.go

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,15 @@ var _ = Describe("kubebuilder", func() {
5757
})
5858

5959
AfterEach(func() {
60-
By("By removing restricted namespace label")
60+
By("removing restricted namespace label")
6161
_ = kbc.RemoveNamespaceLabelToEnforceRestricted()
6262

63-
By("clean up API objects created during the test")
63+
By("undeploy the project")
6464
_ = kbc.Make("undeploy")
6565

66+
By("uninstalling the project")
67+
_ = kbc.Make("uninstall")
68+
6669
By("removing controller image and working dir")
6770
kbc.Destroy()
6871
})
@@ -88,25 +91,19 @@ var _ = Describe("kubebuilder", func() {
8891
GenerateV4WithoutMetrics(kbc)
8992
Run(kbc, true, false, false, false, false)
9093
})
91-
// FIXME: This test is currently disabled because it requires to be fixed:
92-
// https://github.com/kubernetes-sigs/kubebuilder/issues/4853
93-
// It is not working for k8s 1.33
94-
// It("should generate a runnable project with metrics protected by network policies", func() {
95-
// GenerateV4WithNetworkPoliciesWithoutWebhooks(kbc)
96-
// Run(kbc, false, false, false, true, true)
97-
// })
94+
It("should generate a runnable project with the manager running "+
95+
"as restricted and without webhooks", func() {
96+
GenerateV4WithoutWebhooks(kbc)
97+
Run(kbc, false, false, false, true, false)
98+
})
99+
It("should generate a runnable project with metrics protected by network policies", func() {
100+
GenerateV4WithNetworkPoliciesWithoutWebhooks(kbc)
101+
Run(kbc, false, false, false, true, true)
102+
})
98103
It("should generate a runnable project with webhooks and metrics protected by network policies", func() {
99104
GenerateV4WithNetworkPolicies(kbc)
100105
Run(kbc, true, false, false, true, true)
101106
})
102-
// FIXME: This test is currently disabled because it requires to be fixed:
103-
// https://github.com/kubernetes-sigs/kubebuilder/issues/4853
104-
// It is not working for k8s 1.33
105-
// It("should generate a runnable project with the manager running "+
106-
// "as restricted and without webhooks", func() {
107-
// GenerateV4WithoutWebhooks(kbc)
108-
// Run(kbc, false, false, false, true, false)
109-
// })
110107
})
111108
})
112109

@@ -531,6 +528,16 @@ func getMetricsOutput(kbc *utils.TestContext) string {
531528
}
532529
Eventually(verifyCurlUp, 240*time.Second, time.Second).Should(Succeed())
533530

531+
By("validating that the correct ServiceAccount is being used")
532+
saName := kbc.Kubectl.ServiceAccount
533+
currentSAOutput, err := kbc.Kubectl.Get(
534+
true,
535+
"serviceaccount", saName,
536+
"-o", "jsonpath={.metadata.name}",
537+
)
538+
Expect(err).NotTo(HaveOccurred(), "Failed to fetch the service account")
539+
Expect(currentSAOutput).To(Equal(saName), "The ServiceAccount in use does not match the expected one")
540+
534541
By("validating that the metrics endpoint is serving as expected")
535542
getCurlLogs := func(g Gomega) {
536543
metricsOutput, err = kbc.Kubectl.Logs("curl")
@@ -569,16 +576,6 @@ func metricsShouldBeUnavailable(kbc *utils.TestContext) {
569576
}
570577
Eventually(verifyCurlUp, 240*time.Second, time.Second).Should(Succeed())
571578

572-
By("validating that the correct ServiceAccount is being used")
573-
saName := kbc.Kubectl.ServiceAccount
574-
currentSAOutput, err := kbc.Kubectl.Get(
575-
true,
576-
"serviceaccount", saName,
577-
"-o", "jsonpath={.metadata.name}",
578-
)
579-
Expect(err).NotTo(HaveOccurred(), "Failed to fetch the service account")
580-
Expect(currentSAOutput).To(Equal(saName), "The ServiceAccount in use does not match the expected one")
581-
582579
By("validating that the metrics endpoint is not working as expected")
583580
getCurlLogs := func(g Gomega) {
584581
metricsOutput, err := kbc.Kubectl.Logs("curl")
@@ -626,7 +623,7 @@ func cmdOptsToCreateCurlPod(kbc *utils.TestContext, token string) []string {
626623

627624
func removeCurlPod(kbc *utils.TestContext) {
628625
By("cleaning up the curl pod")
629-
_, err := kbc.Kubectl.Delete(true, "pods/curl")
626+
_, err := kbc.Kubectl.Delete(true, "pods/curl", "--grace-period=0", "--force")
630627
Expect(err).NotTo(HaveOccurred())
631628
}
632629

0 commit comments

Comments
 (0)