@@ -31,6 +31,7 @@ import (
3131 e2edebug "k8s.io/kubernetes/test/e2e/framework/debug"
3232 e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl"
3333 e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
34+ imageutils "k8s.io/kubernetes/test/utils/image"
3435 admissionapi "k8s.io/pod-security-admission/api"
3536)
3637
@@ -165,6 +166,34 @@ func describeQatDpdkPlugin() {
165166 ginkgo .It ("does nothing" , func () {})
166167 })
167168 })
169+
170+ ginkgo .Context ("When QAT's autoreset is on [Functionality:auto-reset]" , func () {
171+ ginkgo .BeforeEach (func () {
172+ ginkgo .By ("creating a configMap before plugin gets deployed" )
173+ e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=AutoresetEnabled=on" , "qat-config" )
174+ })
175+
176+ ginkgo .It ("checks if an injected error gets solved" , func (ctx context.Context ) {
177+ injectError (ctx , f )
178+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 300 * time .Second , utils .WaitForPositiveResource ); err != nil {
179+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
180+ }
181+ })
182+ })
183+
184+ ginkgo .Context ("When QAT's autoreset is off [Functionality:auto-reset]" , func () {
185+ ginkgo .BeforeEach (func () {
186+ ginkgo .By ("creating a configMap before plugin gets deployed" )
187+ e2ekubectl .RunKubectlOrDie (f .Namespace .Name , "create" , "configmap" , "--from-literal" , "qat.conf=AutoresetEnabled=off" , "qat-config" )
188+ })
189+
190+ ginkgo .It ("checks if the heartbeat is read correctly" , func (ctx context.Context ) {
191+ injectError (ctx , f )
192+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
193+ framework .Failf ("unable to wait for nodes to have zero resource: %v" , err )
194+ }
195+ })
196+ })
168197}
169198
170199func runCpaSampleCode (ctx context.Context , f * framework.Framework , runTests int , resourceName v1.ResourceName ) {
@@ -199,3 +228,45 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int,
199228 err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
200229 gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
201230}
231+
232+ func injectError (ctx context.Context , f * framework.Framework ) {
233+ yes := true
234+ podSpec := & v1.Pod {
235+ ObjectMeta : metav1.ObjectMeta {Name : "qat-inject-error" },
236+ Spec : v1.PodSpec {
237+ Containers : []v1.Container {
238+ {
239+ Name : "qat-inject-error" ,
240+ Image : imageutils .GetE2EImage (imageutils .BusyBox ),
241+ ImagePullPolicy : "IfNotPresent" ,
242+ Command : []string {"find" , "/sys/kernel/debug/qat_*/heartbeat/" , "-name" , "inject_error" , "-exec" , "sh" , "-c" , "'echo 1 > {}'" , "\\ ;" },
243+ SecurityContext : & v1.SecurityContext {
244+ Privileged : & yes ,
245+ },
246+ VolumeMounts : []v1.VolumeMount {
247+ {
248+ Name : "debugfs" ,
249+ MountPath : "/sys/kernel/debug/" ,
250+ },
251+ },
252+ },
253+ },
254+ Volumes : []v1.Volume {
255+ {
256+ Name : "debugfs" ,
257+ VolumeSource : v1.VolumeSource {
258+ HostPath : & v1.HostPathVolumeSource {
259+ Path : "/sys/kernel/debug/" ,
260+ },
261+ },
262+ },
263+ },
264+ RestartPolicy : v1 .RestartPolicyNever ,
265+ },
266+ }
267+ pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (ctx , podSpec , metav1.CreateOptions {})
268+ framework .ExpectNoError (err , "pod Create API error" )
269+
270+ err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
271+ gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
272+ }
0 commit comments