Skip to content

Commit 3286baa

Browse files
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 <[email protected]>
1 parent 77ad32e commit 3286baa

File tree

3 files changed

+74
-54
lines changed

3 files changed

+74
-54
lines changed

test/e2e/qat/qatplugin_dpdk.go

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ func describeQatDpdkPlugin() {
5757
framework.Failf("unable to locate %q: %v", cryptoTestYaml, err)
5858
}
5959

60-
ginkgo.It("measures performance of DPDK", func() {
60+
ginkgo.BeforeEach(func() {
6161
ginkgo.By("deploying QAT plugin in DPDK mode")
6262
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath))
6363

@@ -74,22 +74,30 @@ func describeQatDpdkPlugin() {
7474
if err := utils.TestPodsFileSystemInfo(podList.Items); err != nil {
7575
framework.Failf("container filesystem info checks failed: %v", err)
7676
}
77+
})
7778

78-
ginkgo.By("checking if the resource is allocatable")
79-
if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/generic", 30*time.Second); err != nil {
80-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
81-
}
82-
83-
ginkgo.By("submitting a crypto pod requesting QAT resources")
84-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestYamlPath))
85-
86-
ginkgo.By("waiting the crypto pod to finish successfully")
87-
e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-crypto-perf-tc1", 60*time.Second)
88-
89-
ginkgo.By("submitting a compress pod requesting QAT resources")
90-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(compressTestYamlPath))
91-
92-
ginkgo.By("waiting the compress pod to finish successfully")
93-
e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-compress-perf-tc1", 60*time.Second)
79+
ginkgo.Context("When QAT resources are available", func() {
80+
ginkgo.BeforeEach(func() {
81+
ginkgo.By("checking if the resource is allocatable")
82+
if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/generic", 30*time.Second); err != nil {
83+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
84+
}
85+
})
86+
87+
ginkgo.It("deploys a crypto pod requesting QAT resources", func() {
88+
ginkgo.By("submitting a crypto pod requesting QAT resources")
89+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestYamlPath))
90+
91+
ginkgo.By("waiting the crypto pod to finish successfully")
92+
e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-crypto-perf-tc1", 60*time.Second)
93+
})
94+
95+
ginkgo.It("deploys a compress pod requesting QAT resources", func() {
96+
ginkgo.By("submitting a compress pod requesting QAT resources")
97+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(compressTestYamlPath))
98+
99+
ginkgo.By("waiting the compress pod to finish successfully")
100+
e2epod.NewPodClient(f).WaitForSuccess("qat-dpdk-test-compress-perf-tc1", 60*time.Second)
101+
})
94102
})
95103
}

test/e2e/qat/qatplugin_kernel.go

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func describeQatKernelPlugin() {
4949
framework.Failf("unable to locate %q: %v", qatPluginKernelYaml, err)
5050
}
5151

52-
ginkgo.It("checks availability of QAT resources", func() {
52+
ginkgo.BeforeEach(func() {
5353
ginkgo.By("deploying QAT plugin in kernel mode")
5454
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "-f", yamlPath)
5555

@@ -66,36 +66,42 @@ func describeQatKernelPlugin() {
6666
if err = utils.TestPodsFileSystemInfo(podList.Items); err != nil {
6767
framework.Failf("container filesystem info checks failed: %v", err)
6868
}
69+
})
6970

70-
ginkgo.By("checking if the resource is allocatable")
71-
if err = utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy1_dc0", 30*time.Second); err != nil {
72-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
73-
}
71+
ginkgo.Context("When QAT resources are available", func() {
72+
ginkgo.BeforeEach(func() {
73+
ginkgo.By("checking if the resource is allocatable")
74+
if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy1_dc0", 30*time.Second); err != nil {
75+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
76+
}
77+
})
7478

75-
ginkgo.By("submitting a pod requesting QAT resources")
76-
podSpec := &v1.Pod{
77-
ObjectMeta: metav1.ObjectMeta{Name: "qatplugin-tester"},
78-
Spec: v1.PodSpec{
79-
Containers: []v1.Container{
80-
{
81-
Args: []string{"-c", "echo mode"},
82-
Name: "testcontainer",
83-
Image: imageutils.GetE2EImage(imageutils.BusyBox),
84-
Command: []string{"/bin/sh"},
85-
Resources: v1.ResourceRequirements{
86-
Requests: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")},
87-
Limits: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")},
79+
ginkgo.It("deploys a pod requesting QAT resources", func() {
80+
ginkgo.By("submitting a pod requesting QAT resources")
81+
podSpec := &v1.Pod{
82+
ObjectMeta: metav1.ObjectMeta{Name: "qatplugin-tester"},
83+
Spec: v1.PodSpec{
84+
Containers: []v1.Container{
85+
{
86+
Args: []string{"-c", "echo mode"},
87+
Name: "testcontainer",
88+
Image: imageutils.GetE2EImage(imageutils.BusyBox),
89+
Command: []string{"/bin/sh"},
90+
Resources: v1.ResourceRequirements{
91+
Requests: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")},
92+
Limits: v1.ResourceList{"qat.intel.com/cy1_dc0": resource.MustParse("1")},
93+
},
8894
},
8995
},
96+
RestartPolicy: v1.RestartPolicyNever,
9097
},
91-
RestartPolicy: v1.RestartPolicyNever,
92-
},
93-
}
94-
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(),
95-
podSpec, metav1.CreateOptions{})
96-
framework.ExpectNoError(err, "pod Create API error")
98+
}
99+
pod, err := f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(context.TODO(),
100+
podSpec, metav1.CreateOptions{})
101+
framework.ExpectNoError(err, "pod Create API error")
97102

98-
ginkgo.By("waiting the pod to finish successfully")
99-
e2epod.NewPodClient(f).WaitForFinish(pod.ObjectMeta.Name, 60*time.Second)
103+
ginkgo.By("waiting the pod to finish successfully")
104+
e2epod.NewPodClient(f).WaitForFinish(pod.ObjectMeta.Name, 60*time.Second)
105+
})
100106
})
101107
}

test/e2e/qat/qatplugin_qatgen4_crypto.go

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func describeQatPluginCy() {
5151
framework.Failf("unable to locate %q: %v", opensslTestYaml, err)
5252
}
5353

54-
ginkgo.It("measures performance of QAT Cy Services", func() {
54+
ginkgo.BeforeEach(func() {
5555
ginkgo.By("deploying QAT plugin in DPDK mode")
5656
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(kustomizationPath))
5757

@@ -68,20 +68,26 @@ func describeQatPluginCy() {
6868
if err := utils.TestPodsFileSystemInfo(podList.Items); err != nil {
6969
framework.Failf("container filesystem info checks failed: %v", err)
7070
}
71+
})
7172

72-
ginkgo.By("checking if the resource is allocatable")
73-
if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy", 30*time.Second); err != nil {
74-
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
75-
}
73+
ginkgo.Context("When QAT4 resources are available", func() {
74+
ginkgo.BeforeEach(func() {
75+
ginkgo.By("checking if the resource is allocatable")
76+
if err := utils.WaitForNodesWithResource(f.ClientSet, "qat.intel.com/cy", 30*time.Second); err != nil {
77+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
78+
}
79+
})
7680

77-
ginkgo.By("submitting a crypto pod requesting QAT resources")
78-
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", opensslTestYamlPath)
81+
ginkgo.It("deploys a crypto pod requesting QAT resources", func() {
82+
ginkgo.By("submitting a crypto pod requesting QAT resources")
83+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", opensslTestYamlPath)
7984

80-
ginkgo.By("waiting the crypto pod to finish successfully")
81-
e2epod.NewPodClient(f).WaitForSuccess("openssl-qat-engine", 300*time.Second)
85+
ginkgo.By("waiting the crypto pod to finish successfully")
86+
e2epod.NewPodClient(f).WaitForSuccess("openssl-qat-engine", 300*time.Second)
8287

83-
output, _ := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, "openssl-qat-engine", "openssl-qat-engine")
88+
output, _ := e2epod.GetPodLogs(f.ClientSet, f.Namespace.Name, "openssl-qat-engine", "openssl-qat-engine")
8489

85-
framework.Logf("cpa_sample_code output:\n %s", output)
90+
framework.Logf("cpa_sample_code output:\n %s", output)
91+
})
8692
})
8793
}

0 commit comments

Comments
 (0)