@@ -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,36 @@ func init() {
5559 ginkgo .Describe ("QAT plugin in DPDK mode [Device:qat] [Mode:dpdk]" , describeQatDpdkPlugin )
5660}
5761
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+
5892func describeQatDpdkPlugin () {
5993 f := framework .NewDefaultFramework ("qatplugindpdk" )
6094 f .NamespacePodSecurityEnforceLevel = admissionapi .LevelPrivileged
@@ -101,6 +135,19 @@ func describeQatDpdkPlugin() {
101135 if err := utils .WaitForNodesWithResource (ctx , f .ClientSet , resourceName , 30 * time .Second , utils .WaitForPositiveResource ); err != nil {
102136 framework .Failf ("unable to wait for nodes to have positive allocatable resource: %v" , err )
103137 }
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+ }
104151 })
105152
106153 ginkgo .AfterEach (func (ctx context.Context ) {
0 commit comments