diff --git a/tests/cnf/ran/powermanagement/internal/tsparams/consts.go b/tests/cnf/ran/powermanagement/internal/tsparams/consts.go index d3c524b03..a9799382c 100644 --- a/tests/cnf/ran/powermanagement/internal/tsparams/consts.go +++ b/tests/cnf/ran/powermanagement/internal/tsparams/consts.go @@ -17,8 +17,6 @@ const ( PowerSaveTimeout = 10 * time.Minute // TestingNamespace is the tests namespace. TestingNamespace = "ran-test" - // PrivPodNamespace is the privileged pod namespace. - PrivPodNamespace = "cnf-ran-gotests-priv" // PowerSavingMode is the name of the power saving power state. PowerSavingMode = "powersaving" diff --git a/tests/cnf/ran/powermanagement/internal/tsparams/powermanagementvars.go b/tests/cnf/ran/powermanagement/internal/tsparams/powermanagementvars.go index a65f090cc..d45147272 100644 --- a/tests/cnf/ran/powermanagement/internal/tsparams/powermanagementvars.go +++ b/tests/cnf/ran/powermanagement/internal/tsparams/powermanagementvars.go @@ -1,10 +1,27 @@ package tsparams import ( + . "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/raninittools" "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/ranparam" + "github.com/openshift-kni/k8sreporter" + performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2" + corev1 "k8s.io/api/core/v1" ) var ( // Labels represents the range of labels that can be used for test cases selection. Labels = append(ranparam.Labels, LabelSuite) + + // ReporterNamespacesToDump tells to the reporter which namespaces to collect pod logs from. + ReporterNamespacesToDump = map[string]string{ + TestingNamespace: "", + RANConfig.MCONamespace: "", + } + + // ReporterCRsToDump is the CRs the reporter should dump. + ReporterCRsToDump = []k8sreporter.CRData{ + {Cr: &corev1.PodList{}}, + {Cr: &corev1.NamespaceList{}}, + {Cr: &performancev2.PerformanceProfileList{}}, + } ) diff --git a/tests/cnf/ran/powermanagement/powermanagement_suite_test.go b/tests/cnf/ran/powermanagement/powermanagement_suite_test.go index f936595e9..620b47c0b 100644 --- a/tests/cnf/ran/powermanagement/powermanagement_suite_test.go +++ b/tests/cnf/ran/powermanagement/powermanagement_suite_test.go @@ -7,11 +7,14 @@ import ( "github.com/golang/glog" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/openshift-kni/eco-goinfra/pkg/clients" "github.com/openshift-kni/eco-goinfra/pkg/namespace" + "github.com/openshift-kni/eco-goinfra/pkg/reportxml" . "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/raninittools" "github.com/openshift-kni/eco-gotests/tests/cnf/ran/internal/ranparam" "github.com/openshift-kni/eco-gotests/tests/cnf/ran/powermanagement/internal/tsparams" _ "github.com/openshift-kni/eco-gotests/tests/cnf/ran/powermanagement/tests" + "github.com/openshift-kni/eco-gotests/tests/internal/reporter" ) var _, currentFile, _, _ = runtime.Caller(0) @@ -45,3 +48,12 @@ var _ = AfterSuite(func() { Expect(err).ToNot(HaveOccurred(), "Failed to delete namespace ", tsparams.TestingNamespace) }) + +var _ = JustAfterEach(func() { + reporter.ReportIfFailed( + CurrentSpecReport(), currentFile, tsparams.ReporterNamespacesToDump, tsparams.ReporterCRsToDump, clients.SetScheme) +}) + +var _ = ReportAfterSuite("", func(report Report) { + reportxml.Create(report, RANConfig.GetReportPath(), RANConfig.TCPrefix) +}) diff --git a/tests/cnf/ran/powermanagement/tests/powersave.go b/tests/cnf/ran/powermanagement/tests/powersave.go index a87a71440..20566c98e 100644 --- a/tests/cnf/ran/powermanagement/tests/powersave.go +++ b/tests/cnf/ran/powermanagement/tests/powersave.go @@ -11,7 +11,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" "github.com/openshift-kni/eco-goinfra/pkg/mco" - "github.com/openshift-kni/eco-goinfra/pkg/namespace" "github.com/openshift-kni/eco-goinfra/pkg/nodes" "github.com/openshift-kni/eco-goinfra/pkg/nto" //nolint:misspell "github.com/openshift-kni/eco-goinfra/pkg/reportxml" @@ -46,18 +45,9 @@ var _ = Describe("Per-core runtime power states tuning", Label(tsparams.LabelPow Expect(err).ToNot(HaveOccurred(), "Failed to get performance profile") originalPerfProfileSpec = perfProfile.Object.Spec - - By("Creating the privileged pod namespace") - _, err = namespace.NewBuilder(Spoke1APIClient, tsparams.PrivPodNamespace).Create() - Expect(err).ToNot(HaveOccurred(), "Failed to create the privileged pod namespace") }) AfterAll(func() { - By("Deleting the privileged pod namespace") - err = namespace.NewBuilder(Spoke1APIClient, tsparams.PrivPodNamespace). - DeleteAndWait(tsparams.PowerSaveTimeout) - Expect(err).ToNot(HaveOccurred(), "Failed to delete priv pod namespace") - perfProfile, err = helper.GetPerformanceProfileWithCPUSet() Expect(err).ToNot(HaveOccurred(), "Failed to get performance profile") @@ -143,7 +133,7 @@ var _ = Describe("Per-core runtime power states tuning", Label(tsparams.LabelPow By("Define test pod") testpod, err := helper.DefineQoSTestPod( - tsparams.PrivPodNamespace, nodeName, cpuLimit.String(), cpuLimit.String(), memLimit.String(), memLimit.String()) + tsparams.TestingNamespace, nodeName, cpuLimit.String(), cpuLimit.String(), memLimit.String(), memLimit.String()) Expect(err).ToNot(HaveOccurred(), "Failed to define test pod") testpod.Definition.Annotations = testPodAnnotations