-
Notifications
You must be signed in to change notification settings - Fork 807
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
NodeExpandVolume no-op for raw block #695
Changes from all commits
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 |
---|---|---|
|
@@ -1082,6 +1082,92 @@ func TestNodePublishVolume(t *testing.T) { | |
t.Run(tc.name, tc.testFunc) | ||
} | ||
} | ||
func TestNodeExpandVolume(t *testing.T) { | ||
mockCtl := gomock.NewController(t) | ||
defer mockCtl.Finish() | ||
|
||
mockMetadata := mocks.NewMockMetadataService(mockCtl) | ||
mockMounter := mocks.NewMockMounter(mockCtl) | ||
|
||
awsDriver := &nodeService{ | ||
metadata: mockMetadata, | ||
mounter: mockMounter, | ||
inFlight: internal.NewInFlight(), | ||
} | ||
|
||
tests := []struct { | ||
name string | ||
request csi.NodeExpandVolumeRequest | ||
expectResponseCode codes.Code | ||
}{ | ||
{ | ||
name: "fail missing volumeId", | ||
request: csi.NodeExpandVolumeRequest{}, | ||
expectResponseCode: codes.InvalidArgument, | ||
}, | ||
{ | ||
name: "fail missing volumePath", | ||
request: csi.NodeExpandVolumeRequest{ | ||
StagingTargetPath: "/testDevice/Path", | ||
VolumeId: "test-volume-id", | ||
}, | ||
expectResponseCode: codes.InvalidArgument, | ||
}, | ||
{ | ||
name: "fail volume path not exist", | ||
request: csi.NodeExpandVolumeRequest{ | ||
VolumePath: "./test", | ||
VolumeId: "test-volume-id", | ||
}, | ||
expectResponseCode: codes.Internal, | ||
}, | ||
{ | ||
name: "Fail validate VolumeCapability", | ||
request: csi.NodeExpandVolumeRequest{ | ||
VolumePath: "./test", | ||
VolumeId: "test-volume-id", | ||
VolumeCapability: &csi.VolumeCapability{ | ||
AccessType: &csi.VolumeCapability_Block{ | ||
Block: &csi.VolumeCapability_BlockVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_UNKNOWN, | ||
}, | ||
}, | ||
}, | ||
expectResponseCode: codes.InvalidArgument, | ||
}, | ||
{ | ||
name: "Success [VolumeCapability is block]", | ||
request: csi.NodeExpandVolumeRequest{ | ||
VolumePath: "./test", | ||
VolumeId: "test-volume-id", | ||
VolumeCapability: &csi.VolumeCapability{ | ||
AccessType: &csi.VolumeCapability_Block{ | ||
Block: &csi.VolumeCapability_BlockVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
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. Can we use 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 tried to use losetup and dd to create loop device when setup testing but with no luck. It failed to find an available loop device when I ran it in linux instance.. This should not be a blocker as I tested the functionality e2e on the cluster. Testing code is here, I will follow up on this later. 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'm going to approve to unblock you, but yeah let's follow up. |
||
expectResponseCode: codes.OK, | ||
}, | ||
} | ||
|
||
for _, test := range tests { | ||
t.Run(test.name, func(t *testing.T) { | ||
_, err := awsDriver.NodeExpandVolume(context.Background(), &test.request) | ||
if err != nil { | ||
if test.expectResponseCode != codes.OK { | ||
expectErr(t, err, test.expectResponseCode) | ||
} else { | ||
t.Fatalf("Expect no error but got: %v", err) | ||
} | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func TestNodeUnpublishVolume(t *testing.T) { | ||
targetPath := "/test/path" | ||
|
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.
So prior to this PR, we don't have this requirement (at least here). We have to make sure this is not a breaking change. Did we verify that behavior stays the same when volumePath is absent?
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.
volume_path is required, so we should be fine I think.
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.
Yeah, as per https://github.com/kubernetes-sigs/aws-ebs-csi-driver/blob/master/vendor/github.com/container-storage-interface/spec/lib/go/csi/csi.pb.go#L4322
I think we should have this check