From 00c666ac57587841319bf6e339d3273dca1c2825 Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Mon, 7 Aug 2023 14:43:10 +0300 Subject: [PATCH 1/4] e2e: rename err to errFailedToLocateRepoFile to prevent linter error when err is declared and any parts below that declare again, linter complains as follows: shadow: declaration of err shadows declaration at line 51 so, we name the first declaration as errFailedToLocateRepoFile so that other 'err's do not need to be named all in different names or can be declared as 'err' without linter error. Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dlb/dlb.go | 12 ++++++------ test/e2e/dsa/dsa.go | 18 +++++++++--------- test/e2e/fpga/fpga.go | 12 ++++++------ test/e2e/gpu/gpu.go | 6 +++--- test/e2e/iaa/iaa.go | 18 +++++++++--------- test/e2e/qat/qatplugin_dpdk.go | 24 ++++++++++++------------ test/e2e/qat/qatplugin_kernel.go | 6 +++--- test/e2e/sgx/sgx.go | 24 ++++++++++++------------ 8 files changed, 60 insertions(+), 60 deletions(-) diff --git a/test/e2e/dlb/dlb.go b/test/e2e/dlb/dlb.go index a4479a4a9..d5bf66f18 100644 --- a/test/e2e/dlb/dlb.go +++ b/test/e2e/dlb/dlb.go @@ -45,9 +45,9 @@ func describe() { f := framework.NewDefaultFramework("dlbplugin") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - kustomizationPath, err := utils.LocateRepoFile(kustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationYaml, err) + kustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationYaml, errFailedToLocateRepoFile) } var dpPodName string @@ -108,9 +108,9 @@ func describe() { } func runDemoApp(ctx context.Context, function, yaml string, f *framework.Framework) { - demoPath, err := utils.LocateRepoFile(yaml) - if err != nil { - framework.Failf("unable to locate %q: %v", yaml, err) + demoPath, errFailedToLocateRepoFile := utils.LocateRepoFile(yaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", yaml, errFailedToLocateRepoFile) } podName := strings.TrimSuffix(filepath.Base(yaml), filepath.Ext(yaml)) diff --git a/test/e2e/dsa/dsa.go b/test/e2e/dsa/dsa.go index a6598c1c2..35c307b3d 100644 --- a/test/e2e/dsa/dsa.go +++ b/test/e2e/dsa/dsa.go @@ -46,19 +46,19 @@ func describe() { f := framework.NewDefaultFramework("dsaplugin") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - kustomizationPath, err := utils.LocateRepoFile(kustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationYaml, err) + kustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationYaml, errFailedToLocateRepoFile) } - configmap, err := utils.LocateRepoFile(configmapYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", configmapYaml, err) + configmap, errFailedToLocateRepoFile := utils.LocateRepoFile(configmapYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", configmapYaml, errFailedToLocateRepoFile) } - demoPath, err := utils.LocateRepoFile(demoYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", demoYaml, err) + demoPath, errFailedToLocateRepoFile := utils.LocateRepoFile(demoYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", demoYaml, errFailedToLocateRepoFile) } var dpPodName string diff --git a/test/e2e/fpga/fpga.go b/test/e2e/fpga/fpga.go index 18917eb45..0728bc841 100644 --- a/test/e2e/fpga/fpga.go +++ b/test/e2e/fpga/fpga.go @@ -50,14 +50,14 @@ func init() { } func describe() { - pluginKustomizationPath, err := utils.LocateRepoFile(pluginKustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", pluginKustomizationYaml, err) + pluginKustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(pluginKustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", pluginKustomizationYaml, errFailedToLocateRepoFile) } - mappingsCollectionPath, err := utils.LocateRepoFile(mappingsCollectionYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", mappingsCollectionYaml, err) + mappingsCollectionPath, errFailedToLocateRepoFile := utils.LocateRepoFile(mappingsCollectionYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", mappingsCollectionYaml, errFailedToLocateRepoFile) } fmw := framework.NewDefaultFramework("fpgaplugin-e2e") diff --git a/test/e2e/gpu/gpu.go b/test/e2e/gpu/gpu.go index d4c5aba3b..5c8be57fe 100644 --- a/test/e2e/gpu/gpu.go +++ b/test/e2e/gpu/gpu.go @@ -47,9 +47,9 @@ func describe() { f := framework.NewDefaultFramework("gpuplugin") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - kustomizationPath, err := utils.LocateRepoFile(kustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationYaml, err) + kustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationYaml, errFailedToLocateRepoFile) } ginkgo.It("checks availability of GPU resources", func(ctx context.Context) { diff --git a/test/e2e/iaa/iaa.go b/test/e2e/iaa/iaa.go index a52233940..809081acf 100644 --- a/test/e2e/iaa/iaa.go +++ b/test/e2e/iaa/iaa.go @@ -46,19 +46,19 @@ func describe() { f := framework.NewDefaultFramework("iaaplugin") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - kustomizationPath, err := utils.LocateRepoFile(kustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationYaml, err) + kustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationYaml, errFailedToLocateRepoFile) } - configmap, err := utils.LocateRepoFile(configmapYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", configmapYaml, err) + configmap, errFailedToLocateRepoFile := utils.LocateRepoFile(configmapYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", configmapYaml, errFailedToLocateRepoFile) } - demoPath, err := utils.LocateRepoFile(demoYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", demoYaml, err) + demoPath, errFailedToLocateRepoFile := utils.LocateRepoFile(demoYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", demoYaml, errFailedToLocateRepoFile) } var dpPodName string diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 1a23179ff..3b713fed2 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -59,24 +59,24 @@ func describeQatDpdkPlugin() { f := framework.NewDefaultFramework("qatplugindpdk") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - kustomizationPath, err := utils.LocateRepoFile(qatPluginKustomizationYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", qatPluginKustomizationYaml, err) + kustomizationPath, errFailedToLocateRepoFile := utils.LocateRepoFile(qatPluginKustomizationYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", qatPluginKustomizationYaml, errFailedToLocateRepoFile) } - compressTestYamlPath, err := utils.LocateRepoFile(compressTestYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", compressTestYaml, err) + compressTestYamlPath, errFailedToLocateRepoFile := utils.LocateRepoFile(compressTestYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", compressTestYaml, errFailedToLocateRepoFile) } - cryptoTestYamlPath, err := utils.LocateRepoFile(cryptoTestYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", cryptoTestYaml, err) + cryptoTestYamlPath, errFailedToLocateRepoFile := utils.LocateRepoFile(cryptoTestYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", cryptoTestYaml, errFailedToLocateRepoFile) } - cryptoTestGen4YamlPath, err := utils.LocateRepoFile(cryptoTestGen4Yaml) - if err != nil { - framework.Failf("unable to locate %q: %v", cryptoTestGen4Yaml, err) + cryptoTestGen4YamlPath, errFailedToLocateRepoFile := utils.LocateRepoFile(cryptoTestGen4Yaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", cryptoTestGen4Yaml, errFailedToLocateRepoFile) } var dpPodName string diff --git a/test/e2e/qat/qatplugin_kernel.go b/test/e2e/qat/qatplugin_kernel.go index 227a6980e..042389d53 100644 --- a/test/e2e/qat/qatplugin_kernel.go +++ b/test/e2e/qat/qatplugin_kernel.go @@ -44,9 +44,9 @@ func describeQatKernelPlugin() { f := framework.NewDefaultFramework("qatpluginkernel") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - yamlPath, err := utils.LocateRepoFile(qatPluginKernelYaml) - if err != nil { - framework.Failf("unable to locate %q: %v", qatPluginKernelYaml, err) + yamlPath, errFailedToLocateRepoFile := utils.LocateRepoFile(qatPluginKernelYaml) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", qatPluginKernelYaml, errFailedToLocateRepoFile) } var dpPodName string diff --git a/test/e2e/sgx/sgx.go b/test/e2e/sgx/sgx.go index 50f10c597..5c6744ab0 100644 --- a/test/e2e/sgx/sgx.go +++ b/test/e2e/sgx/sgx.go @@ -47,14 +47,14 @@ func describe() { f := framework.NewDefaultFramework("sgxplugin") f.NamespacePodSecurityEnforceLevel = admissionapi.LevelPrivileged - deploymentWebhookPath, err := utils.LocateRepoFile(kustomizationWebhook) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationWebhook, err) + deploymentWebhookPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationWebhook) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationWebhook, errFailedToLocateRepoFile) } - deploymentPluginPath, err := utils.LocateRepoFile(kustomizationPlugin) - if err != nil { - framework.Failf("unable to locate %q: %v", kustomizationPlugin, err) + deploymentPluginPath, errFailedToLocateRepoFile := utils.LocateRepoFile(kustomizationPlugin) + if errFailedToLocateRepoFile != nil { + framework.Failf("unable to locate %q: %v", kustomizationPlugin, errFailedToLocateRepoFile) } ginkgo.BeforeEach(func(ctx context.Context) { @@ -64,12 +64,12 @@ func describe() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(deploymentPluginPath)) ginkgo.By("waiting for SGX plugin's availability") - podList, errPodNotRunning := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, f.Namespace.Name, + podList, err := e2epod.WaitForPodsWithLabelRunningReady(ctx, f.ClientSet, f.Namespace.Name, labels.Set{"app": "intel-sgx-plugin"}.AsSelector(), 1 /* one replica */, 100*time.Second) - if errPodNotRunning != nil { + if err != nil { e2edebug.DumpAllNamespaceInfo(ctx, f.ClientSet, f.Namespace.Name) e2ekubectl.LogFailedContainers(ctx, f.ClientSet, f.Namespace.Name, framework.Logf) - framework.Failf("unable to wait for all pods to be running and ready: %v", errPodNotRunning) + framework.Failf("unable to wait for all pods to be running and ready: %v", err) } ginkgo.By("checking SGX plugin's securityContext") @@ -81,13 +81,13 @@ func describe() { ginkgo.Context("When SGX resources are available", func() { ginkgo.BeforeEach(func(ctx context.Context) { ginkgo.By("checking if the resource is allocatable") - if err = utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/epc", 150*time.Second); err != nil { + if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/epc", 150*time.Second); err != nil { framework.Failf("unable to wait for nodes to have positive allocatable epc resource: %v", err) } - if err = utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/enclave", 30*time.Second); err != nil { + if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/enclave", 30*time.Second); err != nil { framework.Failf("unable to wait for nodes to have positive allocatable enclave resource: %v", err) } - if err = utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/provision", 30*time.Second); err != nil { + if err := utils.WaitForNodesWithResource(ctx, f.ClientSet, "sgx.intel.com/provision", 30*time.Second); err != nil { framework.Failf("unable to wait for nodes to have positive allocatable provision resource: %v", err) } }) From 4b26ead3ac0ffd51b56198d1cedcd70b26eeccd2 Mon Sep 17 00:00:00 2001 From: hj-johannes-lee Date: Fri, 28 Jul 2023 23:16:45 +0300 Subject: [PATCH 2/4] e2e: add func utils.GetFormattedErrorAndLog for logging failed pod Signed-off-by: Hyeongju Johannes Lee --- test/e2e/utils/utils.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/e2e/utils/utils.go b/test/e2e/utils/utils.go index 86f88e668..c44c36ce3 100644 --- a/test/e2e/utils/utils.go +++ b/test/e2e/utils/utils.go @@ -17,6 +17,7 @@ package utils import ( "context" + "fmt" "io" "os" "path/filepath" @@ -41,6 +42,16 @@ const ( poll = time.Second ) +// GetPodLogs returns the log of the container. If not possible to get logs, it returns the error message. +func GetPodLogs(ctx context.Context, f *framework.Framework, podName, containerName string) string { + log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, podName, containerName) + if err != nil { + return fmt.Sprintf("unable to get log from pod: %v", err) + } + + return fmt.Sprintf("log output of the container %s in the pod %s:%s", containerName, podName, log) +} + // WaitForNodesWithResource waits for nodes to have positive allocatable resource. func WaitForNodesWithResource(ctx context.Context, c clientset.Interface, res v1.ResourceName, timeout time.Duration) error { framework.Logf("Waiting up to %s for any positive allocatable resource %q", timeout, res) From 32c7c370ef7b9583f3bbb8a82d70c78e33bd8f0c Mon Sep 17 00:00:00 2001 From: Hyeongju Johannes Lee Date: Tue, 11 Jul 2023 00:04:55 +0300 Subject: [PATCH 3/4] e2e: use utils.GetFormattedErrorAndLog for logging demo pods this makes a demo pod's log get printed only when the pod did not run sucessfully Signed-off-by: Hyeongju Johannes Lee --- test/e2e/dlb/dlb.go | 13 +++---------- test/e2e/dsa/dsa.go | 13 +++---------- test/e2e/fpga/fpga.go | 11 +++++------ test/e2e/iaa/iaa.go | 13 +++---------- test/e2e/qat/qatplugin_dpdk.go | 24 ++++++++++++------------ test/e2e/sgx/sgx.go | 5 +++-- 6 files changed, 29 insertions(+), 50 deletions(-) diff --git a/test/e2e/dlb/dlb.go b/test/e2e/dlb/dlb.go index d5bf66f18..811db1738 100644 --- a/test/e2e/dlb/dlb.go +++ b/test/e2e/dlb/dlb.go @@ -22,6 +22,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/kubernetes/test/e2e/framework" @@ -119,15 +120,7 @@ func runDemoApp(ctx context.Context, function, yaml string, f *framework.Framewo e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) ginkgo.By("waiting for the DLB demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(ctx, podName, 200*time.Second) - ginkgo.By("getting workload log") - - log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, podName, podName) - - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } - - framework.Logf("log output: %s", log) + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, podName, f.Namespace.Name, 200*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, podName, podName)) } diff --git a/test/e2e/dsa/dsa.go b/test/e2e/dsa/dsa.go index 35c307b3d..c0d750066 100644 --- a/test/e2e/dsa/dsa.go +++ b/test/e2e/dsa/dsa.go @@ -21,6 +21,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/labels" "k8s.io/kubernetes/test/e2e/framework" e2edebug "k8s.io/kubernetes/test/e2e/framework/debug" @@ -106,16 +107,8 @@ func describe() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) ginkgo.By("waiting for the DSA demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(ctx, podName, 200*time.Second) - - ginkgo.By("getting workload log") - log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, podName, podName) - - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } - - framework.Logf("log output: %s", log) + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, podName, f.Namespace.Name, 200*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, podName, podName)) }) }) }) diff --git a/test/e2e/fpga/fpga.go b/test/e2e/fpga/fpga.go index 0728bc841..c02aee4d6 100644 --- a/test/e2e/fpga/fpga.go +++ b/test/e2e/fpga/fpga.go @@ -24,6 +24,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -97,7 +98,7 @@ func runTestCase(ctx context.Context, fmw *framework.Framework, pluginKustomizat ginkgo.By("checking if the resource is allocatable") - if err := utils.WaitForNodesWithResource(ctx, fmw.ClientSet, resource, 30*time.Second); err != nil { + if err = utils.WaitForNodesWithResource(ctx, fmw.ClientSet, resource, 30*time.Second); err != nil { framework.Failf("unable to wait for nodes to have positive allocatable resource: %v", err) } @@ -109,11 +110,9 @@ func runTestCase(ctx context.Context, fmw *framework.Framework, pluginKustomizat pod := createPod(ctx, fmw, fmt.Sprintf("fpgaplugin-%s-%s-%s-correct", pluginMode, cmd1, cmd2), resource, image, []string{cmd1, "-S0"}) ginkgo.By("waiting the pod to finish successfully") - e2epod.NewPodClient(fmw).WaitForSuccess(ctx, pod.ObjectMeta.Name, 60*time.Second) - // If WaitForSuccess fails, ginkgo doesn't show the logs of the failed container. - // Replacing WaitForSuccess with WaitForFinish + 'kubelet logs' would show the logs - //fmw.PodClient().WaitForFinish(pod.ObjectMeta.Name, 60*time.Second) - //framework.RunKubectlOrDie(fmw.Namespace.Name, "logs", pod.ObjectMeta.Name) + + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, fmw.ClientSet, pod.ObjectMeta.Name, fmw.Namespace.Name, 60*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, fmw, pod.ObjectMeta.Name, "testcontainer")) ginkgo.By("submitting a pod requesting incorrect FPGA resources") diff --git a/test/e2e/iaa/iaa.go b/test/e2e/iaa/iaa.go index 809081acf..9d498c2ee 100644 --- a/test/e2e/iaa/iaa.go +++ b/test/e2e/iaa/iaa.go @@ -21,6 +21,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" "k8s.io/apimachinery/pkg/labels" "k8s.io/kubernetes/test/e2e/framework" e2edebug "k8s.io/kubernetes/test/e2e/framework/debug" @@ -106,16 +107,8 @@ func describe() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-f", demoPath) ginkgo.By("waiting for the IAA demo to succeed") - e2epod.NewPodClient(f).WaitForSuccess(ctx, podName, 300*time.Second) - - ginkgo.By("getting workload log") - log, err := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, podName, podName) - - if err != nil { - framework.Failf("unable to get log from pod: %v", err) - } - - framework.Logf("log output: %s", log) + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, podName, f.Namespace.Name, 300*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, podName, podName)) }) }) }) diff --git a/test/e2e/qat/qatplugin_dpdk.go b/test/e2e/qat/qatplugin_dpdk.go index 3b713fed2..d6c86d96a 100644 --- a/test/e2e/qat/qatplugin_dpdk.go +++ b/test/e2e/qat/qatplugin_dpdk.go @@ -22,6 +22,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -38,6 +39,7 @@ const ( compressTestYaml = "deployments/qat_dpdk_app/test-compress1/kustomization.yaml" cryptoTestYaml = "deployments/qat_dpdk_app/test-crypto1/kustomization.yaml" cryptoTestGen4Yaml = "deployments/qat_dpdk_app/test-crypto1-gen4/kustomization.yaml" + demoPodContainerName = "crypto-perf" ) const ( @@ -135,12 +137,8 @@ func describeQatDpdkPlugin() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestGen4YamlPath)) ginkgo.By("waiting the crypto pod to finish successfully") - - e2epod.NewPodClient(f).WaitForSuccess(ctx, "qat-dpdk-test-crypto-perf-tc1-gen4", 300*time.Second) - - output, _ := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, "qat-dpdk-test-crypto-perf-tc1-gen4", "crypto-perf") - - framework.Logf("crypto-perf output:\n %s", output) + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, "qat-dpdk-test-crypto-perf-tc1-gen4", f.Namespace.Name, 300*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, "qat-dpdk-test-crypto-perf-tc1-gen4", "crypto-perf")) }) }) @@ -169,7 +167,9 @@ func describeQatDpdkPlugin() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(cryptoTestYamlPath)) ginkgo.By("waiting the crypto pod to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess(ctx, "qat-dpdk-test-crypto-perf-tc1", 60*time.Second) + demoPodName := "qat-dpdk-test-crypto-perf-tc1" + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, demoPodName, f.Namespace.Name, 60*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, demoPodName, demoPodContainerName)) }) ginkgo.It("deploys a compress pod requesting QAT resources", func(ctx context.Context) { @@ -177,7 +177,9 @@ func describeQatDpdkPlugin() { e2ekubectl.RunKubectlOrDie(f.Namespace.Name, "apply", "-k", filepath.Dir(compressTestYamlPath)) ginkgo.By("waiting the compress pod to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess(ctx, "qat-dpdk-test-compress-perf-tc1", 60*time.Second) + demoPodName := "qat-dpdk-test-compress-perf-tc1" + err := e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, demoPodName, f.Namespace.Name, 60*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, demoPodName, demoPodContainerName)) }) }) } @@ -210,9 +212,7 @@ func runCpaSampleCode(ctx context.Context, f *framework.Framework, runTests int, framework.ExpectNoError(err, "pod Create API error") ginkgo.By("waiting the cpa_sample_code pod for the resource" + resourceName.String() + "to finish successfully") - e2epod.NewPodClient(f).WaitForSuccess(ctx, pod.ObjectMeta.Name, 300*time.Second) - - output, _ := e2epod.GetPodLogs(ctx, f.ClientSet, f.Namespace.Name, pod.ObjectMeta.Name, pod.Spec.Containers[0].Name) - framework.Logf("cpa_sample_code output:\n %s", output) + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, pod.ObjectMeta.Name, f.Namespace.Name, 300*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, pod.ObjectMeta.Name, pod.Spec.Containers[0].Name)) } diff --git a/test/e2e/sgx/sgx.go b/test/e2e/sgx/sgx.go index 5c6744ab0..b7245ba59 100644 --- a/test/e2e/sgx/sgx.go +++ b/test/e2e/sgx/sgx.go @@ -21,6 +21,7 @@ import ( "github.com/intel/intel-device-plugins-for-kubernetes/test/e2e/utils" "github.com/onsi/ginkgo/v2" + "github.com/onsi/gomega" v1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -115,8 +116,8 @@ func describe() { framework.ExpectNoError(err, "pod Create API error") ginkgo.By("waiting the pod to finish successfully") - - e2epod.NewPodClient(f).WaitForSuccess(ctx, pod.ObjectMeta.Name, 60*time.Second) + err = e2epod.WaitForPodSuccessInNamespaceTimeout(ctx, f.ClientSet, pod.ObjectMeta.Name, f.Namespace.Name, 60*time.Second) + gomega.Expect(err).To(gomega.BeNil(), utils.GetPodLogs(ctx, f, pod.ObjectMeta.Name, "testcontainer")) }) }) From 42a735bf0d5a5fa3aa46bd81a6db7720532a1e34 Mon Sep 17 00:00:00 2001 From: hj-johannes-lee Date: Wed, 2 Aug 2023 17:10:13 +0300 Subject: [PATCH 4/4] e2e,gpu: add log printing when device mounts not found in a demo pod Signed-off-by: Hyeongju Johannes Lee --- test/e2e/gpu/gpu.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/e2e/gpu/gpu.go b/test/e2e/gpu/gpu.go index 5c8be57fe..6225f7230 100644 --- a/test/e2e/gpu/gpu.go +++ b/test/e2e/gpu/gpu.go @@ -108,6 +108,7 @@ func describe() { } if !strings.Contains(log, "card") || !strings.Contains(log, "renderD") { + framework.Logf("log output: %s", log) framework.Failf("device mounts not found from log") }