From e3e6e215b7a4b64aa59f9859b726a990171f8b27 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Thu, 20 Apr 2023 02:24:51 -0700 Subject: [PATCH] e2e: fix AfterEach to be in the correct location 'AfterEach' was made to prevent the failure of a plugin pod that occurs due to 'BeforeEach' that deploys a plugin pod. If it is inside a 'Context' it will still occur the same problem. Since current e2e tests have one 'Context' in general, problems were not visible, but it still have problem in logic and would cause the same problems if more 'Contexts' are made. So, this commit fixes 'AfterEach' to be in the correct location. Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dsa/dsa.go | 16 ++++++++-------- test/e2e/qat/qatplugin_dpdk.go | 17 +++++++++-------- test/e2e/qat/qatplugin_kernel.go | 16 ++++++++-------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/test/e2e/dsa/dsa.go b/test/e2e/dsa/dsa.go index ce7172c2..410e8654 100644 --- a/test/e2e/dsa/dsa.go +++ b/test/e2e/dsa/dsa.go @@ -85,6 +85,14 @@ func describe() { } }) + ginkgo.AfterEach(func() { + ginkgo.By("undeploying DSA plugin") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath)) + if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { + framework.Failf("failed to terminate pod: %v", err) + } + }) + ginkgo.Context("When DSA resources are available", func() { ginkgo.BeforeEach(func() { ginkgo.By("checking if the resource is allocatable") @@ -93,14 +101,6 @@ func describe() { } }) - ginkgo.AfterEach(func() { - ginkgo.By("undeploying DSA plugin") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath)) - if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { - framework.Failf("failed to terminate pod: %v", err) - } - }) - ginkgo.It("deploys a demo app", func() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 59cbcfc2..5dadaa71 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -85,6 +85,14 @@ func describeQatDpdkPlugin() { } }) + ginkgo.AfterEach(func() { + ginkgo.By("undeploying QAT plugin") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath)) + if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { + framework.Failf("failed to terminate pod: %v", err) + } + }) + ginkgo.Context("When QAT Gen4 resources are available", func() { ginkgo.BeforeEach(func() { ginkgo.By("checking if the resource is allocatable") @@ -93,14 +101,6 @@ func describeQatDpdkPlugin() { } }) - ginkgo.AfterEach(func() { - ginkgo.By("undeploying QAT plugin") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-k", filepath.Dir(kustomizationPath)) - if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { - framework.Failf("failed to terminate pod: %v", err) - } - }) - ginkgo.It("deploys a crypto pod requesting QAT resources", func() { ginkgo.By("submitting a crypto pod requesting QAT resources") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", opensslTestYamlPath) @@ -113,6 +113,7 @@ func describeQatDpdkPlugin() { framework.Logf("cpa_sample_code output:\n %s", output) }) }) + ginkgo.Context("When QAT Gen2 resources are available", func() { ginkgo.BeforeEach(func() { ginkgo.By("checking if the resource is allocatable") diff --git a/test/e2e/qat/qatplugin_kernel.go b/test/e2e/qat/qatplugin_kernel.go index 5f95ade1..29275e01 100644 --- a/test/e2e/qat/qatplugin_kernel.go +++ b/test/e2e/qat/qatplugin_kernel.go @@ -71,6 +71,14 @@ func describeQatKernelPlugin() { } }) + ginkgo.AfterEach(func() { + ginkgo.By("undeploying QAT plugin") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-f", yamlPath) + if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { + framework.Failf("failed to terminate pod: %v", err) + } + }) + ginkgo.Context("When QAT resources are available", func() { ginkgo.BeforeEach(func() { ginkgo.By("checking if the resource is allocatable") @@ -79,14 +87,6 @@ func describeQatKernelPlugin() { } }) - ginkgo.AfterEach(func() { - ginkgo.By("undeploying QAT plugin") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "delete", "-f", yamlPath) - if err := e2epod.WaitForPodNotFoundInNamespace(f.ClientSet, dpPodName, f.Namespace.Name, 30*time.Second); err != nil { - framework.Failf("failed to terminate pod: %v", err) - } - }) - ginkgo.It("deploys a pod requesting QAT resources", func() { ginkgo.By("submitting a pod requesting QAT resources") podSpec := &v1.Pod{