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 <hyeongju.lee@intel.com>
This commit is contained in:
Hyeongju Johannes Lee 2023-03-24 03:33:41 -07:00
parent 944df4e9ad
commit f51382b517
5 changed files with 55 additions and 0 deletions

View File

@ -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")

View File

@ -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)

View File

@ -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")

View File

@ -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)

View File

@ -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{