From 3286baadb56a7673bad79a43eb6eb683884d7cf5 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 7 Feb 2023 15:31:32 +0200 Subject: [PATCH] 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 | 34 ++++++++------ test/e2e/qat/qatplugin_kernel.go | 58 +++++++++++++----------- test/e2e/qat/qatplugin_qatgen4_crypto.go | 28 +++++++----- 3 files changed, 70 insertions(+), 50 deletions(-) diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 1be227f4..1c435efc 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.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.By("submitting a crypto pod requesting QAT resources") - e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestYamlPath)) + 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.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.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) + 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 b1af6c82..1f1c86dd 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 0d60a839..cbe1b593 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) + }) }) }