@@ -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,36 @@ 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 ) {
63
+ matches , err := filepath .Glob (autoResetPattern )
64
+ if err != nil {
65
+ }
66
+
67
+ for _ , filePath := range matches {
68
+ err = os .WriteFile (filePath , []byte (cfgVal ), 0644 )
69
+ if err != nil {
70
+ }
71
+ }
72
+
73
+ }
74
+
75
+ func injectError () {
76
+ matches , err := filepath .Glob (injectErrorPattern )
77
+ if err != nil {
78
+ }
79
+
80
+ for _ , filePath := range matches {
81
+ file , err := os .OpenFile (filePath , os .O_WRONLY | os .O_CREATE | os .O_TRUNC , 0644 )
82
+ if err != nil {
83
+ }
84
+ defer file .Close ()
85
+
86
+ // 표준 출력을 파일로 리다이렉트
87
+ os .Stdout = file
88
+ fmt .Println ("1" ) // 이 출력은 파일에 쓰임
89
+ }
90
+ }
91
+
58
92
func describeQatDpdkPlugin () {
59
93
f := framework .NewDefaultFramework ("qatplugindpdk" )
60
94
f .NamespacePodSecurityEnforceLevel = admissionapi .LevelPrivileged
@@ -101,6 +135,19 @@ func describeQatDpdkPlugin() {
101
135
if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102
136
framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
103
137
}
138
+
139
+ ginkgo .By ("checking if injected errors are recognized" )
140
+ setQatAutoReset ("off" )
141
+ injectError ()
142
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForZeroResource ); err != nil {
143
+ framework .Failf ("unable to wait for nodes to have zero resource: %v" , err )
144
+ }
145
+
146
+ ginkgo .By ("checking if auto_reset works to solve the errors" )
147
+ setQatAutoReset ("on" )
148
+ if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 100 * time .Second , utils .WaitForPositiveResource ); err != nil {
149
+ framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
150
+ }
104
151
})
105
152
106
153
ginkgo .AfterEach (func (ctx context.Context ) {
0 commit comments