From b59ae4153757f341fb970e85c5ce433683c4e648 Mon Sep 17 00:00:00 2001 From: Akshay Saini Date: Fri, 12 Jul 2024 06:08:38 +0000 Subject: [PATCH] Add e2e for mkfs formatting option --- test/integration/features/integration.feature | 36 ++++++++++++++++--- test/integration/step_defs_test.go | 15 ++++---- 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/test/integration/features/integration.feature b/test/integration/features/integration.feature index 49f0811c..e0222c5c 100644 --- a/test/integration/features/integration.feature +++ b/test/integration/features/integration.feature @@ -10,7 +10,7 @@ Feature: VxFlex OS CSI interface When I call CreateVolume And there are no errors And when I call PublishVolume "SDC_GUID" - And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/podmondev1" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/podmondev1" "" And there are no errors And I read write data to volume "/tmp/podmondev1" And when I call Validate Volume Host connectivity @@ -332,8 +332,8 @@ Feature: VxFlex OS CSI interface And when I call UnpublishVolume "SDC_GUID" And a capability with voltype "mount" access "multi-reader" fstype "xfs" And when I call PublishVolume "SDC_GUID" - And when I call NodePublishVolumeWithPoint "SDC_GUID" "temp1" - And when I call NodePublishVolumeWithPoint "SDC_GUID" "temp2" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "temp1" "" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "temp2" "" And when I call NodeUnpublishVolumeWithPoint "SDC_GUID" "temp1" And when I call NodeUnpublishVolumeWithPoint "SDC_GUID" "temp2" And when I call UnpublishVolume "SDC_GUID" @@ -348,9 +348,9 @@ Feature: VxFlex OS CSI interface And there are no errors And when I call PublishVolume "SDC_GUID" And when I call PublishVolume "ALT_GUID" - And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/tempdev1" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/tempdev1" "" And there are no errors - And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/tempdev2" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/tempdev2" "" And there are no errors And when I call NodePublishVolume "ALT_GUID" And there are no errors @@ -895,3 +895,29 @@ Scenario: Call NodeGetVolumeStats on unmounted volume And there are no errors And when I call DeleteVolume Then there are no errors + +Scenario: Custom file system format options (mkfsFormatOption) + Given a VxFlexOS service + And a capability with voltype access fstype + And a volume request "mkfs1" "8" + When I call CreateVolume + And there are no errors + And when I call PublishVolume "SDC_GUID" + And when I call NodePublishVolumeWithPoint "SDC_GUID" "/tmp/mkfsdev1" + And the error message should contain + And I read write data to volume "/tmp/mkfsdev1" + And when I call Validate Volume Host connectivity + Then there are no errors + And when I call NodeUnpublishVolumeWithPoint "SDC_GUID" "/tmp/mkfsdev1" + And when I call NodeUnpublishVolume "SDC_GUID" + And when I call UnpublishVolume "SDC_GUID" + And there are no errors + And when I call DeleteVolume + Then there are no errors + Examples: + | voltype | mkfsFormatOption | access | fstype | errormsg | + | "mount" | "-L MyVolume" | "single-writer" | "xfs" | "none" | + | "mount" | "-L MyVolume -m 1" | "single-node-single-writer" | "ext4" | "none" | + | "mount" | "-T largefile4" |"single-node-multi-writer" | "ext4" | "none" | + | "mount" | ":-L MyVolume" | "single-writer" | "xfs" | "error performing private mount" | + | "mount" | "abc" | "single-node-single-writer" | "ext4" | "error performing private mount" | \ No newline at end of file diff --git a/test/integration/step_defs_test.go b/test/integration/step_defs_test.go index 687930e9..b26dce64 100644 --- a/test/integration/step_defs_test.go +++ b/test/integration/step_defs_test.go @@ -754,7 +754,7 @@ func (f *feature) getNodePublishVolumeRequest() *csi.NodePublishVolumeRequest { } //nolint:revive -func (f *feature) whenICallNodePublishVolumeWithPoint(arg1 string, arg2 string) error { +func (f *feature) whenICallNodePublishVolumeWithPoint(arg1 string, arg2 string, mkfsFormatOption string) error { block := f.capability.GetBlock() if block == nil { _, err := os.Stat(arg2) @@ -766,7 +766,7 @@ func (f *feature) whenICallNodePublishVolumeWithPoint(arg1 string, arg2 string) } } - err := f.nodePublishVolume(f.volID, arg2) + err := f.nodePublishVolume(f.volID, arg2, mkfsFormatOption) if err != nil { fmt.Printf("NodePublishVolume failed: %s\n", err.Error()) f.addError(err) @@ -779,7 +779,7 @@ func (f *feature) whenICallNodePublishVolumeWithPoint(arg1 string, arg2 string) //nolint:revive func (f *feature) whenICallNodePublishVolume(arg1 string) error { - err := f.nodePublishVolume(f.volID, "") + err := f.nodePublishVolume(f.volID, "", "") if err != nil { fmt.Printf("NodePublishVolume failed: %s\n", err.Error()) f.addError(err) @@ -805,7 +805,7 @@ func (f *feature) iCallEthemeralNodePublishVolume(id, size string) error { return nil } -func (f *feature) nodePublishVolume(id string, path string) error { +func (f *feature) nodePublishVolume(id string, path string, mkfsFormatOption string) error { req := f.getNodePublishVolumeRequest() if path != "" { block := f.capability.GetBlock() @@ -818,6 +818,9 @@ func (f *feature) nodePublishVolume(id string, path string) error { } } req.VolumeId = id + if len(mkfsFormatOption) > 0 { + req.VolumeContext = map[string]string{"mkfsFormatOption": mkfsFormatOption} + } ctx := context.Background() client := csi.NewNodeClient(grpcClient) _, err := client.NodePublishVolume(ctx, req) @@ -1327,7 +1330,7 @@ func (f *feature) iNodePublishVolumesInParallel(nVols int) error { } dataDirName := fmt.Sprintf("/tmp/datadir%d", i) go func(id string, dataDirName string, done chan bool, errchan chan error) { - err := f.nodePublishVolume(id, dataDirName) + err := f.nodePublishVolume(id, dataDirName, "") done <- true errchan <- err }(id, dataDirName, done, errchan) @@ -2517,7 +2520,7 @@ func FeatureContext(s *godog.ScenarioContext) { s.Step(`^a capability with voltype "([^"]*)" access "([^"]*)" fstype "([^"]*)"$`, f.aCapabilityWithVoltypeAccessFstype) s.Step(`^a volume request "([^"]*)" "(\d+)"$`, f.aVolumeRequest) s.Step(`^when I call NodePublishVolume "([^"]*)"$`, f.whenICallNodePublishVolume) - s.Step(`^when I call NodePublishVolumeWithPoint "([^"]*)" "([^"]*)"$`, f.whenICallNodePublishVolumeWithPoint) + s.Step(`^when I call NodePublishVolumeWithPoint "([^"]*)" "([^"]*)" "([^"]*)"$`, f.whenICallNodePublishVolumeWithPoint) s.Step(`^when I call NodeUnpublishVolume "([^"]*)"$`, f.whenICallNodeUnpublishVolume) s.Step(`^when I call NodeUnpublishVolumeWithPoint "([^"]*)" "([^"]*)"$`, f.whenICallNodeUnpublishVolumeWithPoint) s.Step(`^verify published volume with voltype "([^"]*)" access "([^"]*)" fstype "([^"]*)"$`, f.verifyPublishedVolumeWithVoltypeAccessFstype)