@@ -29,15 +29,19 @@ import (
29
29
"k8s.io/apimachinery/pkg/labels"
30
30
"k8s.io/kubernetes/test/e2e/framework"
31
31
e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
32
+ e2ejob "k8s.io/kubernetes/test/e2e/framework/job"
32
33
e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
33
34
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
35
+ imageutils "k8s.io/kubernetes/test/utils/image"
34
36
admissionapi "k8s.io/pod-security-admission/api"
35
37
)
36
38
37
39
const (
38
40
qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
39
41
cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
40
42
compressTestYaml = "deployments/qat_dpdk_app/compress-perf/compress-perf-dpdk-pod-requesting-qat-dc.yaml"
43
+ cy = "qat.intel.com/cy"
44
+ dc = "qat.intel.com/dc"
41
45
)
42
46
43
47
const (
@@ -77,6 +81,7 @@ func describeQatDpdkPlugin() {
77
81
var dpPodName string
78
82
79
83
var resourceName v1.ResourceName
84
+ var nodeName string
80
85
81
86
ginkgo .JustBeforeEach (func (ctx context.Context ) {
82
87
ginkgo .By ("deploying QAT plugin in DPDK mode" )
@@ -97,6 +102,18 @@ func describeQatDpdkPlugin() {
97
102
framework .Failf ("container filesystem info checks failed: %v" , err )
98
103
}
99
104
105
+ // when running [Functionality] e2e tests
106
+ if resourceName == "" {
107
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , cy , 100 * time .Second , utils .WaitForPositiveResource ); err != nil {
108
+ resourceName = dc
109
+ nodeName , _ = utils .FindNodeAndResourceCapacity (f , ctx , dc )
110
+ return
111
+ }
112
+ resourceName = cy
113
+ nodeName , _ = utils .FindNodeAndResourceCapacity (f , ctx , cy )
114
+ return
115
+ }
116
+
100
117
ginkgo .By ("checking if the resource is allocatable" )
101
118
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102
119
framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
@@ -165,6 +182,52 @@ func describeQatDpdkPlugin() {
165
182
ginkgo .It ("does nothing" , func () {})
166
183
})
167
184
})
185
+
186
+ ginkgo .Context ("When QAT's autoreset is off [Functionality:heartbeat]" , func () {
187
+ ginkgo .BeforeEach (func () {
188
+ ginkgo .By ("creating a configMap before plugin gets deployed" )
189
+ e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=AutoresetEnabled=off" , "qat-config" )
190
+ })
191
+
192
+ ginkgo .It ("checks if the heartbeat is read correctly" , func (ctx context.Context ) {
193
+ injectError (ctx , f , nodeName )
194
+
195
+ ginkgo .By ("seeing if there is zero resource" )
196
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
197
+ framework .Failf ("unable to wait for nodes to have no resource: %v" , err )
198
+ }
199
+ })
200
+ })
201
+
202
+ ginkgo .Context ("When QAT's autoreset is on [Functionality:auto-reset]" , func () {
203
+ ginkgo .BeforeEach (func () {
204
+ ginkgo .By ("creating a configMap before plugin gets deployed" )
205
+ e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=AutoresetEnabled=on" , "qat-config" )
206
+ })
207
+
208
+ ginkgo .It ("checks if an injected error gets solved" , func (ctx context.Context ) {
209
+ injectError (ctx , f , nodeName )
210
+
211
+ ginkgo .By ("seeing if there is zero resource" )
212
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
213
+ // It should not fail since there can be a case auto-reset function worked before plugin notices.
214
+ // It is still useful to wait for some time to ensure that injected error affects other specs.
215
+ framework .Logf ("unable to wait for nodes to have no resource: %v" , err )
216
+ }
217
+
218
+ ginkgo .By ("seeing if there is positive allocatable resource" )
219
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 300 * time .Second , utils .WaitForPositiveResource ); err != nil {
220
+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
221
+ }
222
+
223
+ ginkgo .By ("checking if openssl pod runs successfully" )
224
+ if resourceName == cy {
225
+ runCpaSampleCode (ctx , f , symmetric , resourceName )
226
+ } else {
227
+ runCpaSampleCode (ctx , f , compression , resourceName )
228
+ }
229
+ })
230
+ })
168
231
}
169
232
170
233
func runCpaSampleCode (ctx context.Context , f * framework.Framework , runTests int , resourceName v1.ResourceName ) {
@@ -199,3 +262,36 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int,
199
262
err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
200
263
gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
201
264
}
265
+
266
+ func injectError (ctx context.Context , f * framework.Framework , nodeName string ) {
267
+ job := e2ejob .NewTestJobOnNode ("success" , "qat-inject-error" , v1 .RestartPolicyNever , 1 , 1 , nil , 0 , nodeName )
268
+
269
+ job .Spec .Template .Spec .Containers [0 ].Image = imageutils .GetE2EImage (imageutils .BusyBox )
270
+ job .Spec .Template .Spec .Containers [0 ].Command = []string {
271
+ "/bin/sh" ,
272
+ "-c" ,
273
+ "find /sys/kernel/debug/qat_*/heartbeat/ -name inject_error -exec sh -c 'echo 1 > {}' \\ ;" ,
274
+ }
275
+ job .Spec .Template .Spec .Containers [0 ].VolumeMounts = []v1.VolumeMount {{
276
+ Name : "debugfs" ,
277
+ MountPath : "/sys/kernel/debug/" ,
278
+ }}
279
+ job .Spec .Template .Spec .Volumes = []v1.Volume {{
280
+ Name : "debugfs" ,
281
+ VolumeSource : v1.VolumeSource {
282
+ HostPath : & v1.HostPathVolumeSource {
283
+ Path : "/sys/kernel/debug/" ,
284
+ },
285
+ },
286
+ }}
287
+ yes := true
288
+ job .Spec .Template .Spec .Containers [0 ].SecurityContext = & v1.SecurityContext {
289
+ Privileged : & yes ,
290
+ }
291
+
292
+ job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
293
+ framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
294
+
295
+ err = e2ejob .WaitForJobComplete (ctx , f .ClientSet , f .Namespace .Name , job .Name , nil , 1 )
296
+ framework .ExpectNoError (err , "failed to ensure job completion in namespace: %s" , f .Namespace .Name )
297
+ }
0 commit comments