Skip to content

Commit

Permalink
Added test volume size constant, fixed 'should fail when requesting t…
Browse files Browse the repository at this point in the history
…o create a volume with already exisiting name and different capacity.' to have stricter size requests. Previously because only request was defined, first call could have resulted in a larger provisioned disk
  • Loading branch information
davidz627 committed Apr 5, 2018
1 parent 519692d commit c50849c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ import (
. "github.com/onsi/gomega"
)

const (
TestVolumeSize = 10 * 1024 * 1024 * 1024
)

func verifyVolumeInfo(v *csi.Volume) {
Expect(v).NotTo(BeNil())
Expect(v.GetId()).NotTo(BeEmpty())
Expand Down Expand Up @@ -220,7 +224,6 @@ var _ = Describe("CreateVolume [Controller Server]", func() {

By("creating a volume")
name := "sanity"
size := int64(1 * 1024 * 1024 * 1024)
vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand All @@ -236,7 +239,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {
},
},
CapacityRange: &csi.CapacityRange{
RequiredBytes: size,
RequiredBytes: TestVolumeSize,
},
})
if serverError, ok := status.FromError(err); ok {
Expand All @@ -251,7 +254,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize))
}
By("cleaning up deleting the volume")
_, err = c.DeleteVolume(
Expand All @@ -265,7 +268,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {

By("creating a volume")
name := "sanity"
size := int64(1 * 1024 * 1024 * 1024)
size := int64(TestVolumeSize)
vol1, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand Down Expand Up @@ -326,7 +329,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {

By("creating a volume")
name := "sanity"
size1 := int64(1 * 1024 * 1024 * 1024)
size1 := int64(TestVolumeSize)
vol1, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand All @@ -343,13 +346,14 @@ var _ = Describe("CreateVolume [Controller Server]", func() {
},
CapacityRange: &csi.CapacityRange{
RequiredBytes: size1,
LimitBytes: 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)
size2 := int64(2 * TestVolumeSize)
_, err = c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Expand All @@ -366,6 +370,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {
},
CapacityRange: &csi.CapacityRange{
RequiredBytes: size2,
LimitBytes: size2,
},
})
Expect(err).To(HaveOccurred())
Expand Down

0 comments on commit c50849c

Please sign in to comment.