Skip to content

Commit 53efaae

Browse files
authored
Merge pull request #1839 from hj-johannes-lee/PR-2024-007
qat,e2e: add heartbeat and auto-reset validation
2 parents 4f62bb8 + 7d3f3f3 commit 53efaae

File tree

3 files changed

+108
-5
lines changed

3 files changed

+108
-5
lines changed

.github/workflows/lib-e2e.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- accel-config-demo
2929
- intel-deviceplugin-operator
3030
- name: e2e-qat-gnrd
31-
targetjob: e2e-qat FOCUS="Mode:dpdk.*Resource:(cy|dc)" SKIP="App:(crypto-perf|compress-perf)"
31+
targetjob: e2e-qat FOCUS="Mode:dpdk" SKIP="(App:(crypto-perf|compress-perf)|Functionality)"
3232
runner: simics-gnrd
3333
images:
3434
- intel-qat-plugin

test/e2e/qat/qatplugin_dpdk.go

+91-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"k8s.io/apimachinery/pkg/labels"
3030
"k8s.io/kubernetes/test/e2e/framework"
3131
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
32+
e2ejob "k8s.io/kubernetes/test/e2e/framework/job"
3233
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
3334
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
3435
admissionapi "k8s.io/pod-security-admission/api"
@@ -38,6 +39,8 @@ const (
3839
qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
3940
cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
4041
compressTestYaml = "deployments/qat_dpdk_app/compress-perf/compress-perf-dpdk-pod-requesting-qat-dc.yaml"
42+
cyResource = "qat.intel.com/cy"
43+
dcResource = "qat.intel.com/dc"
4144
)
4245

4346
const (
@@ -111,14 +114,14 @@ func describeQatDpdkPlugin() {
111114
}
112115
})
113116

114-
ginkgo.Context("When QAT resources are available with crypto (cy) services enabled [Resource:cy]", func() {
117+
ginkgo.Context("When QAT resources are continuously available with crypto (cy) services enabled [Resource:cy]", func() {
115118
// This BeforeEach runs even before the JustBeforeEach above.
116119
ginkgo.BeforeEach(func() {
117120
ginkgo.By("creating a configMap before plugin gets deployed")
118121
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "--from-literal", "qat.conf=ServicesEnabled=sym;asym", "qat-config")
119122

120123
ginkgo.By("setting resourceName for cy services")
121-
resourceName = "qat.intel.com/cy"
124+
resourceName = cyResource
122125
})
123126

124127
ginkgo.It("deploys a crypto pod (openssl) requesting QAT resources [App:openssl]", func(ctx context.Context) {
@@ -139,13 +142,13 @@ func describeQatDpdkPlugin() {
139142
})
140143
})
141144

142-
ginkgo.Context("When QAT resources are available with compress (dc) services enabled [Resource:dc]", func() {
145+
ginkgo.Context("When QAT resources are continuously available with compress (dc) services enabled [Resource:dc]", func() {
143146
ginkgo.BeforeEach(func() {
144147
ginkgo.By("creating a configMap before plugin gets deployed")
145148
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "--from-literal", "qat.conf=ServicesEnabled=dc", "qat-config")
146149

147150
ginkgo.By("setting resourceName for dc services")
148-
resourceName = "qat.intel.com/dc"
151+
resourceName = dcResource
149152
})
150153

151154
ginkgo.It("deploys a compress pod (openssl) requesting QAT resources [App:openssl]", func(ctx context.Context) {
@@ -165,6 +168,54 @@ func describeQatDpdkPlugin() {
165168
ginkgo.It("does nothing", func() {})
166169
})
167170
})
171+
172+
ginkgo.Context("When a QAT device goes unresponsive", func() {
173+
ginkgo.When("QAT's auto-reset is off", func() {
174+
ginkgo.BeforeEach(func() {
175+
ginkgo.By("creating a configMap before plugin gets deployed")
176+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "--from-literal", "qat.conf=$'ServiceEnabled=dc\nAutoresetEnabled=off", "qat-config")
177+
178+
ginkgo.By("setting resourceName for dc services")
179+
resourceName = dcResource
180+
})
181+
182+
ginkgo.It("checks if unhealthy status is reported [Functionality:heartbeat]", func(ctx context.Context) {
183+
injectError(ctx, f, resourceName)
184+
185+
ginkgo.By("waiting node resources become zero")
186+
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 30*time.Second, utils.WaitForZeroResource); err != nil {
187+
framework.Failf("unable to wait for nodes to have no resource: %v", err)
188+
}
189+
})
190+
})
191+
192+
ginkgo.When("QAT's autoreset is on", func() {
193+
ginkgo.BeforeEach(func() {
194+
ginkgo.By("creating a configMap before plugin gets deployed")
195+
e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "create", "configmap", "--from-literal", "qat.conf=$'ServiceEnabled=dc\nAutoresetEnabled=on", "qat-config")
196+
197+
ginkgo.By("setting resourceName for dc services")
198+
resourceName = dcResource
199+
})
200+
201+
ginkgo.It("checks if an injected error gets solved [Functionality:auto-reset]", func(ctx context.Context) {
202+
injectError(ctx, f, resourceName)
203+
204+
ginkgo.By("seeing if there is zero resource")
205+
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 30*time.Second, utils.WaitForZeroResource); err != nil {
206+
framework.Failf("unable to wait for nodes to have no resource: %v", err)
207+
}
208+
209+
ginkgo.By("seeing if there is positive allocatable resource")
210+
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 300*time.Second, utils.WaitForPositiveResource); err != nil {
211+
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
212+
}
213+
214+
ginkgo.By("checking if openssl pod runs successfully")
215+
runCpaSampleCode(ctx, f, compression, resourceName)
216+
})
217+
})
218+
})
168219
}
169220

170221
func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int, resourceName v1.ResourceName) {
@@ -199,3 +250,39 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int,
199250
err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, pod.ObjectMeta.Name, f.Namespace.Name, 300*time.Second)
200251
gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, pod.ObjectMeta.Name, pod.Spec.Containers[0].Name))
201252
}
253+
254+
func injectError(ctx context.Context, f *framework.Framework, resourceName v1.ResourceName) {
255+
nodeName, _ := utils.FindNodeAndResourceCapacity(f, ctx, resourceName.String())
256+
if nodeName == "" {
257+
framework.Failf("failed to find a node that has the resource: %s", resourceName)
258+
}
259+
yes := true
260+
261+
job := e2ejob.NewTestJobOnNode("success", "qat-inject-error", v1.RestartPolicyNever, 1, 1, nil, 0, nodeName)
262+
job.Spec.Template.Spec.Containers[0].Command = []string{
263+
"/bin/sh",
264+
"-c",
265+
"find /sys/kernel/debug/qat_*/heartbeat/ -name inject_error -exec sh -c 'echo 1 > {}' \\;",
266+
}
267+
job.Spec.Template.Spec.Containers[0].VolumeMounts = []v1.VolumeMount{{
268+
Name: "debugfs",
269+
MountPath: "/sys/kernel/debug/",
270+
}}
271+
job.Spec.Template.Spec.Volumes = []v1.Volume{{
272+
Name: "debugfs",
273+
VolumeSource: v1.VolumeSource{
274+
HostPath: &v1.HostPathVolumeSource{
275+
Path: "/sys/kernel/debug/",
276+
},
277+
},
278+
}}
279+
job.Spec.Template.Spec.Containers[0].SecurityContext = &v1.SecurityContext{
280+
Privileged: &yes,
281+
}
282+
283+
job, err := e2ejob.CreateJob(ctx, f.ClientSet, f.Namespace.Name, job)
284+
framework.ExpectNoError(err, "failed to create job in namespace: %s", f.Namespace.Name)
285+
286+
err = e2ejob.WaitForJobComplete(ctx, f.ClientSet, f.Namespace.Name, job.Name, nil, 1)
287+
framework.ExpectNoError(err, "failed to ensure job completion in namespace: %s", f.Namespace.Name)
288+
}

test/e2e/utils/utils.go

+16
Original file line numberDiff line numberDiff line change
@@ -365,3 +365,19 @@ func Kubectl(ns string, cmd string, opt string, file string) {
365365
msg := e2ekubectl.RunKubectlOrDie(ns, cmd, opt, path)
366366
framework.Logf("%s", msg)
367367
}
368+
369+
func FindNodeAndResourceCapacity(f *framework.Framework, ctx context.Context, resourceName string) (string, int64) {
370+
nodelist, err := f.ClientSet.CoreV1().Nodes().List(ctx, metav1.ListOptions{})
371+
if err != nil {
372+
framework.Failf("failed to list Nodes: %v", err)
373+
}
374+
375+
// we have at least one node with resource capacity
376+
for _, item := range nodelist.Items {
377+
if q, ok := item.Status.Allocatable[v1.ResourceName(resourceName)]; ok && q.Value() > 0 {
378+
return item.Name, q.Value()
379+
}
380+
}
381+
382+
return "", 0
383+
}

0 commit comments

Comments
 (0)