@@ -29,6 +29,7 @@ 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"
34
35
admissionapi "k8s.io/pod-security-admission/api"
@@ -38,6 +39,8 @@ const (
38
39
qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
39
40
cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
40
41
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"
41
44
)
42
45
43
46
const (
@@ -111,14 +114,14 @@ func describeQatDpdkPlugin() {
111
114
}
112
115
})
113
116
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 () {
115
118
// This BeforeEach runs even before the JustBeforeEach above.
116
119
ginkgo .BeforeEach (func () {
117
120
ginkgo .By ("creating a configMap before plugin gets deployed" )
118
121
e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=ServicesEnabled=sym;asym" , "qat-config" )
119
122
120
123
ginkgo .By ("setting resourceName for cy services" )
121
- resourceName = "qat.intel.com/cy"
124
+ resourceName = cyResource
122
125
})
123
126
124
127
ginkgo .It ("deploys a crypto pod (openssl) requesting QAT resources [App:openssl]" , func (ctx context.Context ) {
@@ -139,13 +142,13 @@ func describeQatDpdkPlugin() {
139
142
})
140
143
})
141
144
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 () {
143
146
ginkgo .BeforeEach (func () {
144
147
ginkgo .By ("creating a configMap before plugin gets deployed" )
145
148
e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=ServicesEnabled=dc" , "qat-config" )
146
149
147
150
ginkgo .By ("setting resourceName for dc services" )
148
- resourceName = "qat.intel.com/dc"
151
+ resourceName = dcResource
149
152
})
150
153
151
154
ginkgo .It ("deploys a compress pod (openssl) requesting QAT resources [App:openssl]" , func (ctx context.Context ) {
@@ -165,6 +168,54 @@ func describeQatDpdkPlugin() {
165
168
ginkgo .It ("does nothing" , func () {})
166
169
})
167
170
})
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\n AutoresetEnabled=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\n AutoresetEnabled=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
+ })
168
219
}
169
220
170
221
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,
199
250
err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
200
251
gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
201
252
}
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
+ }
0 commit comments