Skip to content

Commit

Permalink
Merge pull request #53 from shaior/fix_powersave
Browse files Browse the repository at this point in the history
Fixed stability of powersave test
  • Loading branch information
mcornea authored Jan 25, 2024
2 parents 1f31f6b + 999fb71 commit b86fdd3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/openshift-kni/eco-goinfra/pkg/pod"
"github.com/openshift-kni/eco-gosystem/tests/internal/cmd"
"github.com/openshift-kni/eco-gosystem/tests/internal/config"
mcov1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"

"github.com/openshift-kni/eco-gosystem/tests/internal/inittools"
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/internal/ranfuncinittools"
Expand Down Expand Up @@ -185,8 +186,10 @@ func RedefineContainerResources(
return pod
}

// SetPowerMode updates the performance profile with the given workload hints, and waits for the mcp update.
func SetPowerMode(perfProfile *nto.Builder, perPodPowerManagement, highPowerConsumption, realTime bool) error {
// SetPowerModeAndWaitForMcpUpdate updates the performance profile with the given workload hints,
// and waits for the mcp update.
func SetPowerModeAndWaitForMcpUpdate(perfProfile *nto.Builder, node nodes.Builder, perPodPowerManagement,
highPowerConsumption, realTime bool) error {
glog.V(100).Infof("Set powersave mode on performance profile")

perfProfile.Definition.Spec.WorkloadHints = &performancev2.WorkloadHints{
Expand All @@ -203,7 +206,14 @@ func SetPowerMode(perfProfile *nto.Builder, perPodPowerManagement, highPowerCons
mcp, err := mco.Pull(ranfuncinittools.HubAPIClient, "master")
Expect(err).ToNot(HaveOccurred())

err = mcp.WaitForUpdate(powermanagementparams.Timeout)
err = mcp.WaitToBeInCondition(mcov1.MachineConfigPoolUpdating, corev1.ConditionTrue, 15*time.Minute)
Expect(err).ToNot(HaveOccurred())

err = mcp.WaitToBeInCondition(mcov1.MachineConfigPoolUpdated, corev1.ConditionTrue, 25*time.Minute)
Expect(err).ToNot(HaveOccurred())

err = node.WaitUntilReady(5 * time.Minute)
Expect(err).ToNot(HaveOccurred())

return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const (
// ProcessExporterImage is the image of the process-exporter pod.
ProcessExporterImage = "quay.io/ocp-edge-qe/process-exporter:ppid-2"
// Timeout is the timeout being used in powersave tests.
Timeout = 15 * time.Minute
Timeout = 30 * time.Minute
// CnfTestImage is the test image used by pods.
CnfTestImage = "quay.io/openshift-kni/cnf-tests:4.8"
// PrivPodNamespace is the priv pod namespace.
Expand Down
15 changes: 9 additions & 6 deletions tests/ranfunc/powermanagement/tests/powersave.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/openshift-kni/eco-gosystem/tests/ranfunc/powermanagement/internal/powermanagementparams"
performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2"
"github.com/openshift/cluster-node-tuning-operator/pkg/performanceprofile/controller/performanceprofile/components"
mcov1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/kubernetes/pkg/kubelet/cm/cpuset"
Expand All @@ -35,8 +36,6 @@ var _ = Describe("Per-Core Runtime Tuning of power states - CRI-O", Ordered, fun
originPerformanceProfileSpec performancev2.PerformanceProfileSpec
)

var timeout = 15 * time.Minute

BeforeAll(func() {
// Get nodes for connection host
nodeList, err = nodes.List(ranfuncinittools.HubAPIClient)
Expand All @@ -49,7 +48,7 @@ var _ = Describe("Per-Core Runtime Tuning of power states - CRI-O", Ordered, fun
Expect(err).ToNot(HaveOccurred())
snoNode = nodeList[0].Object

originPerformanceProfileSpec = perfProfile.Object.Spec
// originPerformanceProfileSpec = perfProfile.Object.Spec
Expect(err).ToNot(HaveOccurred())
})

Expand All @@ -63,8 +62,12 @@ var _ = Describe("Per-Core Runtime Tuning of power states - CRI-O", Ordered, fun
mcp, err := mco.Pull(ranfuncinittools.HubAPIClient, "master")
Expect(err).ToNot(HaveOccurred())

err = mcp.WaitForUpdate(timeout)
err = mcp.WaitToBeInCondition(mcov1.MachineConfigPoolUpdating, corev1.ConditionTrue, 15*time.Minute)
Expect(err).ToNot(HaveOccurred())

err = mcp.WaitToBeInCondition(mcov1.MachineConfigPoolUpdated, corev1.ConditionTrue, 25*time.Minute)
Expect(err).ToNot(HaveOccurred())

})

// OCP-54571 - Install SNO node with standard DU profile that does not include WorkloadHints
Expand Down Expand Up @@ -104,7 +107,7 @@ var _ = Describe("Per-Core Runtime Tuning of power states - CRI-O", Ordered, fun
// OCP-54572 - Enable powersave at node level and then enable performance at node level
It("Enable powersave at node level and then enable performance at node level", func() {
By("Patching the performance profile with the workload hints")
err := powermanagementhelper.SetPowerMode(perfProfile, true, false, true)
err := powermanagementhelper.SetPowerModeAndWaitForMcpUpdate(perfProfile, *nodeList[0], true, false, true)
Expect(err).ToNot(HaveOccurred(), "Unable to set power mode")

cmdline, err := cmd.ExecCmd([]string{"chroot", "rootfs", "cat", "/proc/cmdline"}, snoNode.Name)
Expand All @@ -130,7 +133,7 @@ var _ = Describe("Per-Core Runtime Tuning of power states - CRI-O", Ordered, fun
memLimit := resource.MustParse("100Mi")

By("Patching the performance profile with the workload hints")
err := powermanagementhelper.SetPowerMode(perfProfile, true, false, true)
err := powermanagementhelper.SetPowerModeAndWaitForMcpUpdate(perfProfile, *nodeList[0], true, false, true)
Expect(err).ToNot(HaveOccurred(), "Unable to set power mode")

By("Define test pod")
Expand Down
2 changes: 2 additions & 0 deletions vendor/github.com/openshift-kni/eco-goinfra/pkg/mco/mcp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b86fdd3

Please sign in to comment.