From 208171e53506248b59404148edd68cdca194fc3b Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 17 Sep 2024 04:18:18 -0700 Subject: [PATCH] qat,e2e: add heartbeat and auto-reset validation Signed-off-by: Hyeongju Johannes Lee --- test/e2e/qat/qatplugin_dpdk.go | 47 ++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 8d513041c..ac98f282e 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -16,6 +16,8 @@ package qat import ( "context" + "fmt" + "os" "path/filepath" "strconv" "time" @@ -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 ( @@ -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 { + } + + for _, filePath := range matches { + err = os.WriteFile(filePath, []byte(cfgVal), 0644) + if err != nil { + } + } + +} + +func injectError() { + matches, err := filepath.Glob(injectErrorPattern) + if err != nil { + } + + 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 @@ -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) {