e2e: remove multiple labels to node

update the e2e code to remove multiple
labels to the node at a time.

Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
Madhu Rajanna 2023-11-02 12:31:13 +01:00 committed by mergify[bot]
parent a9e8a32a98
commit 55768007f4
3 changed files with 22 additions and 32 deletions

View File

@ -45,13 +45,19 @@ func addLabelsToNodes(f *framework.Framework, labels map[string]string) error {
return nil 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{}) nodes, err := c.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
if err != nil { if err != nil {
return fmt.Errorf("failed to list node: %w", err) return fmt.Errorf("failed to list node: %w", err)
} }
for i := range nodes.Items { 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 return nil

View File

@ -401,31 +401,16 @@ var _ = Describe("RBD", func() {
} }
} }
} }
err = deleteNodeLabel(c, nodeRegionLabel) err = deleteNodeLabels(c, []string{
nodeRegionLabel,
nodeZoneLabel,
nodeCSIRegionLabel,
nodeCSIZoneLabel,
crushLocationRegionLabel,
crushLocationZoneLabel,
})
if err != nil { if err != nil {
framework.Failf("failed to delete node label: %v", err) framework.Failf("failed to delete node labels: %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)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
} }
}) })

View File

@ -165,13 +165,12 @@ var _ = Describe("RBD Upgrade Testing", func() {
} }
} }
} }
err = deleteNodeLabel(c, nodeRegionLabel) err = deleteNodeLabels(c, []string{
nodeRegionLabel,
nodeZoneLabel,
})
if err != nil { if err != nil {
framework.Failf("failed to delete node label: %v", err) framework.Failf("failed to delete node labels: %v", err)
}
err = deleteNodeLabel(c, nodeZoneLabel)
if err != nil {
framework.Failf("failed to delete node label: %v", err)
} }
}) })