Skip to content

Commit

Permalink
cnf ran: adding CR reporting to powermanagement (#93)
Browse files Browse the repository at this point in the history
This also removes the PrivPodNamespace since it did not actually have any purpose over TestingNamespace.
  • Loading branch information
klaskosk authored Jul 15, 2024
1 parent ba904e7 commit 7b9d15e
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 13 deletions.
2 changes: 0 additions & 2 deletions tests/cnf/ran/powermanagement/internal/tsparams/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -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{}},
}
)
12 changes: 12 additions & 0 deletions tests/cnf/ran/powermanagement/powermanagement_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
})
12 changes: 1 addition & 11 deletions tests/cnf/ran/powermanagement/tests/powersave.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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")

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 7b9d15e

Please sign in to comment.