mirror of
https://github.com/ceph/ceph-csi.git
synced 2024-11-21 22:00:19 +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/client-go/kubernetes"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
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
|
// NOTE: This makes all nodes (in a multi-node setup) in the test take
|
||||||
// the same label values, which is fine for the test
|
// the same label values, which is fine for the test
|
||||||
nodes, err := f.ClientSet.CoreV1().Nodes().List(context.TODO(), metav1.ListOptions{})
|
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)
|
return fmt.Errorf("failed to list node: %w", err)
|
||||||
}
|
}
|
||||||
for i := range nodes.Items {
|
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
|
return nil
|
||||||
|
21
e2e/rbd.go
21
e2e/rbd.go
@ -275,21 +275,14 @@ var _ = Describe("RBD", func() {
|
|||||||
}
|
}
|
||||||
c = f.ClientSet
|
c = f.ClientSet
|
||||||
if deployRBD {
|
if deployRBD {
|
||||||
err := createNodeLabel(f, nodeRegionLabel, regionValue)
|
err := addLabelsToNodes(f, map[string]string{
|
||||||
|
nodeRegionLabel: regionValue,
|
||||||
|
nodeZoneLabel: zoneValue,
|
||||||
|
crushLocationRegionLabel: crushLocationRegionValue,
|
||||||
|
crushLocationZoneLabel: crushLocationZoneValue,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("failed to create node label: %v", err)
|
framework.Failf("failed to add node labels: %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)
|
|
||||||
}
|
}
|
||||||
if cephCSINamespace != defaultNs {
|
if cephCSINamespace != defaultNs {
|
||||||
err = createNamespace(c, cephCSINamespace)
|
err = createNamespace(c, cephCSINamespace)
|
||||||
|
@ -107,14 +107,12 @@ var _ = Describe("RBD Upgrade Testing", func() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("failed to create snapshotclass: %v", err)
|
framework.Failf("failed to create snapshotclass: %v", err)
|
||||||
}
|
}
|
||||||
|
err = addLabelsToNodes(f, map[string]string{
|
||||||
err = createNodeLabel(f, nodeRegionLabel, regionValue)
|
nodeRegionLabel: regionValue,
|
||||||
|
nodeZoneLabel: zoneValue,
|
||||||
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
framework.Failf("failed to create node label: %v", err)
|
framework.Failf("failed to add node labels: %v", err)
|
||||||
}
|
|
||||||
err = createNodeLabel(f, nodeZoneLabel, zoneValue)
|
|
||||||
if err != nil {
|
|
||||||
framework.Failf("failed to create node label: %v", err)
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
AfterEach(func() {
|
AfterEach(func() {
|
||||||
|
Loading…
Reference in New Issue
Block a user