@@ -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 (
@@ -77,6 +80,7 @@ func describeQatDpdkPlugin() {
77
80
var dpPodName string
78
81
79
82
var resourceName v1.ResourceName
83
+ var nodeName string
80
84
81
85
ginkgo .JustBeforeEach (func (ctx context.Context ) {
82
86
ginkgo .By ("deploying QAT plugin in DPDK mode" )
@@ -97,6 +101,18 @@ func describeQatDpdkPlugin() {
97
101
framework .Failf ("container filesystem info checks failed: %v" , err )
98
102
}
99
103
104
+ // when running [Functionality] e2e tests
105
+ if resourceName == "" {
106
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , cyResource , 100 * time .Second , utils .WaitForPositiveResource ); err != nil {
107
+ resourceName = dcResource
108
+ nodeName , _ = utils .FindNodeAndResourceCapacity (f , ctx , dcResource )
109
+ return
110
+ }
111
+ resourceName = cyResource
112
+ nodeName , _ = utils .FindNodeAndResourceCapacity (f , ctx , cyResource )
113
+ return
114
+ }
115
+
100
116
ginkgo .By ("checking if the resource is allocatable" )
101
117
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102
118
framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
@@ -111,14 +127,14 @@ func describeQatDpdkPlugin() {
111
127
}
112
128
})
113
129
114
- ginkgo .Context ("When QAT resources are available with crypto (cy) services enabled [Resource:cy]" , func () {
130
+ ginkgo .Context ("When QAT resources are continuously available with crypto (cy) services enabled [Resource:cy]" , func () {
115
131
// This BeforeEach runs even before the JustBeforeEach above.
116
132
ginkgo .BeforeEach (func () {
117
133
ginkgo .By ("creating a configMap before plugin gets deployed" )
118
134
e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=ServicesEnabled=sym;asym" , "qat-config" )
119
135
120
136
ginkgo .By ("setting resourceName for cy services" )
121
- resourceName = "qat.intel.com/cy"
137
+ resourceName = cyResource
122
138
})
123
139
124
140
ginkgo .It ("deploys a crypto pod (openssl) requesting QAT resources [App:openssl]" , func (ctx context.Context ) {
@@ -139,13 +155,13 @@ func describeQatDpdkPlugin() {
139
155
})
140
156
})
141
157
142
- ginkgo .Context ("When QAT resources are available with compress (dc) services enabled [Resource:dc]" , func () {
158
+ ginkgo .Context ("When QAT resources are continuously available with compress (dc) services enabled [Resource:dc]" , func () {
143
159
ginkgo .BeforeEach (func () {
144
160
ginkgo .By ("creating a configMap before plugin gets deployed" )
145
161
e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=ServicesEnabled=dc" , "qat-config" )
146
162
147
163
ginkgo .By ("setting resourceName for dc services" )
148
- resourceName = "qat.intel.com/dc"
164
+ resourceName = dcResource
149
165
})
150
166
151
167
ginkgo .It ("deploys a compress pod (openssl) requesting QAT resources [App:openssl]" , func (ctx context.Context ) {
@@ -165,6 +181,57 @@ func describeQatDpdkPlugin() {
165
181
ginkgo .It ("does nothing" , func () {})
166
182
})
167
183
})
184
+
185
+ ginkgo .Context ("When a QAT device goes unresponsive" , func () {
186
+ ginkgo .When ("QAT's auto-reset is off" , 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 [Functionality:heartbeat]" , 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 .When ("QAT's autoreset is on" , 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 [Functionality:auto-reset]" , 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
+ framework .Logf ("unable to wait for nodes to have no resource: %v" , err )
214
+ // It should not be Failf since there can be a case auto-reset worked before plugin notices.
215
+ // It is still necessary to have utils.WaitForNodeWithResource for WaitForZeroResource
216
+ // because there can be also a case that the following part that checks WaitForPositiveResource may run
217
+ // before the injected error is recognized by plugin when this part does not exist.
218
+ // In other words, this is necessary to ensure that the injected error does not remain after this It() spec.
219
+ }
220
+
221
+ ginkgo .By ("seeing if there is positive allocatable resource" )
222
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 300 * time .Second , utils .WaitForPositiveResource ); err != nil {
223
+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
224
+ }
225
+
226
+ ginkgo .By ("checking if openssl pod runs successfully" )
227
+ if resourceName == cyResource {
228
+ runCpaSampleCode (ctx , f , symmetric , resourceName )
229
+ } else {
230
+ runCpaSampleCode (ctx , f , compression , resourceName )
231
+ }
232
+ })
233
+ })
234
+ })
168
235
}
169
236
170
237
func runCpaSampleCode (ctx context.Context , f * framework.Framework , runTests int , resourceName v1.ResourceName ) {
@@ -199,3 +266,35 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int,
199
266
err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
200
267
gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
201
268
}
269
+
270
+ func injectError (ctx context.Context , f * framework.Framework , nodeName string ) {
271
+ job := e2ejob .NewTestJobOnNode ("success" , "qat-inject-error" , v1 .RestartPolicyNever , 1 , 1 , nil , 0 , nodeName )
272
+
273
+ job .Spec .Template .Spec .Containers [0 ].Command = []string {
274
+ "/bin/sh" ,
275
+ "-c" ,
276
+ "find /sys/kernel/debug/qat_*/heartbeat/ -name inject_error -exec sh -c 'echo 1 > {}' \\ ;" ,
277
+ }
278
+ job .Spec .Template .Spec .Containers [0 ].VolumeMounts = []v1.VolumeMount {{
279
+ Name : "debugfs" ,
280
+ MountPath : "/sys/kernel/debug/" ,
281
+ }}
282
+ job .Spec .Template .Spec .Volumes = []v1.Volume {{
283
+ Name : "debugfs" ,
284
+ VolumeSource : v1.VolumeSource {
285
+ HostPath : & v1.HostPathVolumeSource {
286
+ Path : "/sys/kernel/debug/" ,
287
+ },
288
+ },
289
+ }}
290
+ yes := true
291
+ job .Spec .Template .Spec .Containers [0 ].SecurityContext = & v1.SecurityContext {
292
+ Privileged : & yes ,
293
+ }
294
+
295
+ job , err := e2ejob .CreateJob (ctx , f .ClientSet , f .Namespace .Name , job )
296
+ framework .ExpectNoError (err , "failed to create job in namespace: %s" , f .Namespace .Name )
297
+
298
+ err = e2ejob .WaitForJobComplete (ctx , f .ClientSet , f .Namespace .Name , job .Name , nil , 1 )
299
+ framework .ExpectNoError (err , "failed to ensure job completion in namespace: %s" , f .Namespace .Name )
300
+ }
0 commit comments