From f51382b5176ac33889d2667d687b860126164b16 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Fri, 24 Mar 2023 03:33:41 -0700 Subject: [PATCH] e2e: ensure device plugin gets deleted before next one is deployed Though namespace is deleted after each It(), it does not ensure that it is deleted. Because of this reason, device plugin did not get deleted before the next one is deployed. This can cause a temporary crash of the new plugin and sometimes becomes the cause of e2e test's failure. This commit fixes it by ensuring previous device plugin gets deleted after each run. Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dlb/dlb.go | 11 +++++++++++ test/e2e/dsa/dsa.go | 11 +++++++++++ test/e2e/iaa/iaa.go | 11 +++++++++++ test/e2e/qat/qatplugin_dpdk.go | 11 +++++++++++ test/e2e/qat/qatplugin_kernel.go | 11 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/test/e2e/dlb/dlb.go b/test/e2e/dlb/dlb.go index 3607aa47..e606348e 100644 --- a/test/e2e/dlb/dlb.go +++ b/test/e2e/dlb/dlb.go @@ -49,6 +49,8 @@ func describe() { framework.Failf("unable to locate %q: %v", kustomizationYaml, err) } + var dpPodName string + ginkgo.BeforeEach(func() { ginkgo.By("deploying DLB plugin") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) @@ -61,6 +63,7 @@ func describe() { e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) framework.Failf("unable to wait for all pods to be running and ready: %v", err) } + dpPodName = podList.Items[0].Name ginkgo.By("checking DLB plugin's securityContext") if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { @@ -68,6 +71,14 @@ func describe() { } }) + ginkgo.AfterEach(func() { + ginkgo.By("undeploying DLB 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 PF resources are available", func() { ginkgo.BeforeEach(func() { resource := v1.ResourceName("dlb.intel.com/pf") diff --git a/test/e2e/dsa/dsa.go b/test/e2e/dsa/dsa.go index a792b340..ce7172c2 100644 --- a/test/e2e/dsa/dsa.go +++ b/test/e2e/dsa/dsa.go @@ -60,6 +60,8 @@ func describe() { framework.Failf("unable to locate %q: %v", demoYaml, err) } + var dpPodName string + ginkgo.Describe("Without using operator", func() { ginkgo.BeforeEach(func() { ginkgo.By("deploying DSA plugin") @@ -75,6 +77,7 @@ func describe() { e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) framework.Failf("unable to wait for all pods to be running and ready: %v", err) } + dpPodName = podList.Items[0].Name ginkgo.By("checking DSA plugin's securityContext") if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { @@ -90,6 +93,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.It("deploys a demo app", func() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) diff --git a/test/e2e/iaa/iaa.go b/test/e2e/iaa/iaa.go index 6cbadb0e..891c1e18 100644 --- a/test/e2e/iaa/iaa.go +++ b/test/e2e/iaa/iaa.go @@ -60,6 +60,8 @@ func describe() { framework.Failf("unable to locate %q: %v", demoYaml, err) } + var dpPodName string + ginkgo.Describe("Without using operator", func() { ginkgo.BeforeEach(func() { ginkgo.By("deploying IAA plugin") @@ -75,6 +77,7 @@ func describe() { e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) framework.Failf("unable to wait for all pods to be running and ready: %v", err) } + dpPodName = podList.Items[0].Name ginkgo.By("checking IAA plugin's securityContext") if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { @@ -82,6 +85,14 @@ func describe() { } }) + ginkgo.AfterEach(func() { + ginkgo.By("undeploying IAA 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 IAA resources are available", func() { ginkgo.BeforeEach(func() { ginkgo.By("checking if the resource is allocatable") diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 2f38d2e0..59cbcfc2 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -63,6 +63,8 @@ func describeQatDpdkPlugin() { framework.Failf("unable to locate %q: %v", opensslTestYaml, err) } + var dpPodName string + ginkgo.BeforeEach(func() { ginkgo.By("deploying QAT plugin in DPDK mode") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) @@ -75,6 +77,7 @@ func describeQatDpdkPlugin() { e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) framework.Failf("unable to wait for all pods to be running and ready: %v", err) } + dpPodName = podList.Items[0].Name ginkgo.By("checking QAT plugin's securityContext") if err := utils.TestPodsFileSystemInfo(podList.Items); err != nil { @@ -90,6 +93,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.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) diff --git a/test/e2e/qat/qatplugin_kernel.go b/test/e2e/qat/qatplugin_kernel.go index 1f1c86dd..5f95ade1 100644 --- a/test/e2e/qat/qatplugin_kernel.go +++ b/test/e2e/qat/qatplugin_kernel.go @@ -49,6 +49,8 @@ func describeQatKernelPlugin() { framework.Failf("unable to locate %q: %v", qatPluginKernelYaml, err) } + var dpPodName string + ginkgo.BeforeEach(func() { ginkgo.By("deploying QAT plugin in kernel mode") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "-f", yamlPath) @@ -61,6 +63,7 @@ func describeQatKernelPlugin() { e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) framework.Failf("unable to wait for all pods to be running and ready: %v", err) } + dpPodName = podList.Items[0].Name ginkgo.By("checking QAT plugin's securityContext") if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { @@ -76,6 +79,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.It("deploys a pod requesting QAT resources", func() { ginkgo.By("submitting a pod requesting QAT resources") podSpec := &v1.Pod{