Skip to content

Commit

Permalink
qat,e2e: add heartbeat and auto-reset validation
Browse files Browse the repository at this point in the history
Signed-off-by: Hyeongju Johannes Lee <[email protected]>
  • Loading branch information
hj-johannes-lee authored and root committed Sep 17, 2024
1 parent 4ca9eb9 commit 208171e
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions test/e2e/qat/qatplugin_dpdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ package qat

import (
"context"
"fmt"
"os"
"path/filepath"
"strconv"
"time"
Expand All @@ -38,6 +40,8 @@ const (
qatPluginKustomizationYaml = "deployments/qat_plugin/overlays/e2e/kustomization.yaml"
cryptoTestYaml = "deployments/qat_dpdk_app/crypto-perf/crypto-perf-dpdk-pod-requesting-qat-cy.yaml"
compressTestYaml = "deployments/qat_dpdk_app/compress-perf/compress-perf-dpdk-pod-requesting-qat-dc.yaml"
autoResetPattern = "/sys/bus/pci/drivers/*/*/qat/auto_reset"
injectErrorPattern = "/sys/kernel/debug/qat_*/heartbeat/inject_error"
)

const (
Expand All @@ -55,6 +59,36 @@ func init() {
ginkgo.Describe("QAT plugin in DPDK mode [Device:qat] [Mode:dpdk]", describeQatDpdkPlugin)
}

func setQatAutoReset(cfgVal string) {
matches, err := filepath.Glob(autoResetPattern)
if err != nil {

Check failure on line 64 in test/e2e/qat/qatplugin_dpdk.go

View workflow job for this annotation

GitHub Actions / validate / lint

SA9003: empty branch (staticcheck)
}

for _, filePath := range matches {
err = os.WriteFile(filePath, []byte(cfgVal), 0644)

Check failure on line 68 in test/e2e/qat/qatplugin_dpdk.go

View workflow job for this annotation

GitHub Actions / validate / lint

G306: Expect WriteFile permissions to be 0600 or less (gosec)
if err != nil {

Check failure on line 69 in test/e2e/qat/qatplugin_dpdk.go

View workflow job for this annotation

GitHub Actions / validate / lint

SA9003: empty branch (staticcheck)
}
}

}

Check failure on line 73 in test/e2e/qat/qatplugin_dpdk.go

View workflow job for this annotation

GitHub Actions / validate / lint

unnecessary trailing newline (whitespace)

func injectError() {
matches, err := filepath.Glob(injectErrorPattern)
if err != nil {

Check failure on line 77 in test/e2e/qat/qatplugin_dpdk.go

View workflow job for this annotation

GitHub Actions / validate / lint

SA9003: empty branch (staticcheck)
}

for _, filePath := range matches {
file, err := os.OpenFile(filePath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
}
defer file.Close()

// 표준 출력을 파일로 리다이렉트
os.Stdout = file
fmt.Println("1") // 이 출력은 파일에 쓰임
}
}

func describeQatDpdkPlugin() {
f := framework.NewDefaultFramework("qatplugindpdk")
f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged
Expand Down Expand Up @@ -101,6 +135,19 @@ func describeQatDpdkPlugin() {
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 30*time.Second, utils.WaitForPositiveResource); err != nil {
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
}

ginkgo.By("checking if injected errors are recognized")
setQatAutoReset("off")
injectError()
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 100*time.Second, utils.WaitForZeroResource); err != nil {
framework.Failf("unable to wait for nodes to have zero resource: %v", err)
}

ginkgo.By("checking if auto_reset works to solve the errors")
setQatAutoReset("on")
if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, resourceName, 100*time.Second, utils.WaitForPositiveResource); err != nil {
framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err)
}
})

ginkgo.AfterEach(func(ctx context.Context) {
Expand Down

0 comments on commit 208171e

Please sign in to comment.