diff --git a/tests/e2e/dualstack/dualstack_test.go b/tests/e2e/dualstack/dualstack_test.go index b4108509b..e213c3d5e 100644 --- a/tests/e2e/dualstack/dualstack_test.go +++ b/tests/e2e/dualstack/dualstack_test.go @@ -244,10 +244,8 @@ spec: AfterAll(func(ctx SpecContext) { By("Deleting the pods") - Expect(k.DeleteNamespace(DualStackNamespace)).To(Succeed(), fmt.Sprintf("Failed to delete the %q namespace", DualStackNamespace)) - Expect(k.DeleteNamespace(IPv4Namespace)).To(Succeed(), fmt.Sprintf("Failed to delete the %q namespace", IPv4Namespace)) - Expect(k.DeleteNamespace(IPv6Namespace)).To(Succeed(), fmt.Sprintf("Failed to delete the %q namespace", IPv6Namespace)) - Expect(k.DeleteNamespace(SleepNamespace)).To(Succeed(), fmt.Sprintf("Failed to delete the %q namespace", SleepNamespace)) + Expect(k.DeleteNamespace(DualStackNamespace, IPv4Namespace, IPv6Namespace, SleepNamespace)). + To(Succeed(), "Failed to delete namespaces") Success("DualStack validation pods deleted") }) }) diff --git a/tests/e2e/util/kubectl/kubectl.go b/tests/e2e/util/kubectl/kubectl.go index 28e5b0adf..5c92fbee0 100644 --- a/tests/e2e/util/kubectl/kubectl.go +++ b/tests/e2e/util/kubectl/kubectl.go @@ -124,17 +124,17 @@ func (k Kubectl) DeleteCRDs(crds []string) error { } // DeleteNamespaceNoWait deletes a namespace and returns immediately (without waiting for the namespace to be removed). -func (k Kubectl) DeleteNamespaceNoWait(ns string) error { - return k.deleteNamespace(ns, false) +func (k Kubectl) DeleteNamespaceNoWait(namespaces ...string) error { + return k.deleteNamespace(namespaces, false) } // DeleteNamespace deletes a namespace and waits for it to be removed completely. -func (k Kubectl) DeleteNamespace(ns string) error { - return k.deleteNamespace(ns, true) +func (k Kubectl) DeleteNamespace(namespaces ...string) error { + return k.deleteNamespace(namespaces, true) } -func (k Kubectl) deleteNamespace(ns string, wait bool) error { - cmd := k.build(" delete namespace " + ns + " --wait=" + strconv.FormatBool(wait)) +func (k Kubectl) deleteNamespace(namespaces []string, wait bool) error { + cmd := k.build(" delete namespace " + strings.Join(namespaces, " ") + " --wait=" + strconv.FormatBool(wait)) _, err := k.executeCommand(cmd) if err != nil { return fmt.Errorf("error deleting namespace: %w", err)