@@ -18,6 +18,7 @@ import (
1818 "context"
1919 "path/filepath"
2020 "strconv"
21+ "strings"
2122 "time"
2223
2324 "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils"
@@ -137,6 +138,10 @@ func describeQatDpdkPlugin() {
137138 ginkgo .When ("there is no app to run [App:noapp]" , func () {
138139 ginkgo .It ("does nothing" , func () {})
139140 })
141+
142+ ginkgo .It ("checks heartbeat detection and auto-reset functionalities [Functionality:auto-reset]" , func (ctx context.Context ) {
143+ checkAutoResetFunctionality (ctx , f , symmetric , resourceName )
144+ })
140145 })
141146
142147 ginkgo .Context ("When QAT resources are available with compress (dc) services enabled [Resource:dc]" , func () {
@@ -164,6 +169,10 @@ func describeQatDpdkPlugin() {
164169 ginkgo .When ("there is no app to run [App:noapp]" , func () {
165170 ginkgo .It ("does nothing" , func () {})
166171 })
172+
173+ ginkgo .It ("checks heartbeat detection and auto-reset functionalities [Functionality:auto-reset]" , func (ctx context.Context ) {
174+ checkAutoResetFunctionality (ctx , f , compression , resourceName )
175+ })
167176 })
168177}
169178
@@ -199,3 +208,72 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int,
199208 err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
200209 gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
201210}
211+
212+ func checkAutoResetFunctionality (ctx context.Context , f * framework.Framework , runTests int , resourceName v1.ResourceName ) {
213+ ginkgo .By ("checking if heartbeat status is read correctly" )
214+ setQatAutoReset ("off" , ctx , f )
215+ injectError (ctx , f )
216+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
217+ framework .Failf ("unable to wait for nodes to have zero resource: %v" , err )
218+ }
219+
220+ ginkgo .By ("checking if auto-reset works to solve injected errors" )
221+ setQatAutoReset ("on" , ctx , f )
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 deployed pod runs successfully" )
227+ runCpaSampleCode (ctx , f , runTests , resourceName )
228+ }
229+
230+ func setQatAutoReset (status string , ctx context.Context , f * framework.Framework ) {
231+ runQatAutoResetPod ([]string {"set_auto_reset" , status }, ctx , f )
232+ }
233+
234+ func injectError (ctx context.Context , f * framework.Framework ) {
235+ runQatAutoResetPod ([]string {"inject_error" }, ctx , f )
236+ }
237+
238+ func runQatAutoResetPod (command []string , ctx context.Context , f * framework.Framework ) {
239+ ginkgo .By ("submitting a pod that sets auto-reset function of QAT devices" )
240+ yes := true
241+ podSpec := & v1.Pod {
242+ ObjectMeta : metav1.ObjectMeta {Name : "qat-auto-reset-" + strings .ReplaceAll (strings .Join (command , "-" ), "_" , "-" )},
243+ Spec : v1.PodSpec {
244+ Containers : []v1.Container {
245+ {
246+ Name : "qat-auto-reset" ,
247+ Image : "intel/qat-auto-reset:devel" ,
248+ ImagePullPolicy : "IfNotPresent" ,
249+ Command : append ([]string {"qat-auto-reset-test.sh" }, command ... ),
250+ SecurityContext : & v1.SecurityContext {
251+ Privileged : & yes ,
252+ },
253+ VolumeMounts : []v1.VolumeMount {
254+ {
255+ Name : "debugfs" ,
256+ MountPath : "/sys/kernel/debug/" ,
257+ },
258+ },
259+ },
260+ },
261+ Volumes : []v1.Volume {
262+ {
263+ Name : "debugfs" ,
264+ VolumeSource : v1.VolumeSource {
265+ HostPath : & v1.HostPathVolumeSource {
266+ Path : "/sys/kernel/debug/" ,
267+ },
268+ },
269+ },
270+ },
271+ RestartPolicy : v1 .RestartPolicyNever ,
272+ },
273+ }
274+ pod , err := f .ClientSet .CoreV1 ().Pods (f .Namespace .Name ).Create (ctx , podSpec , metav1.CreateOptions {})
275+ framework .ExpectNoError (err , "pod Create API error" )
276+
277+ err = e2epod .WaitForPodSuccessInNamespaceTimeout (ctx , f .ClientSet , pod .ObjectMeta .Name , f .Namespace .Name , 300 * time .Second )
278+ gomega .Expect (err ).To (gomega .BeNil (), utils .GetPodLogs (ctx , f , pod .ObjectMeta .Name , pod .Spec .Containers [0 ].Name ))
279+ }
0 commit comments