Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests for Node Topologies #358

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion service/features/service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1564,8 +1564,20 @@ Feature: VxFlex OS CSI interface
| "volume1" | "multi_az" | "none" |
| "volume1" | "invalid_multi_az" | "no zone topology found in accessibility requirements" |

Scenario: Call NodeGetInfo without zone label
Given a VxFlexOS service
And I use config "config"
When I call NodeGetInfo
Then a NodeGetInfo is returned without zone topology

Scenario: Call NodeGetInfo with zone label
Given a VxFlexOS service
And I use config "multi_az"
When I call NodeGetInfo with zone labels
Then a valid NodeGetInfo is returned with node topology
Then a valid NodeGetInfo is returned with node topology

Scenario: Call NodeGetInfo with zone label with invalid config
Given a VxFlexOS service
And I use config "invalid_multi_az"
When I call NodeGetInfo with zone labels
Then a NodeGetInfo is returned without zone system topology
26 changes: 25 additions & 1 deletion service/step_defs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@ func (f *feature) iCallNodeGetInfo() error {
req := new(csi.NodeGetInfoRequest)
f.service.opts.SdcGUID = "9E56672F-2F4B-4A42-BFF4-88B6846FBFDA"
GetNodeLabels = mockGetNodeLabels
GetNodeUID = mockGetNodeUID
f.nodeGetInfoResponse, f.err = f.service.NodeGetInfo(*ctx, req)
return nil
}
Expand Down Expand Up @@ -4724,7 +4725,7 @@ func (f *feature) iCallCreateVolumeWithZones(name string) error {
}

func mockGetNodeLabelsWithZone(_ context.Context, _ *service) (map[string]string, error) {
labels := map[string]string{"zone.csi-vxflexos.dellemc.com": "zoneA"}
labels := map[string]string{"zone." + Name: "zoneA"}
return labels, nil
}

Expand All @@ -4747,6 +4748,27 @@ func (f *feature) aValidNodeGetInfoIsReturnedWithNodeTopology() error {
return nil
}

func (f *feature) aNodeGetInfoIsReturnedWithoutZoneTopology() error {
accessibility := f.nodeGetInfoResponse.GetAccessibleTopology()
Log.Printf("Node Accessibility %+v", accessibility)
if _, ok := accessibility.Segments["zone."+Name]; ok {
return fmt.Errorf("zone found")
}
return nil
}

func (f *feature) aNodeGetInfoIsReturnedWithoutZoneSystemTopology() error {
accessibility := f.nodeGetInfoResponse.GetAccessibleTopology()
Log.Printf("Node Accessibility %+v", accessibility)

for _, array := range f.service.opts.arrays {
if _, ok := accessibility.Segments[Name+"/"+array.SystemID]; ok {
return fmt.Errorf("zone found")
}
}
return nil
}

func FeatureContext(s *godog.ScenarioContext) {
f := &feature{}
s.Step(`^a VxFlexOS service$`, f.aVxFlexOSService)
Expand Down Expand Up @@ -4974,6 +4996,8 @@ func FeatureContext(s *godog.ScenarioContext) {
s.Step(`^I call CreateVolume "([^"]*)" with zones$`, f.iCallCreateVolumeWithZones)
s.Step(`^I call NodeGetInfo with zone labels$`, f.iCallNodeGetInfoWithZoneLabels)
s.Step(`^a valid NodeGetInfo is returned with node topology$`, f.aValidNodeGetInfoIsReturnedWithNodeTopology)
s.Step(`^a NodeGetInfo is returned without zone topology$`, f.aNodeGetInfoIsReturnedWithoutZoneTopology)
s.Step(`^a NodeGetInfo is returned without zone system topology$`, f.aNodeGetInfoIsReturnedWithoutZoneSystemTopology)

s.After(func(ctx context.Context, _ *godog.Scenario, _ error) (context.Context, error) {
if f.server != nil {
Expand Down