From ddbf26bbe90d9cc94c58bd02645db1de99de8cdd Mon Sep 17 00:00:00 2001 From: Shereen Haj Date: Tue, 2 Apr 2024 17:03:13 +0300 Subject: [PATCH] e2e: call tainting method instead of duplicates There is a method to applyTaintToNode(..) so using it instead of similar duplicates. Signed-off-by: Shereen Haj --- test/e2e/serial/tests/tolerations.go | 72 +------------------ .../serial/tests/workload_placement_taint.go | 27 +------ 2 files changed, 5 insertions(+), 94 deletions(-) diff --git a/test/e2e/serial/tests/tolerations.go b/test/e2e/serial/tests/tolerations.go index 5b1ce6b56..b142b4080 100644 --- a/test/e2e/serial/tests/tolerations.go +++ b/test/e2e/serial/tests/tolerations.go @@ -374,29 +374,7 @@ var _ = Describe("[serial][disruptive][slow][rtetols] numaresources RTE tolerati Expect(ok).To(BeTrue()) taintedNode := &workers[targetIdx] - Eventually(func() error { - var err error - node := &corev1.Node{} - err = fxt.Client.Get(ctx, client.ObjectKeyFromObject(taintedNode), node) - if err != nil { - return err - } - - updatedNode, updated, err := taints.AddOrUpdateTaint(node, tnt) - if err != nil { - return err - } - if !updated { - return nil - } - - klog.Infof("adding taint: %q to node: %q", tnt.String(), updatedNode.Name) - err = fxt.Client.Update(ctx, updatedNode) - if err != nil { - return err - } - return nil - }).WithPolling(1 * time.Second).WithTimeout(1 * time.Minute).ShouldNot(HaveOccurred()) + applyTaintToNode(ctx, fxt.Client, taintedNode, tnt) targetNodeNames = append(targetNodeNames, taintedNode.Name) klog.Infof("considering node: %q tainted with %q", taintedNode.Name, tnt.String()) @@ -462,29 +440,7 @@ var _ = Describe("[serial][disruptive][slow][rtetols] numaresources RTE tolerati Expect(ok).To(BeTrue()) taintedNode = &workers[targetIdx] - Eventually(func() error { - var err error - node := &corev1.Node{} - err = fxt.Client.Get(ctx, client.ObjectKeyFromObject(taintedNode), node) - if err != nil { - return err - } - - updatedNode, updated, err := taints.AddOrUpdateTaint(node, tnt) - if err != nil { - return err - } - if !updated { - return nil - } - - klog.Infof("adding taint: %q to node: %q", tnt.String(), updatedNode.Name) - err = fxt.Client.Update(ctx, updatedNode) - if err != nil { - return err - } - return nil - }).WithPolling(1 * time.Second).WithTimeout(1 * time.Minute).ShouldNot(HaveOccurred()) + applyTaintToNode(ctx, fxt.Client, taintedNode, tnt) targetNodeNames = append(targetNodeNames, taintedNode.Name) klog.Infof("considering node: %q tainted with %q", taintedNode.Name, tnt.String()) }) @@ -602,29 +558,7 @@ var _ = Describe("[serial][disruptive][slow][rtetols] numaresources RTE tolerati Expect(ok).To(BeTrue()) taintedNode := &workers[targetIdx] - Eventually(func() error { - var err error - node := &corev1.Node{} - err = fxt.Client.Get(ctx, client.ObjectKeyFromObject(taintedNode), node) - if err != nil { - return err - } - - updatedNode, updated, err := taints.AddOrUpdateTaint(node, tnt) - if err != nil { - return err - } - if !updated { - return nil - } - - klog.Infof("adding taint: %q to node: %q", tnt.String(), updatedNode.Name) - err = fxt.Client.Update(ctx, updatedNode) - if err != nil { - return err - } - return nil - }).WithPolling(1 * time.Second).WithTimeout(1 * time.Minute).ShouldNot(HaveOccurred()) + applyTaintToNode(ctx, fxt.Client, taintedNode, tnt) targetNodeNames = append(targetNodeNames, taintedNode.Name) klog.Infof("considering node: %q tainted with %q", taintedNode.Name, tnt.String()) diff --git a/test/e2e/serial/tests/workload_placement_taint.go b/test/e2e/serial/tests/workload_placement_taint.go index 9ce12d191..87ae43fb6 100644 --- a/test/e2e/serial/tests/workload_placement_taint.go +++ b/test/e2e/serial/tests/workload_placement_taint.go @@ -131,31 +131,8 @@ var _ = Describe("[serial][disruptive][scheduler] numaresources workload placeme var updatedNodeNames []string for i := range nodes { refNode := &nodes[i] - - Eventually(func() error { - var err error - node := &corev1.Node{} - err = fxt.Client.Get(context.TODO(), client.ObjectKeyFromObject(refNode), node) - if err != nil { - return err - } - - updatedNode, updated, err := taints.AddOrUpdateTaint(node, tnt) - if err != nil { - return err - } - if !updated { - return nil - } - - klog.Infof("adding taint: %q to node: %q", tnt.String(), updatedNode.Name) - err = fxt.Client.Update(context.TODO(), updatedNode) - if err != nil { - return err - } - updatedNodeNames = append(updatedNodeNames, updatedNode.Name) - return nil - }).WithPolling(1 * time.Second).WithTimeout(1 * time.Minute).ShouldNot(HaveOccurred()) + applyTaintToNode(context.TODO(), fxt.Client, refNode, tnt) + updatedNodeNames = append(updatedNodeNames, refNode.Name) } taintedNodeNames = updatedNodeNames