Skip to content

Commit

Permalink
Create GetCapacity feature scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
adamginna-dell committed Oct 27, 2023
1 parent 35f1f13 commit 30eb7f1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
10 changes: 5 additions & 5 deletions service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,9 @@ func (s *service) GetCapacity(

log.Infof("Available capacity from the Array: %d", capacity.Entries[0].Content.SizeFree)

maxVolSize := s.getMaximumVolumeSize(ctx, arrayID)
maxVolSize, err := s.getMaximumVolumeSize(ctx, arrayID)

if maxVolSize == 0 {
if err != nil {
return &csi.GetCapacityResponse{
AvailableCapacity: int64(capacity.Entries[0].Content.SizeFree),
}, nil
Expand All @@ -547,16 +547,16 @@ func (s *service) GetCapacity(

}

func (s *service) getMaximumVolumeSize(ctx context.Context, arrayID string) int64 {
func (s *service) getMaximumVolumeSize(ctx context.Context, arrayID string) (int64, error) {
ctx, log, _ := GetRunidLog(ctx)
unity, err := s.getUnityClient(ctx, arrayID)
volumeAPI := gounity.NewVolume(unity)
maxVolumeSize, err := volumeAPI.GetMaxVolumeSize(ctx, "Limit_MaxLUNSize")
if err != nil {
log.Debugf("GetMaxVolumeSize returning: %v for Array having GlobalId %s", err, arrayID)
return 0
return 0, err
}
return maxVolumeSize.MaxVolumSizeContent.Limit
return maxVolumeSize.MaxVolumSizeContent.Limit, nil
}

func (s *service) CreateSnapshot(ctx context.Context, req *csi.CreateSnapshotRequest) (*csi.CreateSnapshotResponse, error) {
Expand Down
4 changes: 4 additions & 0 deletions test/unit-test/features/unit.feature
Original file line number Diff line number Diff line change
Expand Up @@ -802,3 +802,7 @@ Feature: CSI interface
And when I call DeleteVolume
Then there are no errors

Scenario: GetCapacity successfully requested
Given a CSI service
When I Call GetCapacity
Then there are no errors
1 change: 1 addition & 0 deletions test/unit-test/unit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1321,5 +1321,6 @@ func FeatureContext(s *godog.Suite) {
s.Step(`^When I call GetPluginCapabilities$`, f.whenICallGetPluginCapabilities)
s.Step(`^When I call GetPluginInfo$`, f.whenICallGetPluginInfo)
s.Step(`^when I call Node Expand Volume$`, f.whenICallNodeExpandVolume)
s.Step(`^When I Call GetCapacity$`, f.whenICallGetCapacity)

}

0 comments on commit 30eb7f1

Please sign in to comment.