From fbd2df94b5df9ce5465ddd7c141b9605d8f23bd9 Mon Sep 17 00:00:00 2001 From: Talor Itzhak Date: Sun, 23 Jul 2023 18:58:53 +0300 Subject: [PATCH] e2e:irqbalance: wait for tuned profile to be ready (#721) we need to wait for tuned to apply the recent changes, before we check the irqbalance settings. we poll the tuned profile and check the applied status. we failed the test if the status not consolidate to applied within the timeout value. Signed-off-by: Talor Itzhak --- .../functests/1_performance/irqbalance.go | 15 +++++++++++++++ .../functests/utils/tuned/tuned.go | 13 +++++++++++++ 2 files changed, 28 insertions(+) diff --git a/test/e2e/performanceprofile/functests/1_performance/irqbalance.go b/test/e2e/performanceprofile/functests/1_performance/irqbalance.go index bd93f20d9..aa5893c9b 100644 --- a/test/e2e/performanceprofile/functests/1_performance/irqbalance.go +++ b/test/e2e/performanceprofile/functests/1_performance/irqbalance.go @@ -18,6 +18,7 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + tunedv1 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/tuned/v1" machineconfigv1 "github.com/openshift/machine-config-operator/pkg/apis/machineconfiguration.openshift.io/v1" performancev2 "github.com/openshift/cluster-node-tuning-operator/pkg/apis/performanceprofile/v2" @@ -31,6 +32,7 @@ import ( "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/nodes" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/pods" "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/profiles" + e2etuned "github.com/openshift/cluster-node-tuning-operator/test/e2e/performanceprofile/functests/utils/tuned" "github.com/openshift/cluster-node-tuning-operator/test/e2e/util" "github.com/openshift/cluster-node-tuning-operator/test/framework" ) @@ -89,6 +91,19 @@ var _ = Describe("[performance] Checking IRQBalance settings", Ordered, func() { } for _, node := range workerRTNodes { + var condStatus string + Eventually(context.TODO(), func() bool { + tunedProfile, err := e2etuned.GetProfile(context.TODO(), testclient.Client, components.NamespaceNodeTuningOperator, node.Name) + Expect(err).ToNot(HaveOccurred(), "failed to get Tuned Profile for node %q", node.Name) + for _, cond := range tunedProfile.Status.Conditions { + if cond.Type == tunedv1.TunedProfileApplied && cond.Status != corev1.ConditionTrue { + condStatus = string(cond.Status) + return false + } + } + return true + }).WithPolling(time.Second*10).WithTimeout(3*time.Minute).Should(BeTrue(), "Tuned Profile for node %q was not applied successfully conditionStatus=%q", node.Name, condStatus) + By(fmt.Sprintf("verifying worker node %q", node.Name)) bannedCPUs, err := getIrqBalanceBannedCPUs(&node) diff --git a/test/e2e/performanceprofile/functests/utils/tuned/tuned.go b/test/e2e/performanceprofile/functests/utils/tuned/tuned.go index 94c09196d..d4a5e6ef4 100644 --- a/test/e2e/performanceprofile/functests/utils/tuned/tuned.go +++ b/test/e2e/performanceprofile/functests/utils/tuned/tuned.go @@ -127,3 +127,16 @@ func CheckParameters(node *corev1.Node, sysctlMap map[string]string, kernelParam ExpectWithOffset(1, err).To(HaveOccurred(), "node should have non-RT kernel") } } + +func GetProfile(ctx context.Context, cli client.Client, ns, name string) (*tunedv1.Profile, error) { + key := client.ObjectKey{ + Namespace: ns, + Name: name, + } + p := &tunedv1.Profile{} + err := cli.Get(ctx, key, p) + if err != nil { + return nil, err + } + return p, nil +}