@@ -16,6 +16,8 @@ package qat
1616
1717import (
1818 "context"
19+ "fmt"
20+ "os"
1921 "path/filepath"
2022 "strconv"
2123 "time"
@@ -38,6 +40,8 @@ const (
3840 qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
3941 cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
4042 compressTestYaml = "deployments/qat_dpdk_app/compress-perf/compress-perf-dpdk-pod-requesting-qat-dc.yaml"
43+ autoResetPattern = "/sys/bus/pci/drivers/*/*/qat/auto_reset"
44+ injectErrorPattern = "/sys/kernel/debug/qat_*/heartbeat/inject_error"
4145)
4246
4347const (
@@ -55,6 +59,41 @@ func init() {
5559 ginkgo .Describe ("QAT plugin in DPDK mode [Device:qat] [Mode:dpdk]" , describeQatDpdkPlugin )
5660}
5761
62+ func setQatAutoReset (cfgVal string ) error {
63+ matches , err := filepath .Glob (autoResetPattern )
64+ if err != nil {
65+ return err
66+ }
67+
68+ for _ , filePath := range matches {
69+ err = os .WriteFile (filePath , []byte (cfgVal ), 0600 )
70+ if err != nil {
71+ return err
72+ }
73+ }
74+ return nil
75+ }
76+
77+ func injectError () error {
78+ matches , err := filepath .Glob (injectErrorPattern )
79+ if err != nil {
80+ return err
81+ }
82+
83+ for _ , filePath := range matches {
84+ file , err := os .OpenFile (filePath , os .O_WRONLY | os .O_TRUNC , 0600 )
85+ if err != nil {
86+ return err
87+ }
88+ defer file .Close ()
89+
90+ os .Stdout = file
91+ fmt .Println ("1" )
92+ }
93+
94+ return nil
95+ }
96+
5897func describeQatDpdkPlugin () {
5998 f := framework .NewDefaultFramework ("qatplugindpdk" )
6099 f .NamespacePodSecurityEnforceLevel = admissionapi .LevelPrivileged
@@ -101,6 +140,28 @@ func describeQatDpdkPlugin() {
101140 if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102141 framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
103142 }
143+
144+ ginkgo .By ("checking if injected errors are recognized" )
145+ if err := setQatAutoReset ("off" ); err != nil {
146+ framework .Logf ("unable to set auto reset in this system: %v" , err )
147+ return
148+ }
149+ if err := injectError (); err != nil {
150+ framework .Logf ("unable to test error injection in this system: %v" , err )
151+ return
152+ }
153+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
154+ framework .Failf ("unable to wait for nodes to have zero resource: %v" , err )
155+ }
156+
157+ ginkgo .By ("checking if auto_reset works to solve the errors" )
158+ if err := setQatAutoReset ("on" ); err != nil {
159+ framework .Logf ("unable to set auto reset in this system: %v" , err )
160+ return
161+ }
162+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForPositiveResource ); err != nil {
163+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
164+ }
104165 })
105166
106167 ginkgo .AfterEach (func (ctx context.Context ) {
0 commit comments