@@ -16,6 +16,8 @@ package qat
16
16
17
17
import (
18
18
"context"
19
+ "fmt"
20
+ "os"
19
21
"path/filepath"
20
22
"strconv"
21
23
"time"
@@ -38,6 +40,8 @@ const (
38
40
qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
39
41
cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
40
42
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"
41
45
)
42
46
43
47
const (
@@ -55,6 +59,41 @@ func init() {
55
59
ginkgo .Describe ("QAT plugin in DPDK mode [Device:qat] [Mode:dpdk]" , describeQatDpdkPlugin )
56
60
}
57
61
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
+
58
97
func describeQatDpdkPlugin () {
59
98
f := framework .NewDefaultFramework ("qatplugindpdk" )
60
99
f .NamespacePodSecurityEnforceLevel = admissionapi .LevelPrivileged
@@ -101,6 +140,25 @@ func describeQatDpdkPlugin() {
101
140
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102
141
framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
103
142
}
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
+ }
148
+ if err := injectError (); err != nil {
149
+ framework .Logf ("unable to test error injection in this system: %v" , err )
150
+ }
151
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
152
+ framework .Failf ("unable to wait for nodes to have zero resource: %v" , err )
153
+ }
154
+
155
+ ginkgo .By ("checking if auto_reset works to solve the errors" )
156
+ if err := setQatAutoReset ("on" ); err != nil {
157
+ framework .Logf ("unable to set auto reset in this system: %v" , err )
158
+ }
159
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForPositiveResource ); err != nil {
160
+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
161
+ }
104
162
})
105
163
106
164
ginkgo .AfterEach (func (ctx context.Context ) {
0 commit comments