Skip to content

Commit

Permalink
Add multi-az unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
falfaroc committed Nov 22, 2024
1 parent 17a226d commit 196a140
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 6 deletions.
21 changes: 21 additions & 0 deletions service/features/array-config/invalid_multi_az
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"endpoint": "http://127.0.0.1",
"username": "admin",
"password": "Password123",
"insecure": true,
"isDefault": true,
"systemID": "14dbbf5617523654",
"zone": {
"name": "notExistent",
"protectionDomains": [
{
"name": "bad",
"pools": [
"badPool"
]
}
]
}
}
]
40 changes: 40 additions & 0 deletions service/features/array-config/multi_az
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[
{
"endpoint": "http://127.0.0.1",
"username": "admin",
"password": "Password123",
"insecure": true,
"isDefault": true,
"systemID": "14dbbf5617523654",
"zone": {
"name": "zoneA",
"protectionDomains": [
{
"name": "mocksystem",
"pools": [
"viki_pool_HDD_20181031"
]
}
]
}
},
{
"endpoint": "http://127.0.0.2",
"username": "admin",
"password": "Password123",
"skipCertificateValidation": true,
"isDefault": false,
"systemID": "15dbbf5617523655",
"zone": {
"name": "zoneB",
"protectionDomains": [
{
"name": "mocksystem",
"pools": [
"viki_pool_HDD_20181031"
]
}
]
}
}
]
2 changes: 1 addition & 1 deletion service/features/get_storage_pool_instances.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"zeroPaddingEnabled": true,
"backgroundScannerMode": "Disabled",
"rebalanceIoPriorityPolicy": "favorAppIos",
"protectionDomainId": "b8b3919900000000",
"protectionDomainId": "14dbbf5617523654",
"backgroundScannerBWLimitKBps": 0,
"rebuildIoPriorityBwLimitPerDeviceInKbps": 10240,
"sparePercentage": 10,
Expand Down
19 changes: 17 additions & 2 deletions service/features/service.feature
Original file line number Diff line number Diff line change
Expand Up @@ -1551,5 +1551,20 @@ Feature: VxFlex OS CSI interface
Examples:
| systemid | nasserver | error | errorMsg |
| "15dbbf5617523655" | "63ec8e0d-4551-29a7-e79c-b202f2b914f3" | "" | "none" |
| "15dbbf5617523655" | "invalid-nas-server" | "NasNotFoundError" | "NAS server not found" |

| "15dbbf5617523655" | "invalid-nas-server" | "NasNotFoundError" | "NAS server not found" |

Scenario: Create Volume for multi-available zone
Given a VxFlexOS service
And I use config <config>
When I call Probe
And I call CreateVolume <name> with zones
Then the error contains <errorMsg>
Examples:
| name | config | errorMsg |
| "volume1" | "multi_az" | "none" |
| "volume1" | "invalid_multi_az" | "no zone topology found in accessibility requirements" |

Scenario: Call NodeGetInfo with zone label
Given a VxFlexOS service
When I call NodeGetInfo with zone labels
Then a valid NodeGetInfo is returned with node topology
83 changes: 80 additions & 3 deletions service/step_defs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4253,12 +4253,15 @@ func (f *feature) iUseConfig(filename string) error {
fmt.Printf("****************************************************** s.opts.arrays %v\n", f.service.opts.arrays)
f.service.systemProbeAll(context.Background())
f.adminClient = f.service.adminClients[arrayID]
f.adminClient2 = f.service.adminClients[arrayID2]
if f.adminClient == nil {
return fmt.Errorf("adminClient nil")
}
if f.adminClient2 == nil {
return fmt.Errorf("adminClient2 nil")

if len(f.service.opts.arrays) > 1 {
f.adminClient2 = f.service.adminClients[arrayID2]
if f.adminClient2 == nil {
return fmt.Errorf("adminClient2 nil")
}
}
return nil
}
Expand Down Expand Up @@ -4674,6 +4677,76 @@ func (f *feature) iCallPingNASServer(systemID string, name string) error {
return nil
}

func getZoneEnabledRequest() *csi.CreateVolumeRequest {
req := new(csi.CreateVolumeRequest)
params := make(map[string]string)
req.Parameters = params
capacityRange := new(csi.CapacityRange)
capacityRange.RequiredBytes = 32 * 1024 * 1024 * 1024
req.CapacityRange = capacityRange
req.AccessibilityRequirements = new(csi.TopologyRequirement)
topologies := []*csi.Topology{
{
Segments: map[string]string{
"zone.csi-vxflexos.dellemc.com": "zoneA",
},
},
{
Segments: map[string]string{
"zone.csi-vxflexos.dellemc.com": "zoneB",
},
},
}
req.AccessibilityRequirements.Preferred = topologies
return req
}

func (f *feature) iCallCreateVolumeWithZones(name string) error {
ctx := new(context.Context)
if f.createVolumeRequest == nil {
req := getZoneEnabledRequest()
f.createVolumeRequest = req
}
req := f.createVolumeRequest
req.Name = name

fmt.Println("I am in iCallCreateVolume fn.....")

f.createVolumeResponse, f.err = f.service.CreateVolume(*ctx, req)
if f.err != nil {
log.Printf("CreateVolume called failed: %s\n", f.err.Error())
}

if f.createVolumeResponse != nil {
log.Printf("vol id %s\n", f.createVolumeResponse.GetVolume().VolumeId)
}
return nil
}

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

func (f *feature) iCallNodeGetInfoWithZoneLabels() error {
ctx := new(context.Context)
req := new(csi.NodeGetInfoRequest)
f.service.opts.SdcGUID = "9E56672F-2F4B-4A42-BFF4-88B6846FBFDA"
GetNodeLabels = mockGetNodeLabelsWithZone
GetNodeUID = mockGetNodeUID
f.nodeGetInfoResponse, f.err = f.service.NodeGetInfo(*ctx, req)
return nil
}

func (f *feature) aValidNodeGetInfoIsReturnedWithNodeTopology() error {
accessibility := f.nodeGetInfoResponse.GetAccessibleTopology()
if _, ok := accessibility.Segments["zone.csi-vxflexos.dellemc.com"]; !ok {
return fmt.Errorf("zone not found")
}

return nil
}

func FeatureContext(s *godog.ScenarioContext) {
f := &feature{}
s.Step(`^a VxFlexOS service$`, f.aVxFlexOSService)
Expand Down Expand Up @@ -4898,6 +4971,10 @@ func FeatureContext(s *godog.ScenarioContext) {
s.Step(`^I call GetNodeUID with invalid node$`, f.iCallGetNodeUIDWithInvalidNode)
s.Step(`^I call GetNodeUID with unset KubernetesClient$`, f.iCallGetNodeUIDWithUnsetKubernetesClient)

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.After(func(ctx context.Context, _ *godog.Scenario, _ error) (context.Context, error) {
if f.server != nil {
f.server.Close()
Expand Down

0 comments on commit 196a140

Please sign in to comment.