From b111203392619b9b612f0af92226edf4845a7c8d Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 7 Feb 2023 15:24:05 +0200 Subject: [PATCH 1/4] e2e, dlb: divide single It() to have multiple layers Structure is as follows: Describe("DLB plugin") BeforeEach("deploys plugin") Context("When device resources are available") BeforeEach("checks if resources are available") It("runs a pod requesting resources") Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dlb/dlb.go | 64 +++++++++++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/test/e2e/dlb/dlb.go b/test/e2e/dlb/dlb.go index baae463f4..3607aa473 100644 --- a/test/e2e/dlb/dlb.go +++ b/test/e2e/dlb/dlb.go @@ -49,7 +49,7 @@ func describe() { framework.Failf("unable to locate %q: %v", kustomizationYaml, err) } - ginkgo.It("runs DLB plugin and a demo workload", func() { + ginkgo.BeforeEach(func() { ginkgo.By("deploying DLB plugin") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) @@ -66,36 +66,56 @@ func describe() { if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { framework.Failf("container filesystem info checks failed: %v", err) } + }) - for _, resource := range []v1.ResourceName{"dlb.intel.com/pf", "dlb.intel.com/vf"} { - ginkgo.By("checking if the " + resource.String() + " resource is allocatable") - if err = utils.WaitForNodesWithResource(f.ClientSet, resource, 30*time.Second); err != nil { + ginkgo.Context("When PF resources are available", func() { + ginkgo.BeforeEach(func() { + resource := v1.ResourceName("dlb.intel.com/pf") + if err := utils.WaitForNodesWithResource(f.ClientSet, resource, 30*time.Second); err != nil { framework.Failf("unable to wait for nodes to have positive allocatable resource %s: %v", resource, err) } - } + }) - for function, yaml := range map[string]string{"PF": demoPFYaml, "VF": demoVFYaml} { - demoPath, err := utils.LocateRepoFile(yaml) - if err != nil { - framework.Failf("unable to locate %q: %v", yaml, err) + ginkgo.It("can run demo app", func() { + runDemoApp("PF", demoPFYaml, f) + }) + }) + + ginkgo.Context("When VF resources are available", func() { + ginkgo.BeforeEach(func() { + resource := v1.ResourceName("dlb.intel.com/vf") + if err := utils.WaitForNodesWithResource(f.ClientSet, resource, 30*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource %s: %v", resource, err) } + }) - podName := strings.TrimSuffix(filepath.Base(yaml), filepath.Ext(yaml)) + ginkgo.It("can run demo app", func() { + runDemoApp("VF", demoVFYaml, f) + }) + }) +} - ginkgo.By("submitting a pod requesting DLB " + function + " resources") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) +func runDemoApp(function, yaml string, f *framework.Framework) { + demoPath, err := utils.LocateRepoFile(yaml) + if err != nil { + framework.Failf("unable to locate %q: %v", yaml, err) + } - ginkgo.By("waiting for the DLB demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(podName, 200*time.Second) + podName := strings.TrimSuffix(filepath.Base(yaml), filepath.Ext(yaml)) - ginkgo.By("getting workload log") - log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) + ginkgo.By("submitting a pod requesting DLB " + function + " resources") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } + ginkgo.By("waiting for the DLB demo to succeed") + e2epod.NewPodClient(f).WaitForSuccess(podName, 200*time.Second) - framework.Logf("log output: %s", log) - } - }) + ginkgo.By("getting workload log") + + log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) + + if err != nil { + framework.Failf("unable to get log from pod: %v", err) + } + + framework.Logf("log output: %s", log) } From fc0d0b5e0ca2c9d1ab7981f2a3404551b63fe474 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 7 Feb 2023 15:27:56 +0200 Subject: [PATCH 2/4] e2e, dsa: divide single It() to have multiple layers Structure is as follows: Describe("DSA plugin") Describe("without using operator") BeforeEach("deploys plugin") Context("When device resources are available") BeforeEach("checks if resources are available") It("runs a pod requesting resources") Describe("with using operator") It("deploys with operator") Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dsa/dsa.go | 114 ++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/test/e2e/dsa/dsa.go b/test/e2e/dsa/dsa.go index 5c3623d03..a792b340d 100644 --- a/test/e2e/dsa/dsa.go +++ b/test/e2e/dsa/dsa.go @@ -60,65 +60,75 @@ func describe() { framework.Failf("unable to locate %q: %v", demoYaml, err) } - ginkgo.It("runs DSA plugin and a demo workload", func() { - ginkgo.By("deploying DSA plugin") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-dsa-config", "--from-file="+configmap) - - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) - - ginkgo.By("waiting for DSA plugin's availability") - podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name, - labels.Set{"app": "intel-dsa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second) - if err != nil { - e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name) - e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } - - ginkgo.By("checking DSA plugin's securityContext") - if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { - framework.Failf("container filesystem info checks failed: %v", err) - } - - ginkgo.By("checking if the resource is allocatable") - if err = utils.WaitForNodesWithResource(f.ClientSet, "dsa.intel.com/wq-user-dedicated", 300*time.Second); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } - - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) - - ginkgo.By("waiting for the DSA demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(podName, 200*time.Second) - - ginkgo.By("getting workload log") - log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) - - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } - - framework.Logf("log output: %s", log) + ginkgo.Describe("Without using operator", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("deploying DSA plugin") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-dsa-config", "--from-file="+configmap) + + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) + + ginkgo.By("waiting for DSA plugin's availability") + podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name, + labels.Set{"app": "intel-dsa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second) + if err != nil { + e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name) + e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } + + ginkgo.By("checking DSA plugin's securityContext") + if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { + framework.Failf("container filesystem info checks failed: %v", err) + } + }) + + ginkgo.Context("When DSA resources are available", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("checking if the resource is allocatable") + if err := utils.WaitForNodesWithResource(f.ClientSet, "dsa.intel.com/wq-user-dedicated", 300*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } + }) + + ginkgo.It("deploys a demo app", func() { + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) + + ginkgo.By("waiting for the DSA demo to succeed") + e2epod.NewPodClient(f).WaitForSuccess(podName, 200*time.Second) + + ginkgo.By("getting workload log") + log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) + + if err != nil { + framework.Failf("unable to get log from pod: %v", err) + } + + framework.Logf("log output: %s", log) + }) + }) }) - ginkgo.It("deploys DSA plugin with operator", func() { - utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml") + ginkgo.Describe("With using operator", func() { + ginkgo.It("deploys DSA plugin with operator", func() { + utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml") - if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil { - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } + if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil { + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } - utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml") + utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml") - if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-dsa-plugin"}.AsSelector(), 1, timeout); err != nil { - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } + if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-dsa-plugin"}.AsSelector(), 1, timeout); err != nil { + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } - if err := utils.WaitForNodesWithResource(f.ClientSet, "dsa.intel.com/wq-user-dedicated", timeout); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } + if err := utils.WaitForNodesWithResource(f.ClientSet, "dsa.intel.com/wq-user-dedicated", timeout); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } - utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml") + utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_dsadeviceplugin.yaml") - utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml") + utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml") + }) }) } From 77ad32e008857883125f6c852ed22445fec99987 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 7 Feb 2023 15:30:45 +0200 Subject: [PATCH 3/4] e2e, iaa: divide single It() to have multiple layers Structure is as follows: Describe("IAA plugin") Describe("without using operator") BeforeEach("deploys plugin") Context("When device resources are available") BeforeEach("checks if resources are available") It("runs a pod requesting resources") Describe("with using operator") It("deploys with operator") Signed-off-by: Hyeongju Johannes Lee --- test/e2e/iaa/iaa.go | 114 ++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 52 deletions(-) diff --git a/test/e2e/iaa/iaa.go b/test/e2e/iaa/iaa.go index 1c28298ed..6cbadb0ea 100644 --- a/test/e2e/iaa/iaa.go +++ b/test/e2e/iaa/iaa.go @@ -60,65 +60,75 @@ func describe() { framework.Failf("unable to locate %q: %v", demoYaml, err) } - ginkgo.It("runs IAA plugin and a demo workload", func() { - ginkgo.By("deploying IAA plugin") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-iaa-config", "--from-file="+configmap) - - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) - - ginkgo.By("waiting for IAA plugin's availability") - podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name, - labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second) - if err != nil { - e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name) - e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } - - ginkgo.By("checking IAA plugin's securityContext") - if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { - framework.Failf("container filesystem info checks failed: %v", err) - } - - ginkgo.By("checking if the resource is allocatable") - if err = utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", 300*time.Second); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } - - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) - - ginkgo.By("waiting for the IAA demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(podName, 300*time.Second) - - ginkgo.By("getting workload log") - log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) - - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } - - framework.Logf("log output: %s", log) + ginkgo.Describe("Without using operator", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("deploying IAA plugin") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "intel-iaa-config", "--from-file="+configmap) + + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) + + ginkgo.By("waiting for IAA plugin's availability") + podList, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, f.Namespace.Name, + labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1 /* one replica */, 300*time.Second) + if err != nil { + e2edebug.DumpAllNamespaceInfo(f.ClientSet, f.Namespace.Name) + e2ekubectl.LogFailedContainers(f.ClientSet, f.Namespace.Name, framework.Logf) + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } + + ginkgo.By("checking IAA plugin's securityContext") + if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { + framework.Failf("container filesystem info checks failed: %v", err) + } + }) + + ginkgo.Context("When IAA resources are available", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("checking if the resource is allocatable") + if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", 300*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } + }) + + ginkgo.It("deploys a demo app", func() { + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) + + ginkgo.By("waiting for the IAA demo to succeed") + e2epod.NewPodClient(f).WaitForSuccess(podName, 300*time.Second) + + ginkgo.By("getting workload log") + log, err := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, podName, podName) + + if err != nil { + framework.Failf("unable to get log from pod: %v", err) + } + + framework.Logf("log output: %s", log) + }) + }) }) - ginkgo.It("deploys IAA plugin with operator", func() { - utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml") + ginkgo.Describe("With using operator", func() { + ginkgo.It("deploys IAA plugin with operator", func() { + utils.Kubectl("", "apply", "-k", "deployments/operator/default/kustomization.yaml") - if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil { - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } + if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"control-plane": "controller-manager"}.AsSelector(), 1, timeout); err != nil { + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } - utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml") + utils.Kubectl("", "apply", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml") - if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1, timeout); err != nil { - framework.Failf("unable to wait for all pods to be running and ready: %v", err) - } + if _, err := e2epod.WaitForPodsWithLabelRunningReady(f.ClientSet, ns, labels.Set{"app": "intel-iaa-plugin"}.AsSelector(), 1, timeout); err != nil { + framework.Failf("unable to wait for all pods to be running and ready: %v", err) + } - if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", timeout); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } + if err := utils.WaitForNodesWithResource(f.ClientSet, "iaa.intel.com/wq-user-dedicated", timeout); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } - utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml") + utils.Kubectl("", "delete", "-f", "deployments/operator/samples/deviceplugin_v1_iaadeviceplugin.yaml") - utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml") + utils.Kubectl("", "delete", "-k", "deployments/operator/default/kustomization.yaml") + }) }) } From 3286baadb56a7673bad79a43eb6eb683884d7cf5 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 7 Feb 2023 15:31:32 +0200 Subject: [PATCH 4/4] e2e, qat: divide single It() to have multiple layers Structure is as follows: Describe("QAT plugin") BeforeEach("deploys plugin") Context("When device resources are available") BeforeEach("checks if resources are available") It("runs a pod requesting resources") It("runs another pod requesting resources if there is") Signed-off-by: Hyeongju Johannes Lee --- test/e2e/qat/qatplugin_dpdk.go | 42 ++++++++++------- test/e2e/qat/qatplugin_kernel.go | 58 +++++++++++++----------- test/e2e/qat/qatplugin_qatgen4_crypto.go | 28 +++++++----- 3 files changed, 74 insertions(+), 54 deletions(-) diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 1be227f45..1c435efc9 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -57,7 +57,7 @@ func describeQatDpdkPlugin() { framework.Failf("unable to locate %q: %v", cryptoTestYaml, err) } - ginkgo.It("measures performance of DPDK", func() { + ginkgo.BeforeEach(func() { ginkgo.By("deploying QAT plugin in DPDK mode") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) @@ -74,22 +74,30 @@ func describeQatDpdkPlugin() { if err := utils.TestPodsFileSystemInfo(podList.Items); err != nil { framework.Failf("container filesystem info checks failed: %v", err) } + }) - ginkgo.By("checking if the resource is allocatable") - if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/generic", 30*time.Second); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } - - ginkgo.By("submitting a crypto pod requesting QAT resources") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestYamlPath)) - - ginkgo.By("waiting the crypto pod to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-crypto-perf-tc1", 60*time.Second) - - ginkgo.By("submitting a compress pod requesting QAT resources") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(compressTestYamlPath)) - - ginkgo.By("waiting the compress pod to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-compress-perf-tc1", 60*time.Second) + ginkgo.Context("When QAT resources are available", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("checking if the resource is allocatable") + if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/generic", 30*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %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", "-k", filepath.Dir(cryptoTestYamlPath)) + + ginkgo.By("waiting the crypto pod to finish successfully") + e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-crypto-perf-tc1", 60*time.Second) + }) + + ginkgo.It("deploys a compress pod requesting QAT resources", func() { + ginkgo.By("submitting a compress pod requesting QAT resources") + e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(compressTestYamlPath)) + + ginkgo.By("waiting the compress pod to finish successfully") + e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-compress-perf-tc1", 60*time.Second) + }) }) } diff --git a/test/e2e/qat/qatplugin_kernel.go b/test/e2e/qat/qatplugin_kernel.go index b1af6c821..1f1c86dd1 100644 --- a/test/e2e/qat/qatplugin_kernel.go +++ b/test/e2e/qat/qatplugin_kernel.go @@ -49,7 +49,7 @@ func describeQatKernelPlugin() { framework.Failf("unable to locate %q: %v", qatPluginKernelYaml, err) } - ginkgo.It("checks availability of QAT resources", func() { + ginkgo.BeforeEach(func() { ginkgo.By("deploying QAT plugin in kernel mode") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "-f", yamlPath) @@ -66,36 +66,42 @@ func describeQatKernelPlugin() { if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil { framework.Failf("container filesystem info checks failed: %v", err) } + }) - ginkgo.By("checking if the resource is allocatable") - if err = utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy1_dc0", 30*time.Second); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } + ginkgo.Context("When QAT resources are available", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("checking if the resource is allocatable") + if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy1_dc0", 30*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } + }) - ginkgo.By("submitting a pod requesting QAT resources") - podSpec := &v1.Pod{ - ObjectMeta: metav1.ObjectMeta{Name: "qatplugin-tester"}, - Spec: v1.PodSpec{ - Containers: []v1.Container{ - { - Args: []string{"-c", "echo mode"}, - Name: "testcontainer", - Image: imageutils.GetE2EImage(imageutils.BusyBox), - Command: []string{"/bin/sh"}, - Resources: v1.ResourceRequirements{ - Requests: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")}, - Limits: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")}, + ginkgo.It("deploys a pod requesting QAT resources", func() { + ginkgo.By("submitting a pod requesting QAT resources") + podSpec := &v1.Pod{ + ObjectMeta: metav1.ObjectMeta{Name: "qatplugin-tester"}, + Spec: v1.PodSpec{ + Containers: []v1.Container{ + { + Args: []string{"-c", "echo mode"}, + Name: "testcontainer", + Image: imageutils.GetE2EImage(imageutils.BusyBox), + Command: []string{"/bin/sh"}, + Resources: v1.ResourceRequirements{ + Requests: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")}, + Limits: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")}, + }, }, }, + RestartPolicy: v1.RestartPolicyNever, }, - RestartPolicy: v1.RestartPolicyNever, - }, - } - pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), - podSpec, metav1.CreateOptions{}) - framework.ExpectNoError(err, "pod Create API error") + } + pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(), + podSpec, metav1.CreateOptions{}) + framework.ExpectNoError(err, "pod Create API error") - ginkgo.By("waiting the pod to finish successfully") - e2epod.NewPodClient(f).WaitForFinish(pod.ObjectMeta.Name, 60*time.Second) + ginkgo.By("waiting the pod to finish successfully") + e2epod.NewPodClient(f).WaitForFinish(pod.ObjectMeta.Name, 60*time.Second) + }) }) } diff --git a/test/e2e/qat/qatplugin_qatgen4_crypto.go b/test/e2e/qat/qatplugin_qatgen4_crypto.go index 0d60a8395..cbe1b5937 100644 --- a/test/e2e/qat/qatplugin_qatgen4_crypto.go +++ b/test/e2e/qat/qatplugin_qatgen4_crypto.go @@ -51,7 +51,7 @@ func describeQatPluginCy() { framework.Failf("unable to locate %q: %v", opensslTestYaml, err) } - ginkgo.It("measures performance of QAT Cy Services", func() { + ginkgo.BeforeEach(func() { ginkgo.By("deploying QAT plugin in DPDK mode") e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath)) @@ -68,20 +68,26 @@ func describeQatPluginCy() { if err := utils.TestPodsFileSystemInfo(podList.Items); err != nil { framework.Failf("container filesystem info checks failed: %v", err) } + }) - ginkgo.By("checking if the resource is allocatable") - if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy", 30*time.Second); err != nil { - framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) - } + ginkgo.Context("When QAT4 resources are available", func() { + ginkgo.BeforeEach(func() { + ginkgo.By("checking if the resource is allocatable") + if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy", 30*time.Second); err != nil { + framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) + } + }) - ginkgo.By("submitting a crypto pod requesting QAT resources") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", opensslTestYamlPath) + 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) - ginkgo.By("waiting the crypto pod to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess("openssl-qat-engine", 300*time.Second) + ginkgo.By("waiting the crypto pod to finish successfully") + e2epod.NewPodClient(f).WaitForSuccess("openssl-qat-engine", 300*time.Second) - output, _ := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, "openssl-qat-engine", "openssl-qat-engine") + output, _ := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, "openssl-qat-engine", "openssl-qat-engine") - framework.Logf("cpa_sample_code output:\n %s", output) + framework.Logf("cpa_sample_code output:\n %s", output) + }) }) }