Skip to content

Commit

Permalink
Updated tests for custom labels
Browse files Browse the repository at this point in the history
  • Loading branch information
tdawe committed Dec 1, 2024
1 parent 3f97334 commit 0994807
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 10 deletions.
22 changes: 22 additions & 0 deletions service/features/array-config/multi_az_custom_labels
Original file line number Diff line number Diff line change
@@ -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"
]
}
]
}
}
]
4 changes: 2 additions & 2 deletions service/features/service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 8 additions & 8 deletions service/step_defs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
},
},
}
Expand All @@ -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
Expand All @@ -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
}

Expand All @@ -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")
}

Expand All @@ -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
Expand Down

0 comments on commit 0994807

Please sign in to comment.