From 44afa1d17f67ae1fd7ea9b0bf5078efcfecfe1fc Mon Sep 17 00:00:00 2001 From: Bharath Sreekanth <93715158+bharathsreekanth@users.noreply.github.com> Date: Mon, 9 Dec 2024 14:08:59 -0500 Subject: [PATCH] Add snap and clone test (#371) --- service/features/service.feature | 26 +++++++++++++++++++++ service/step_defs_test.go | 40 ++++++++++++++++++++++++++++++-- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/service/features/service.feature b/service/features/service.feature index ef8295a3..c1a8dce8 100644 --- a/service/features/service.feature +++ b/service/features/service.feature @@ -1579,3 +1579,29 @@ Feature: VxFlex OS CSI interface | config | | "multi_az" | | "multi_az_custom_labels" | + + Scenario: Snapshot a single volume in zone + Given a VxFlexOS service + And I use config + When I call Probe + And I call CreateVolume "volume1" with zones + And a valid CreateVolumeResponse is returned + And I call CreateSnapshot + Then a valid CreateSnapshotResponse is returned + And I call Create Volume for zones from Snapshot + Then a valid CreateVolumeResponse is returned + Examples: + | name | config | errorMsg | + | "snap1" | "multi_az" | "none" | + + Scenario: Clone a single volume in zone + Given a VxFlexOS service + And I use config + When I call Probe + And I call CreateVolume with zones + And a valid CreateVolumeResponse is returned + And I call Clone volume for zones + Then a valid CreateVolumeResponse is returned + Examples: + | name | config | errorMsg | + | "volume1" | "multi_az" | "none" | diff --git a/service/step_defs_test.go b/service/step_defs_test.go index 3c4f7c76..a2a48ecb 100644 --- a/service/step_defs_test.go +++ b/service/step_defs_test.go @@ -3812,6 +3812,39 @@ func (f *feature) iCallCreateVolumeFromSnapshot() error { return nil } +func (f *feature) iCallCreateVolumeForZonesFromSnapshot(snapshotID string) error { + ctx := new(context.Context) + req := getZoneEnabledRequest(f.service.opts.zoneLabelKey) + req.Name = "volumeForZonesFromSnap " + + source := &csi.VolumeContentSource_SnapshotSource{SnapshotId: snapshotID} + req.VolumeContentSource = new(csi.VolumeContentSource) + req.VolumeContentSource.Type = &csi.VolumeContentSource_Snapshot{Snapshot: source} + f.createVolumeResponse, f.err = f.service.CreateVolume(*ctx, req) + if f.err != nil { + fmt.Printf("Error on CreateVolume for zones from snap: %s\n", f.err.Error()) + } + return nil +} + +func (f *feature) iCallCloneVolumeForZones(volumeID string) error { + ctx := new(context.Context) + req := getZoneEnabledRequest(f.service.opts.zoneLabelKey) + req.Name = "clone" + + source := &csi.VolumeContentSource_VolumeSource{VolumeId: volumeID} + req.VolumeContentSource = new(csi.VolumeContentSource) + req.VolumeContentSource.Type = &csi.VolumeContentSource_Volume{Volume: source} + req.AccessibilityRequirements = new(csi.TopologyRequirement) + fmt.Printf("CallCloneVolumeForZones with request = %v", req) + f.createVolumeResponse, f.err = f.service.CreateVolume(*ctx, req) + if f.err != nil { + fmt.Printf("Error on CreateVolume from volume: %s\n", f.err.Error()) + } + + return nil +} + func (f *feature) iCallCreateVolumeFromSnapshotNFS() error { ctx := new(context.Context) req := getTypicalNFSCreateVolumeRequest() @@ -4685,6 +4718,7 @@ func (f *feature) iCallPingNASServer(systemID string, name string) error { func getZoneEnabledRequest(zoneLabelName string) *csi.CreateVolumeRequest { req := new(csi.CreateVolumeRequest) params := make(map[string]string) + params["storagepool"] = "viki_pool_HDD_20181031" req.Parameters = params capacityRange := new(csi.CapacityRange) capacityRange.RequiredBytes = 32 * 1024 * 1024 * 1024 @@ -4715,11 +4749,11 @@ func (f *feature) iCallCreateVolumeWithZones(name string) error { req := f.createVolumeRequest req.Name = name - fmt.Println("I am in iCallCreateVolume fn.....") + fmt.Printf("I am in iCallCreateVolume with zones fn with req => ..... %v ...", req) f.createVolumeResponse, f.err = f.service.CreateVolume(*ctx, req) if f.err != nil { - log.Printf("CreateVolume called failed: %s\n", f.err.Error()) + log.Printf("CreateVolume with zones called failed: %s\n", f.err.Error()) } if f.createVolumeResponse != nil { @@ -4902,6 +4936,8 @@ func FeatureContext(s *godog.ScenarioContext) { s.Step(`^I call DeleteSnapshot NFS$`, f.iCallDeleteSnapshotNFS) s.Step(`^a valid snapshot consistency group$`, f.aValidSnapshotConsistencyGroup) s.Step(`^I call Create Volume from Snapshot$`, f.iCallCreateVolumeFromSnapshot) + s.Step(`^I call Create Volume for zones from Snapshot "([^"]*)"$`, f.iCallCreateVolumeForZonesFromSnapshot) + s.Step(`^I call Clone volume for zones "([^"]*)"$`, f.iCallCloneVolumeForZones) s.Step(`^I call Create Volume from SnapshotNFS$`, f.iCallCreateVolumeFromSnapshotNFS) s.Step(`^the wrong capacity$`, f.theWrongCapacity) s.Step(`^the wrong storage pool$`, f.theWrongStoragePool)