-
Notifications
You must be signed in to change notification settings - Fork 151
Controller: cleaning up e2e tests #51
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 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 |
---|---|---|
|
@@ -216,7 +216,6 @@ var _ = Describe("CreateVolume [Controller Server]", func() { | |
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
|
||
// Pending fix in mock file | ||
It("should return appropriate values SingleNodeWriter WithCapacity 1Gi Type:Mount", func() { | ||
|
||
By("creating a volume") | ||
|
@@ -240,12 +239,20 @@ var _ = Describe("CreateVolume [Controller Server]", func() { | |
RequiredBytes: size, | ||
}, | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(vol).NotTo(BeNil()) | ||
Expect(vol.GetVolume()).NotTo(BeNil()) | ||
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) | ||
Expect(vol.GetVolume().GetCapacityBytes()).To(Equal(size)) | ||
if serverError, ok := status.FromError(err); ok { | ||
if serverError.Code() == codes.OutOfRange || serverError.Code() == codes.Unimplemented { | ||
Skip("Required bytes not supported") | ||
} else { | ||
Expect(err).NotTo(HaveOccurred()) | ||
} | ||
} else { | ||
|
||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(vol).NotTo(BeNil()) | ||
Expect(vol.GetVolume()).NotTo(BeNil()) | ||
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty()) | ||
Expect(vol.GetVolume().GetCapacityBytes()).To(Equal(size)) | ||
} | ||
By("cleaning up deleting the volume") | ||
_, err = c.DeleteVolume( | ||
context.Background(), | ||
|
@@ -254,6 +261,154 @@ var _ = Describe("CreateVolume [Controller Server]", func() { | |
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
It("should not fail when requesting to create a volume with already exisiting name and same capacity.", func() { | ||
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. This looks good, but the only thing is that an error may be returned if the driver does not support 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. @lpabon thanks a lot for your review, I will address it. 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. done |
||
|
||
By("creating a volume") | ||
name := "sanity" | ||
size := int64(1 * 1024 * 1024 * 1024) | ||
vol1, err := c.CreateVolume( | ||
context.Background(), | ||
&csi.CreateVolumeRequest{ | ||
Name: name, | ||
VolumeCapabilities: []*csi.VolumeCapability{ | ||
{ | ||
AccessType: &csi.VolumeCapability_Mount{ | ||
Mount: &csi.VolumeCapability_MountVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: size, | ||
}, | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(vol1).NotTo(BeNil()) | ||
Expect(vol1.GetVolume()).NotTo(BeNil()) | ||
Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty()) | ||
Expect(vol1.GetVolume().GetCapacityBytes()).To(Equal(size)) | ||
vol2, err := c.CreateVolume( | ||
context.Background(), | ||
&csi.CreateVolumeRequest{ | ||
Name: name, | ||
VolumeCapabilities: []*csi.VolumeCapability{ | ||
{ | ||
AccessType: &csi.VolumeCapability_Mount{ | ||
Mount: &csi.VolumeCapability_MountVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: size, | ||
}, | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
Expect(vol2).NotTo(BeNil()) | ||
Expect(vol2.GetVolume()).NotTo(BeNil()) | ||
Expect(vol2.GetVolume().GetId()).NotTo(BeEmpty()) | ||
Expect(vol2.GetVolume().GetCapacityBytes()).To(Equal(size)) | ||
Expect(vol1.GetVolume().GetId()).To(Equal(vol2.GetVolume().GetId())) | ||
|
||
By("cleaning up deleting the volume") | ||
_, err = c.DeleteVolume( | ||
context.Background(), | ||
&csi.DeleteVolumeRequest{ | ||
VolumeId: vol1.GetVolume().GetId(), | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
It("should fail when requesting to create a volume with already exisiting name and different capacity.", func() { | ||
|
||
By("creating a volume") | ||
name := "sanity" | ||
size1 := int64(1 * 1024 * 1024 * 1024) | ||
vol1, err := c.CreateVolume( | ||
context.Background(), | ||
&csi.CreateVolumeRequest{ | ||
Name: name, | ||
VolumeCapabilities: []*csi.VolumeCapability{ | ||
{ | ||
AccessType: &csi.VolumeCapability_Mount{ | ||
Mount: &csi.VolumeCapability_MountVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: size1, | ||
}, | ||
}) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(vol1).NotTo(BeNil()) | ||
Expect(vol1.GetVolume()).NotTo(BeNil()) | ||
Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty()) | ||
size2 := int64(2 * 1024 * 1024 * 1024) | ||
_, err = c.CreateVolume( | ||
context.Background(), | ||
&csi.CreateVolumeRequest{ | ||
Name: name, | ||
VolumeCapabilities: []*csi.VolumeCapability{ | ||
{ | ||
AccessType: &csi.VolumeCapability_Mount{ | ||
Mount: &csi.VolumeCapability_MountVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: size2, | ||
}, | ||
}) | ||
Expect(err).To(HaveOccurred()) | ||
serverError, ok := status.FromError(err) | ||
Expect(ok).To(BeTrue()) | ||
Expect(serverError.Code()).To(Equal(codes.AlreadyExists)) | ||
|
||
By("cleaning up deleting the volume") | ||
_, err = c.DeleteVolume( | ||
context.Background(), | ||
&csi.DeleteVolumeRequest{ | ||
VolumeId: vol1.GetVolume().GetId(), | ||
}) | ||
Expect(err).NotTo(HaveOccurred()) | ||
}) | ||
It("should fail when requesting to create a volume exceeding Maximum Capacity", func() { | ||
|
||
By("creating a volume") | ||
name := "sanity" | ||
size := int64(10 * 1024 * 1024 * 1024 * 1024) | ||
_, err := c.CreateVolume( | ||
context.Background(), | ||
&csi.CreateVolumeRequest{ | ||
Name: name, | ||
VolumeCapabilities: []*csi.VolumeCapability{ | ||
{ | ||
AccessType: &csi.VolumeCapability_Mount{ | ||
Mount: &csi.VolumeCapability_MountVolume{}, | ||
}, | ||
AccessMode: &csi.VolumeCapability_AccessMode{ | ||
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER, | ||
}, | ||
}, | ||
}, | ||
CapacityRange: &csi.CapacityRange{ | ||
RequiredBytes: size, | ||
}, | ||
}) | ||
Expect(err).To(HaveOccurred()) | ||
serverError, ok := status.FromError(err) | ||
Expect(ok).To(BeTrue()) | ||
Expect(serverError.Code()).To(Equal(codes.OutOfRange)) | ||
}) | ||
}) | ||
|
||
var _ = Describe("DeleteVolume [Controller Server]", func() { | ||
|
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.
👍