Skip to content

Commit

Permalink
e2e: remove multiple labels to node
Browse files Browse the repository at this point in the history
update the e2e code to remove multiple
labels to the node at a time.

Signed-off-by: Madhu Rajanna <[email protected]>
  • Loading branch information
Madhu-1 authored and mergify[bot] committed Nov 3, 2023
1 parent a9e8a32 commit 5576800
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 32 deletions.
10 changes: 8 additions & 2 deletions e2e/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,19 @@ func addLabelsToNodes(f *framework.Framework, labels map[string]string) error {
return nil
}

func deleteNodeLabel(c kubernetes.Interface, labelKey string) error {
func deleteNodeLabels(c kubernetes.Interface, labelKeys []string) error {
nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
if err != nil {
return fmt.Errorf("failed to list node: %w", err)
}
for i := range nodes.Items {
e2enode.RemoveLabelOffNode(c, nodes.Items[i].Name, labelKey)
if err := testutils.RemoveLabelOffNode(c, nodes.Items[i].Name, labelKeys); err != nil {
return fmt.Errorf("failed to remove label off node: %w", err)
}

if err := testutils.VerifyLabelsRemoved(c, nodes.Items[i].Name, labelKeys); err != nil {
return fmt.Errorf("failed to verify label removed from node: %w", err)
}
}

return nil
Expand Down
33 changes: 9 additions & 24 deletions e2e/rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,31 +401,16 @@ var _ = Describe("RBD", func() {
}
}
}
err = deleteNodeLabel(c, nodeRegionLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
err = deleteNodeLabel(c, nodeZoneLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
// Remove the CSI labels that get added
err = deleteNodeLabel(c, nodeCSIRegionLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
err = deleteNodeLabel(c, nodeCSIZoneLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
// Remove the CRUSH Location labels
err = deleteNodeLabel(c, crushLocationRegionLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
err = deleteNodeLabel(c, crushLocationZoneLabel)
err = deleteNodeLabels(c, []string{
nodeRegionLabel,
nodeZoneLabel,
nodeCSIRegionLabel,
nodeCSIZoneLabel,
crushLocationRegionLabel,
crushLocationZoneLabel,
})
if err != nil {
framework.Failf("failed to delete node label: %v", err)
framework.Failf("failed to delete node labels: %v", err)
}
})

Expand Down
11 changes: 5 additions & 6 deletions e2e/upgrade-rbd.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,13 +165,12 @@ var _ = Describe("RBD Upgrade Testing", func() {
}
}
}
err = deleteNodeLabel(c, nodeRegionLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
}
err = deleteNodeLabel(c, nodeZoneLabel)
err = deleteNodeLabels(c, []string{
nodeRegionLabel,
nodeZoneLabel,
})
if err != nil {
framework.Failf("failed to delete node label: %v", err)
framework.Failf("failed to delete node labels: %v", err)
}
})

Expand Down

0 comments on commit 5576800

Please sign in to comment.