From 09948074e529f0d757e42474227f7cbf96e5a718 Mon Sep 17 00:00:00 2001 From: Trevor Dawe Date: Sun, 1 Dec 2024 20:19:37 +0000 Subject: [PATCH] Updated tests for custom labels --- .../array-config/multi_az_custom_labels | 22 +++++++++++++++++++ service/features/service.feature | 4 ++-- service/step_defs_test.go | 16 +++++++------- 3 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 service/features/array-config/multi_az_custom_labels diff --git a/service/features/array-config/multi_az_custom_labels b/service/features/array-config/multi_az_custom_labels new file mode 100644 index 00000000..b346db0c --- /dev/null +++ b/service/features/array-config/multi_az_custom_labels @@ -0,0 +1,22 @@ +[ + { + "endpoint": "http://127.0.0.1", + "username": "username", + "password": "password", + "insecure": true, + "isDefault": true, + "systemID": "14dbbf5617523654", + "zone": { + "name": "zone1", + "labelKey": "topology.k8s.io/zone", + "protectionDomains": [ + { + "name": "pd", + "pools": [ + "pool1" + ] + } + ] + } + } +] diff --git a/service/features/service.feature b/service/features/service.feature index c83acb83..a4967941 100644 --- a/service/features/service.feature +++ b/service/features/service.feature @@ -1578,6 +1578,6 @@ Feature: VxFlex OS CSI interface Scenario: Call NodeGetInfo with zone label with invalid config Given a VxFlexOS service - And I use config "invalid_multi_az" + And I use config "multi_az_custom_labels" When I call NodeGetInfo with zone labels - Then a NodeGetInfo is returned without zone system topology + Then a valid NodeGetInfo is returned with node topology diff --git a/service/step_defs_test.go b/service/step_defs_test.go index b6aebb93..3c4f7c76 100644 --- a/service/step_defs_test.go +++ b/service/step_defs_test.go @@ -4682,7 +4682,7 @@ func (f *feature) iCallPingNASServer(systemID string, name string) error { return nil } -func getZoneEnabledRequest() *csi.CreateVolumeRequest { +func getZoneEnabledRequest(zoneLabelName string) *csi.CreateVolumeRequest { req := new(csi.CreateVolumeRequest) params := make(map[string]string) req.Parameters = params @@ -4693,12 +4693,12 @@ func getZoneEnabledRequest() *csi.CreateVolumeRequest { topologies := []*csi.Topology{ { Segments: map[string]string{ - "zone.csi-vxflexos.dellemc.com": "zoneA", + zoneLabelName: "zoneA", }, }, { Segments: map[string]string{ - "zone.csi-vxflexos.dellemc.com": "zoneB", + zoneLabelName: "zoneB", }, }, } @@ -4709,7 +4709,7 @@ func getZoneEnabledRequest() *csi.CreateVolumeRequest { func (f *feature) iCallCreateVolumeWithZones(name string) error { ctx := new(context.Context) if f.createVolumeRequest == nil { - req := getZoneEnabledRequest() + req := getZoneEnabledRequest(f.service.opts.zoneLabelKey) f.createVolumeRequest = req } req := f.createVolumeRequest @@ -4728,8 +4728,8 @@ func (f *feature) iCallCreateVolumeWithZones(name string) error { return nil } -func mockGetNodeLabelsWithZone(_ context.Context, _ *service) (map[string]string, error) { - labels := map[string]string{"zone." + Name: "zoneA"} +func mockGetNodeLabelsWithZone(_ context.Context, s *service) (map[string]string, error) { + labels := map[string]string{s.opts.zoneLabelKey: "zoneA"} return labels, nil } @@ -4745,7 +4745,7 @@ func (f *feature) iCallNodeGetInfoWithZoneLabels() error { func (f *feature) aValidNodeGetInfoIsReturnedWithNodeTopology() error { accessibility := f.nodeGetInfoResponse.GetAccessibleTopology() - if _, ok := accessibility.Segments["zone.csi-vxflexos.dellemc.com"]; !ok { + if _, ok := accessibility.Segments[f.service.opts.zoneLabelKey]; !ok { return fmt.Errorf("zone not found") } @@ -4755,7 +4755,7 @@ func (f *feature) aValidNodeGetInfoIsReturnedWithNodeTopology() error { func (f *feature) aNodeGetInfoIsReturnedWithoutZoneTopology() error { accessibility := f.nodeGetInfoResponse.GetAccessibleTopology() Log.Printf("Node Accessibility %+v", accessibility) - if _, ok := accessibility.Segments["zone."+Name]; ok { + if _, ok := accessibility.Segments[f.service.opts.zoneLabelKey]; ok { return fmt.Errorf("zone found") } return nil