Skip to content

Commit 2b808a6

Browse files
authored
Merge pull request #4880 from camilamacedo86/cleanup-e2e
🌱 (ci) - fix cleanup for go/v4 e2e tests
2 parents 0c3b376 + d8d69dd commit 2b808a6

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

test/e2e/v4/plugin_cluster_test.go

Lines changed: 16 additions & 13 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
})
@@ -531,6 +534,16 @@ func getMetricsOutput(kbc *utils.TestContext) string {
531534
}
532535
Eventually(verifyCurlUp, 240*time.Second, time.Second).Should(Succeed())
533536

537+
By("validating that the correct ServiceAccount is being used")
538+
saName := kbc.Kubectl.ServiceAccount
539+
currentSAOutput, err := kbc.Kubectl.Get(
540+
true,
541+
"serviceaccount", saName,
542+
"-o", "jsonpath={.metadata.name}",
543+
)
544+
Expect(err).NotTo(HaveOccurred(), "Failed to fetch the service account")
545+
Expect(currentSAOutput).To(Equal(saName), "The ServiceAccount in use does not match the expected one")
546+
534547
By("validating that the metrics endpoint is serving as expected")
535548
getCurlLogs := func(g Gomega) {
536549
metricsOutput, err = kbc.Kubectl.Logs("curl")
@@ -569,16 +582,6 @@ func metricsShouldBeUnavailable(kbc *utils.TestContext) {
569582
}
570583
Eventually(verifyCurlUp, 240*time.Second, time.Second).Should(Succeed())
571584

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-
582585
By("validating that the metrics endpoint is not working as expected")
583586
getCurlLogs := func(g Gomega) {
584587
metricsOutput, err := kbc.Kubectl.Logs("curl")
@@ -626,7 +629,7 @@ func cmdOptsToCreateCurlPod(kbc *utils.TestContext, token string) []string {
626629

627630
func removeCurlPod(kbc *utils.TestContext) {
628631
By("cleaning up the curl pod")
629-
_, err := kbc.Kubectl.Delete(true, "pods/curl")
632+
_, err := kbc.Kubectl.Delete(true, "pods/curl", "--grace-period=0", "--force")
630633
Expect(err).NotTo(HaveOccurred())
631634
}
632635

0 commit comments

Comments
 (0)