Skip to content

Commit c7daa50

Browse files
(ci) - fix cleanup to allow tests broken for 1.33 work
1 parent 1d073d9 commit c7daa50

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

test/e2e/v4/plugin_cluster_test.go

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ var _ = Describe("kubebuilder", func() {
6363
By("clean up API objects created during the test")
6464
_ = kbc.Make("undeploy")
6565

66+
By("clean up API objects created during the test")
67+
_ = kbc.Make("uninstall")
68+
6669
By("removing controller image and working dir")
6770
kbc.Destroy()
6871
})
@@ -88,13 +91,10 @@ 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 metrics protected by network policies", func() {
95+
GenerateV4WithNetworkPoliciesWithoutWebhooks(kbc)
96+
Run(kbc, false, false, false, true, true)
97+
})
9898
It("should generate a runnable project with webhooks and metrics protected by network policies", func() {
9999
GenerateV4WithNetworkPolicies(kbc)
100100
Run(kbc, true, false, false, true, true)
@@ -501,6 +501,13 @@ func getMetricsOutput(kbc *utils.TestContext) string {
501501
)
502502
Expect(err).NotTo(HaveOccurred(), "Controller-manager service should exist")
503503

504+
By("checking controller-manager logs to verify metrics server is up")
505+
controllerPodName := getControllerName(kbc)
506+
logs, err := kbc.Kubectl.Logs(controllerPodName)
507+
Expect(err).NotTo(HaveOccurred(), "failed to get controller-manager logs")
508+
Expect(logs).To(ContainSubstring("Serving metrics server"),
509+
"controller logs should show that metrics server is up")
510+
504511
By("ensuring the service endpoint is ready")
505512
checkServiceEndpoint := func(g Gomega) {
506513
var output string
@@ -626,8 +633,25 @@ func cmdOptsToCreateCurlPod(kbc *utils.TestContext, token string) []string {
626633

627634
func removeCurlPod(kbc *utils.TestContext) {
628635
By("cleaning up the curl pod")
629-
_, err := kbc.Kubectl.Delete(true, "pods/curl")
630-
Expect(err).NotTo(HaveOccurred())
636+
_, err := kbc.Kubectl.Delete(true, "pod", "curl")
637+
Expect(err).NotTo(HaveOccurred(), "Failed to delete curl pod")
638+
639+
var deleted bool
640+
Eventually(func() bool {
641+
_, err := kbc.Kubectl.Get(true, "pod", "curl")
642+
deleted = err != nil
643+
return deleted
644+
}, time.Minute, time.Second).Should(BeTrue(), "curl pod should be deleted within 1 minute")
645+
646+
if !deleted {
647+
By("forcing deletion of the curl pod")
648+
_, err := kbc.Kubectl.Command("delete", "pod", "curl", "--grace-period=0", "--force")
649+
Expect(err).NotTo(HaveOccurred(), "Force delete of curl pod failed")
650+
Eventually(func(g Gomega) {
651+
_, err := kbc.Kubectl.Get(true, "pod", "curl")
652+
g.Expect(err).To(HaveOccurred())
653+
}, time.Minute, time.Second).Should(Succeed(), "curl pod should be deleted after force")
654+
}
631655
}
632656

633657
// serviceAccountToken provides a helper function that can provide you with a service account

0 commit comments

Comments
 (0)