Skip to content

Commit d1875c4

Browse files
qat,e2e: add heartbeat and auto-reset validation
Signed-off-by: Hyeongju Johannes Lee <[email protected]>
1 parent 4ca9eb9 commit d1875c4

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

test/e2e/qat/qatplugin_dpdk.go

+58
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ package qat
1616

1717
import (
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

4347
const (
@@ -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+
5897
func describeQatDpdkPlugin() {
5998
f := framework.NewDefaultFramework("qatplugindpdk")
6099
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
@@ -101,6 +140,25 @@ 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+
}
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+
}
104162
})
105163

106164
ginkgo.AfterEach(func(ctx context.Context) {

0 commit comments

Comments
 (0)