-
Notifications
You must be signed in to change notification settings - Fork 110
Set storage size to minimum volume size #441
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
Changes from 4 commits
bdbb42d
075fa32
3502954
ea7c363
98c4714
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -181,14 +181,20 @@ func (*fakeTagsDriver) UntagResources(context.Context, string, *godo.UntagResour | |
} | ||
|
||
func TestControllerExpandVolume(t *testing.T) { | ||
default_volume := &godo.Volume{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use snake case here, i.e., |
||
ID: "volume-id", | ||
SizeGigaBytes: (defaultVolumeSizeInBytes / giB), | ||
} | ||
tcs := []struct { | ||
name string | ||
req *csi.ControllerExpandVolumeRequest | ||
resp *csi.ControllerExpandVolumeResponse | ||
err error | ||
name string | ||
req *csi.ControllerExpandVolumeRequest | ||
resp *csi.ControllerExpandVolumeResponse | ||
err error | ||
godo_volume *godo.Volume | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd name this just There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, done. |
||
}{ | ||
{ | ||
name: "request exceeds maximum supported size", | ||
name: "request exceeds maximum supported size", | ||
godo_volume: default_volume, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of requiring to define the volume for every current and future test case, could we make it optional and let the test body pick There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, updated. |
||
req: &csi.ControllerExpandVolumeRequest{ | ||
VolumeId: "volume-id", | ||
CapacityRange: &csi.CapacityRange{ | ||
|
@@ -200,17 +206,22 @@ func TestControllerExpandVolume(t *testing.T) { | |
}, | ||
{ | ||
name: "requested size less than minimum supported size", | ||
godo_volume: &godo.Volume{ | ||
ID: "volume-id", | ||
SizeGigaBytes: (minimumVolumeSizeInBytes / giB), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we subtract a bit to make sure we're really below the minimum size (and not hitting it exactly)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this is |
||
}, | ||
req: &csi.ControllerExpandVolumeRequest{ | ||
VolumeId: "volume-id", | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: 0.5 * giB, | ||
}, | ||
}, | ||
resp: nil, | ||
err: status.Error(codes.OutOfRange, "ControllerExpandVolume invalid capacity range: required (512Mi) can not be less than minimum supported volume size (1Gi)"), | ||
resp: &csi.ControllerExpandVolumeResponse{CapacityBytes: minimumVolumeSizeInBytes, NodeExpansionRequired: true}, | ||
err: nil, | ||
}, | ||
{ | ||
name: "volume for corresponding volume id does not exist", | ||
name: "volume for corresponding volume id does not exist", | ||
godo_volume: default_volume, | ||
req: &csi.ControllerExpandVolumeRequest{ | ||
VolumeId: "non-existent-id", | ||
CapacityRange: &csi.CapacityRange{ | ||
|
@@ -221,7 +232,8 @@ func TestControllerExpandVolume(t *testing.T) { | |
err: status.Error(codes.Internal, "ControllerExpandVolume could not retrieve existing volume: volume not found"), | ||
}, | ||
{ | ||
name: "new volume size is less than old volume size", | ||
name: "new volume size is less than old volume size", | ||
godo_volume: default_volume, | ||
req: &csi.ControllerExpandVolumeRequest{ | ||
VolumeId: "volume-id", | ||
CapacityRange: &csi.CapacityRange{ | ||
|
@@ -232,7 +244,8 @@ func TestControllerExpandVolume(t *testing.T) { | |
err: nil, | ||
}, | ||
{ | ||
name: "new volume size is equal to old volume size", | ||
name: "new volume size is equal to old volume size", | ||
godo_volume: default_volume, | ||
req: &csi.ControllerExpandVolumeRequest{ | ||
VolumeId: "volume-id", | ||
CapacityRange: &csi.CapacityRange{ | ||
|
@@ -245,20 +258,16 @@ func TestControllerExpandVolume(t *testing.T) { | |
} | ||
for _, tc := range tcs { | ||
t.Run(tc.name, func(t *testing.T) { | ||
volume := &godo.Volume{ | ||
ID: "volume-id", | ||
SizeGigaBytes: (defaultVolumeSizeInBytes / giB), | ||
} | ||
driver := &Driver{ | ||
region: "foo", | ||
storage: &fakeStorageDriver{ | ||
volumes: map[string]*godo.Volume{ | ||
"volume-id": volume, | ||
"volume-id": tc.godo_volume, | ||
}, | ||
}, | ||
storageActions: &fakeStorageActionsDriver{ | ||
volumes: map[string]*godo.Volume{ | ||
"volume-id": volume, | ||
"volume-id": tc.godo_volume, | ||
}, | ||
}, | ||
log: logrus.New().WithField("test_enabed", true), | ||
|
@@ -268,7 +277,7 @@ func TestControllerExpandVolume(t *testing.T) { | |
assert.Equal(t, err, tc.err) | ||
} else { | ||
assert.Equal(t, tc.resp, resp) | ||
assert.Equal(t, (volume.SizeGigaBytes * giB), resp.CapacityBytes) | ||
assert.Equal(t, (tc.godo_volume.SizeGigaBytes * giB), resp.CapacityBytes) | ||
} | ||
|
||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's say "minimum volume size" to not give the impression that
minimumVolumeSizeBytes
is a known value from the CSI spec (whichrequiredBytes
is only).