mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-12-21 20:40:20 +00:00
e2e: add multiple labels to node
update the e2e code to add multiple labels to the node at a time. fixes: #4146 Signed-off-by: Madhu Rajanna <madhupr007@gmail.com>
This commit is contained in:
parent
4d3b1fc46f
commit
a9e8a32a98
@ -26,9 +26,10 @@ import (
|
||||
"k8s.io/client-go/kubernetes"
|
||||
"k8s.io/kubernetes/test/e2e/framework"
|
||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||
testutils "k8s.io/kubernetes/test/utils"
|
||||
)
|
||||
|
||||
func createNodeLabel(f *framework.Framework, labelKey, labelValue string) error {
|
||||
func addLabelsToNodes(f *framework.Framework, labels map[string]string) error {
|
||||
// NOTE: This makes all nodes (in a multi-node setup) in the test take
|
||||
// the same label values, which is fine for the test
|
||||
nodes, err := f.ClientSet.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
|
||||
@ -36,7 +37,9 @@ func createNodeLabel(f *framework.Framework, labelKey, labelValue string) error
|
||||
return fmt.Errorf("failed to list node: %w", err)
|
||||
}
|
||||
for i := range nodes.Items {
|
||||
e2enode.AddOrUpdateLabelOnNode(f.ClientSet, nodes.Items[i].Name, labelKey, labelValue)
|
||||
if err := testutils.AddLabelsToNode(f.ClientSet, nodes.Items[i].Name, labels); err != nil {
|
||||
return fmt.Errorf("failed to add labels to node: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
|
21
e2e/rbd.go
21
e2e/rbd.go
@ -275,21 +275,14 @@ var _ = Describe("RBD", func() {
|
||||
}
|
||||
c = f.ClientSet
|
||||
if deployRBD {
|
||||
err := createNodeLabel(f, nodeRegionLabel, regionValue)
|
||||
err := addLabelsToNodes(f, map[string]string{
|
||||
nodeRegionLabel: regionValue,
|
||||
nodeZoneLabel: zoneValue,
|
||||
crushLocationRegionLabel: crushLocationRegionValue,
|
||||
crushLocationZoneLabel: crushLocationZoneValue,
|
||||
})
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
}
|
||||
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
}
|
||||
err = createNodeLabel(f, crushLocationRegionLabel, crushLocationRegionValue)
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
}
|
||||
err = createNodeLabel(f, crushLocationZoneLabel, crushLocationZoneValue)
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
framework.Failf("failed to add node labels: %v", err)
|
||||
}
|
||||
if cephCSINamespace != defaultNs {
|
||||
err = createNamespace(c, cephCSINamespace)
|
||||
|
@ -107,14 +107,12 @@ var _ = Describe("RBD Upgrade Testing", func() {
|
||||
if err != nil {
|
||||
framework.Failf("failed to create snapshotclass: %v", err)
|
||||
}
|
||||
|
||||
err = createNodeLabel(f, nodeRegionLabel, regionValue)
|
||||
err = addLabelsToNodes(f, map[string]string{
|
||||
nodeRegionLabel: regionValue,
|
||||
nodeZoneLabel: zoneValue,
|
||||
})
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
}
|
||||
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
||||
if err != nil {
|
||||
framework.Failf("failed to create node label: %v", err)
|
||||
framework.Failf("failed to add node labels: %v", err)
|
||||
}
|
||||
})
|
||||
AfterEach(func() {
|
||||
|
Loading…
Reference in New Issue
Block a user