Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: make demo pod logged only when failed running #1470

Merged
merged 4 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions test/e2e/dlb/dlb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -45,9 +46,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)
hj-johannes-lee marked this conversation as resolved.
Show resolved Hide resolved
}

var dpPodName string
Expand Down Expand Up @@ -108,9 +109,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))
Expand All @@ -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))
}
31 changes: 12 additions & 19 deletions test/e2e/dsa/dsa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,19 +47,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
Expand Down Expand Up @@ -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))
})
})
})
Expand Down
23 changes: 11 additions & 12 deletions test/e2e/fpga/fpga.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -50,14 +51,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")
Expand Down Expand Up @@ -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)
}

Expand All @@ -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")

Expand Down
7 changes: 4 additions & 3 deletions test/e2e/gpu/gpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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")
}

Expand Down
31 changes: 12 additions & 19 deletions test/e2e/iaa/iaa.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,19 +47,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
Expand Down Expand Up @@ -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))
})
})
})
Expand Down
48 changes: 24 additions & 24 deletions test/e2e/qat/qatplugin_dpdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand All @@ -59,24 +61,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
Expand Down Expand Up @@ -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"))
})
})

Expand Down Expand Up @@ -169,15 +167,19 @@ 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) {
ginkgo.By("submitting a compress pod requesting QAT resources")
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))
})
})
}
Expand Down Expand Up @@ -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))
}
6 changes: 3 additions & 3 deletions test/e2e/qat/qatplugin_kernel.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading