Skip to content

Commit

Permalink
e2e: call tainting method instead of duplicates
Browse files Browse the repository at this point in the history
There is a method to applyTaintToNode(..) so using it instead of similar
duplicates.

Signed-off-by: Shereen Haj <[email protected]>
  • Loading branch information
shajmakh committed Apr 3, 2024
1 parent 68739e9 commit ddbf26b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 94 deletions.
72 changes: 3 additions & 69 deletions test/e2e/serial/tests/tolerations.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())

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

Expand Down
27 changes: 2 additions & 25 deletions test/e2e/serial/tests/workload_placement_taint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit ddbf26b

Please sign in to comment.