Update vendor csi spec and csi-test to 1.0.0-rc2

This commit is contained in:
Michelle Au
2018-11-14 13:27:37 -08:00
parent 92f87c14e7
commit 9be7a7dd24
42 changed files with 2674 additions and 1964 deletions

View File

@@ -39,13 +39,13 @@ var _ = Describe("MyCSIDriver", func () {
Context("Config A", func () {
var config &sanity.Config
BeforeEach() {
... setup driver and config...
}
BeforeEach(func() {
//... setup driver and config...
})
AfterEach() {
...tear down driver...
}
AfterEach(func() {
//...tear down driver...
})
Describe("CSI sanity", func() {
sanity.GinkgoTest(config)
@@ -53,7 +53,7 @@ var _ = Describe("MyCSIDriver", func () {
})
Context("Config B", func () {
...
// other configs
})
})
```

View File

@@ -20,7 +20,7 @@ import (
"context"
"log"
"github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
. "github.com/onsi/ginkgo"
)
@@ -61,8 +61,8 @@ func (cl *Cleanup) RegisterVolume(name string, info VolumeInfo) {
// MaybeRegisterVolume adds or updates an entry for the volume with
// the given name if CreateVolume was successful.
func (cl *Cleanup) MaybeRegisterVolume(name string, vol *csi.CreateVolumeResponse, err error) {
if err == nil && vol.GetVolume().GetId() != "" {
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
if err == nil && vol.GetVolume().GetVolumeId() != "" {
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
}
}
@@ -112,7 +112,7 @@ func (cl *Cleanup) DeleteVolumes() {
&csi.ControllerUnpublishVolumeRequest{
VolumeId: info.VolumeID,
NodeId: info.NodeID,
ControllerUnpublishSecrets: cl.Context.Secrets.ControllerUnpublishVolumeSecret,
Secrets: cl.Context.Secrets.ControllerUnpublishVolumeSecret,
},
); err != nil {
logger.Printf("warning: ControllerUnpublishVolume: %s", err)
@@ -122,8 +122,8 @@ func (cl *Cleanup) DeleteVolumes() {
if _, err := cl.ControllerClient.DeleteVolume(
ctx,
&csi.DeleteVolumeRequest{
VolumeId: info.VolumeID,
ControllerDeleteSecrets: cl.Context.Secrets.DeleteVolumeSecret,
VolumeId: info.VolumeID,
Secrets: cl.Context.Secrets.DeleteVolumeSecret,
},
); err != nil {
logger.Printf("error: DeleteVolume: %s", err)

View File

@@ -23,11 +23,12 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
"strconv"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"strconv"
)
const (
@@ -35,6 +36,8 @@ const (
// provisioned volumes. 10GB by default, can be overridden by
// setting Config.TestVolumeSize.
DefTestVolumeSize int64 = 10 * 1024 * 1024 * 1024
MaxNameLength int = 128
)
func TestVolumeSize(sc *SanityContext) int64 {
@@ -46,14 +49,14 @@ func TestVolumeSize(sc *SanityContext) int64 {
func verifyVolumeInfo(v *csi.Volume) {
Expect(v).NotTo(BeNil())
Expect(v.GetId()).NotTo(BeEmpty())
Expect(v.GetVolumeId()).NotTo(BeEmpty())
}
func verifySnapshotInfo(snapshot *csi.Snapshot) {
Expect(snapshot).NotTo(BeNil())
Expect(snapshot.GetId()).NotTo(BeEmpty())
Expect(snapshot.GetSnapshotId()).NotTo(BeEmpty())
Expect(snapshot.GetSourceVolumeId()).NotTo(BeEmpty())
Expect(snapshot.GetCreatedAt()).NotTo(BeZero())
Expect(snapshot.GetCreationTime()).NotTo(BeZero())
}
func isControllerCapabilitySupported(
@@ -182,7 +185,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
cl.MaybeRegisterVolume("", vol, err)
@@ -198,8 +202,9 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
vol, err := c.CreateVolume(
context.Background(),
&csi.CreateVolumeRequest{
Name: name,
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Name: name,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
cl.MaybeRegisterVolume(name, vol, err)
@@ -229,22 +234,23 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
By("cleaning up deleting the volume")
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -273,7 +279,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
CapacityRange: &csi.CapacityRange{
RequiredBytes: TestVolumeSize(sc),
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
if serverError, ok := status.FromError(err); ok &&
@@ -283,8 +290,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", TestVolumeSize(sc)))
By("cleaning up deleting the volume")
@@ -292,14 +299,14 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.UnregisterVolume(name)
})
It("should not fail when requesting to create a volume with already exisiting name and same capacity.", func() {
It("should not fail when requesting to create a volume with already existing name and same capacity.", func() {
By("creating a volume")
name := uniqueString("sanity-controller-create-twice")
@@ -322,14 +329,15 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
CapacityRange: &csi.CapacityRange{
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol1).NotTo(BeNil())
Expect(vol1.GetVolume()).NotTo(BeNil())
Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetId()})
Expect(vol1.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetVolumeId()})
Expect(vol1.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
vol2, err := c.CreateVolume(
@@ -349,29 +357,30 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
CapacityRange: &csi.CapacityRange{
RequiredBytes: size,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol2).NotTo(BeNil())
Expect(vol2.GetVolume()).NotTo(BeNil())
Expect(vol2.GetVolume().GetId()).NotTo(BeEmpty())
Expect(vol2.GetVolume().GetVolumeId()).NotTo(BeEmpty())
Expect(vol2.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
Expect(vol1.GetVolume().GetId()).To(Equal(vol2.GetVolume().GetId()))
Expect(vol1.GetVolume().GetVolumeId()).To(Equal(vol2.GetVolume().GetVolumeId()))
By("cleaning up deleting the volume")
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol1.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol1.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.UnregisterVolume(name)
})
It("should fail when requesting to create a volume with already exisiting name and different capacity.", func() {
It("should fail when requesting to create a volume with already existing name and different capacity.", func() {
By("creating a volume")
name := uniqueString("sanity-controller-create-twice-different")
@@ -395,14 +404,15 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: size1,
LimitBytes: size1,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).ToNot(HaveOccurred())
Expect(vol1).NotTo(BeNil())
Expect(vol1.GetVolume()).NotTo(BeNil())
Expect(vol1.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetId()})
Expect(vol1.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol1.GetVolume().GetVolumeId()})
size2 := 2 * TestVolumeSize(sc)
_, err = c.CreateVolume(
@@ -423,7 +433,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
RequiredBytes: size2,
LimitBytes: size2,
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).To(HaveOccurred())
@@ -436,8 +447,59 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol1.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol1.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.UnregisterVolume(name)
})
It("should not fail when creating volume with maximum-length name", func() {
nameBytes := make([]byte, MaxNameLength)
for i := 0; i < MaxNameLength; i++ {
nameBytes[i] = 'a'
}
name := string(nameBytes)
By("creating a volume")
size := TestVolumeSize(sc)
vol, 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,
},
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
Expect(vol.GetVolume().GetCapacityBytes()).To(BeNumerically(">=", size))
By("cleaning up deleting the volume")
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -457,7 +519,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err := c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -472,8 +534,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err := c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: "reallyfakevolumeid",
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: "reallyfakevolumeid",
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -499,14 +561,15 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
// Delete Volume
By("deleting a volume")
@@ -514,8 +577,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -570,21 +633,22 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
// ValidateVolumeCapabilities
By("validating volume capabilities")
valivolcap, err := c.ValidateVolumeCapabilities(
context.Background(),
&csi.ValidateVolumeCapabilitiesRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
VolumeCapabilities: []*csi.VolumeCapability{
{
AccessType: &csi.VolumeCapability_Mount{
@@ -598,15 +662,20 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
})
Expect(err).NotTo(HaveOccurred())
Expect(valivolcap).NotTo(BeNil())
Expect(valivolcap.GetSupported()).To(BeTrue())
// If confirmation is provided then it is REQUIRED to provide
// the volume capabilities
if valivolcap.GetConfirmed() != nil {
Expect(valivolcap.GetConfirmed().GetVolumeCapabilities()).NotTo(BeEmpty())
}
By("cleaning up deleting the volume")
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -651,7 +720,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -666,8 +735,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: "id",
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
VolumeId: "id",
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -684,7 +753,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
&csi.ControllerPublishVolumeRequest{
VolumeId: "id",
NodeId: "fakenode",
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -714,19 +783,20 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
By("getting a node id")
nid, err := n.NodeGetId(
nid, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetIdRequest{})
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())
@@ -737,7 +807,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conpubvol, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
@@ -747,12 +817,12 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())
By("cleaning up unpublishing the volume")
@@ -760,10 +830,10 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conunpubvol, err := c.ControllerUnpublishVolume(
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
// NodeID is optional in ControllerUnpublishVolume
NodeId: nid.GetNodeId(),
ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret,
NodeId: nid.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -774,8 +844,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -799,8 +869,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -831,14 +901,15 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
// ControllerPublishVolume
By("calling controllerpublish on that volume")
@@ -846,7 +917,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conpubvol, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: "some-fake-node-id",
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
@@ -856,8 +927,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -872,8 +943,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -900,19 +971,20 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
By("getting a node id")
nid, err := n.NodeGetId(
nid, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetIdRequest{})
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())
@@ -921,7 +993,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
By("calling controllerpublish on that volume")
pubReq := &csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
@@ -931,8 +1003,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
}
conpubvol, err := c.ControllerPublishVolume(context.Background(), pubReq)
@@ -955,10 +1027,10 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conunpubvol, err := c.ControllerUnpublishVolume(
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
// NodeID is optional in ControllerUnpublishVolume
NodeId: nid.GetNodeId(),
ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret,
NodeId: nid.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
@@ -970,8 +1042,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -991,7 +1063,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err := c.ControllerUnpublishVolume(
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret,
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -1021,19 +1093,20 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
Parameters: sc.Config.TestVolumeParameters,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
By("getting a node id")
nid, err := n.NodeGetId(
nid, err := n.NodeGetInfo(
context.Background(),
&csi.NodeGetIdRequest{})
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())
@@ -1044,7 +1117,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conpubvol, err := c.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
@@ -1054,12 +1127,12 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())
// ControllerUnpublishVolume
@@ -1068,10 +1141,10 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
conunpubvol, err := c.ControllerUnpublishVolume(
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
// NodeID is optional in ControllerUnpublishVolume
NodeId: nid.GetNodeId(),
ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret,
NodeId: nid.GetNodeId(),
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -1082,8 +1155,8 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) {
_, err = c.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -1125,28 +1198,28 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(err).NotTo(HaveOccurred())
By("creating a snapshot")
snapshotReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-1", volume.GetVolume().GetId(), nil)
snapshotReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-1", volume.GetVolume().GetVolumeId(), nil)
snapshot, err := c.CreateSnapshot(context.Background(), snapshotReq)
Expect(err).NotTo(HaveOccurred())
snapshots, err := c.ListSnapshots(
context.Background(),
&csi.ListSnapshotsRequest{SnapshotId: snapshot.GetSnapshot().GetId()})
&csi.ListSnapshotsRequest{SnapshotId: snapshot.GetSnapshot().GetSnapshotId()})
Expect(err).NotTo(HaveOccurred())
Expect(snapshots).NotTo(BeNil())
Expect(len(snapshots.GetEntries())).To(BeNumerically("==", 1))
verifySnapshotInfo(snapshots.GetEntries()[0].GetSnapshot())
Expect(snapshots.GetEntries()[0].GetSnapshot().GetId()).To(Equal(snapshot.GetSnapshot().GetId()))
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
Expect(snapshots.GetEntries()[0].GetSnapshot().GetSnapshotId()).To(Equal(snapshot.GetSnapshot().GetSnapshotId()))
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
It("should return empty when the specify snapshot id is not exist", func() {
@@ -1167,7 +1240,7 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(err).NotTo(HaveOccurred())
By("creating a snapshot")
snapshotReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-2", volume.GetVolume().GetId(), nil)
snapshotReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-2", volume.GetVolume().GetVolumeId(), nil)
snapshot, err := c.CreateSnapshot(context.Background(), snapshotReq)
Expect(err).NotTo(HaveOccurred())
@@ -1182,12 +1255,12 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
}
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
@@ -1202,46 +1275,6 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(snapshots.GetEntries()).To(BeEmpty())
})
It("should fail when an invalid starting_token is passed", func() {
vols, err := c.ListSnapshots(
context.Background(),
&csi.ListSnapshotsRequest{
StartingToken: "invalid-token",
},
)
Expect(err).To(HaveOccurred())
Expect(vols).To(BeNil())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.Aborted))
})
It("should fail when the starting_token is greater than total number of snapshots", func() {
// Get total number of snapshots.
snapshots, err := c.ListSnapshots(
context.Background(),
&csi.ListSnapshotsRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(snapshots).NotTo(BeNil())
totalSnapshots := len(snapshots.GetEntries())
// Send starting_token that is greater than the total number of snapshots.
snapshots, err = c.ListSnapshots(
context.Background(),
&csi.ListSnapshotsRequest{
StartingToken: strconv.Itoa(totalSnapshots + 5),
},
)
Expect(err).To(HaveOccurred())
Expect(snapshots).To(BeNil())
serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.Aborted))
})
It("check the presence of new snapshots in the snapshot list", func() {
// List Snapshots before creating new snapshots.
snapshots, err := c.ListSnapshots(
@@ -1258,7 +1291,7 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(err).NotTo(HaveOccurred())
By("creating a snapshot")
snapReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-3", volume.GetVolume().GetId(), nil)
snapReq := MakeCreateSnapshotReq(sc, "listSnapshots-snapshot-3", volume.GetVolume().GetVolumeId(), nil)
snapshot, err := c.CreateSnapshot(context.Background(), snapReq)
Expect(err).NotTo(HaveOccurred())
Expect(snapshot).NotTo(BeNil())
@@ -1272,12 +1305,12 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(len(snapshots.GetEntries())).To(Equal(totalSnapshots + 1))
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
@@ -1326,7 +1359,7 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
Expect(volume).NotTo(BeNil())
createVols = append(createVols, volume.GetVolume())
snapReq := MakeCreateSnapshotReq(sc, "snapshot"+strconv.Itoa(i), volume.GetVolume().GetId(), nil)
snapReq := MakeCreateSnapshotReq(sc, "snapshot"+strconv.Itoa(i), volume.GetVolume().GetVolumeId(), nil)
snapshot, err := c.CreateSnapshot(context.Background(), snapReq)
Expect(err).NotTo(HaveOccurred())
Expect(snapshot).NotTo(BeNil())
@@ -1349,7 +1382,6 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
nextToken := snapshots.GetNextToken()
Expect(nextToken).To(Equal(strconv.Itoa(maxEntries)))
Expect(len(snapshots.GetEntries())).To(Equal(maxEntries))
// Request list snapshots with starting_token and no max entries.
@@ -1369,7 +1401,7 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
By("cleaning up deleting the snapshots")
for _, snap := range createSnapshots {
delSnapReq := MakeDeleteSnapshotReq(sc, snap.GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snap.GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
}
@@ -1377,7 +1409,7 @@ var _ = DescribeSanity("ListSnapshots [Controller Server]", func(sc *SanityConte
By("cleaning up deleting the volumes")
for _, vol := range createVols {
delVolReq := MakeDeleteVolumeReq(sc, vol.GetId())
delVolReq := MakeDeleteVolumeReq(sc, vol.GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
}
@@ -1404,7 +1436,7 @@ var _ = DescribeSanity("DeleteSnapshot [Controller Server]", func(sc *SanityCont
req := &csi.DeleteSnapshotRequest{}
if sc.Secrets != nil {
req.DeleteSnapshotSecrets = sc.Secrets.DeleteSnapshotSecret
req.Secrets = sc.Secrets.DeleteSnapshotSecret
}
_, err := c.DeleteSnapshot(context.Background(), req)
@@ -1431,19 +1463,19 @@ var _ = DescribeSanity("DeleteSnapshot [Controller Server]", func(sc *SanityCont
// Create Snapshot First
By("creating a snapshot")
snapshotReq := MakeCreateSnapshotReq(sc, "DeleteSnapshot-snapshot-1", volume.GetVolume().GetId(), nil)
snapshotReq := MakeCreateSnapshotReq(sc, "DeleteSnapshot-snapshot-1", volume.GetVolume().GetVolumeId(), nil)
snapshot, err := c.CreateSnapshot(context.Background(), snapshotReq)
Expect(err).NotTo(HaveOccurred())
Expect(snapshot).NotTo(BeNil())
verifySnapshotInfo(snapshot.GetSnapshot())
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snapshot.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
@@ -1469,7 +1501,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
}
if sc.Secrets != nil {
req.CreateSnapshotSecrets = sc.Secrets.CreateSnapshotSecret
req.Secrets = sc.Secrets.CreateSnapshotSecret
}
_, err := c.CreateSnapshot(context.Background(), req)
@@ -1486,7 +1518,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
}
if sc.Secrets != nil {
req.CreateSnapshotSecrets = sc.Secrets.CreateSnapshotSecret
req.Secrets = sc.Secrets.CreateSnapshotSecret
}
_, err := c.CreateSnapshot(context.Background(), req)
@@ -1504,7 +1536,7 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
Expect(err).NotTo(HaveOccurred())
By("creating a snapshot")
snapReq1 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-1", volume.GetVolume().GetId(), nil)
snapReq1 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-1", volume.GetVolume().GetVolumeId(), nil)
snap1, err := c.CreateSnapshot(context.Background(), snapReq1)
Expect(err).NotTo(HaveOccurred())
Expect(snap1).NotTo(BeNil())
@@ -1516,12 +1548,12 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
verifySnapshotInfo(snap2.GetSnapshot())
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
@@ -1533,14 +1565,17 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
Expect(err).ToNot(HaveOccurred())
By("creating a snapshot with the created volume source id")
req1 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-2", volume.GetVolume().GetId(), nil)
req1 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-2", volume.GetVolume().GetVolumeId(), nil)
snap1, err := c.CreateSnapshot(context.Background(), req1)
Expect(err).NotTo(HaveOccurred())
Expect(snap1).NotTo(BeNil())
verifySnapshotInfo(snap1.GetSnapshot())
volume2, err := c.CreateVolume(context.Background(), MakeCreateVolumeReq(sc, "CreateSnapshot-volume-3"))
Expect(err).ToNot(HaveOccurred())
By("creating a snapshot with the same name but different volume source id")
req2 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-2", "test001", nil)
req2 := MakeCreateSnapshotReq(sc, "CreateSnapshot-snapshot-2", volume2.GetVolume().GetVolumeId(), nil)
_, err = c.CreateSnapshot(context.Background(), req2)
Expect(err).To(HaveOccurred())
serverError, ok := status.FromError(err)
@@ -1548,12 +1583,48 @@ var _ = DescribeSanity("CreateSnapshot [Controller Server]", func(sc *SanityCont
Expect(serverError.Code()).To(Equal(codes.AlreadyExists))
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetId())
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetId())
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
It("should not fail when creating snapshot with maximum-length name", func() {
By("creating a volume")
volReq := MakeCreateVolumeReq(sc, "CreateSnapshot-volume-3")
volume, err := c.CreateVolume(context.Background(), volReq)
Expect(err).NotTo(HaveOccurred())
nameBytes := make([]byte, MaxNameLength)
for i := 0; i < MaxNameLength; i++ {
nameBytes[i] = 'a'
}
name := string(nameBytes)
By("creating a snapshot")
snapReq1 := MakeCreateSnapshotReq(sc, name, volume.GetVolume().GetVolumeId(), nil)
snap1, err := c.CreateSnapshot(context.Background(), snapReq1)
Expect(err).NotTo(HaveOccurred())
Expect(snap1).NotTo(BeNil())
verifySnapshotInfo(snap1.GetSnapshot())
snap2, err := c.CreateSnapshot(context.Background(), snapReq1)
Expect(err).NotTo(HaveOccurred())
Expect(snap2).NotTo(BeNil())
verifySnapshotInfo(snap2.GetSnapshot())
By("cleaning up deleting the snapshot")
delSnapReq := MakeDeleteSnapshotReq(sc, snap1.GetSnapshot().GetSnapshotId())
_, err = c.DeleteSnapshot(context.Background(), delSnapReq)
Expect(err).NotTo(HaveOccurred())
By("cleaning up deleting the volume")
delVolReq := MakeDeleteVolumeReq(sc, volume.GetVolume().GetVolumeId())
_, err = c.DeleteVolume(context.Background(), delVolReq)
Expect(err).NotTo(HaveOccurred())
})
@@ -1578,10 +1649,11 @@ func MakeCreateVolumeReq(sc *SanityContext, name string) *csi.CreateVolumeReques
RequiredBytes: size1,
LimitBytes: size1,
},
Parameters: sc.Config.TestVolumeParameters,
}
if sc.Secrets != nil {
req.ControllerCreateSecrets = sc.Secrets.CreateVolumeSecret
req.Secrets = sc.Secrets.CreateVolumeSecret
}
return req
@@ -1595,7 +1667,7 @@ func MakeCreateSnapshotReq(sc *SanityContext, name, sourceVolumeId string, param
}
if sc.Secrets != nil {
req.CreateSnapshotSecrets = sc.Secrets.CreateSnapshotSecret
req.Secrets = sc.Secrets.CreateSnapshotSecret
}
return req
@@ -1607,7 +1679,7 @@ func MakeDeleteSnapshotReq(sc *SanityContext, id string) *csi.DeleteSnapshotRequ
}
if sc.Secrets != nil {
delSnapReq.DeleteSnapshotSecrets = sc.Secrets.DeleteSnapshotSecret
delSnapReq.Secrets = sc.Secrets.DeleteSnapshotSecret
}
return delSnapReq
@@ -1619,7 +1691,7 @@ func MakeDeleteVolumeReq(sc *SanityContext, id string) *csi.DeleteVolumeRequest
}
if sc.Secrets != nil {
delVolReq.ControllerDeleteSecrets = sc.Secrets.DeleteVolumeSecret
delVolReq.Secrets = sc.Secrets.DeleteVolumeSecret
}
return delVolReq

View File

@@ -24,7 +24,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -51,7 +51,7 @@ var _ = DescribeSanity("Identity Service", func(sc *SanityContext) {
for _, cap := range res.GetCapabilities() {
switch cap.GetService().GetType() {
case csi.PluginCapability_Service_CONTROLLER_SERVICE:
case csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS:
case csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS:
default:
Fail(fmt.Sprintf("Unknown capability: %v\n", cap.GetService().GetType()))
}

View File

@@ -23,7 +23,7 @@ import (
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"github.com/container-storage-interface/spec/lib/go/csi/v0"
"github.com/container-storage-interface/spec/lib/go/csi"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
@@ -119,6 +119,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
switch cap.GetRpc().GetType() {
case csi.NodeServiceCapability_RPC_UNKNOWN:
case csi.NodeServiceCapability_RPC_STAGE_UNSTAGE_VOLUME:
case csi.NodeServiceCapability_RPC_GET_VOLUME_STATS:
default:
Fail(fmt.Sprintf("Unknown capability: %v\n", cap.GetRpc().GetType()))
}
@@ -126,18 +127,6 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
})
})
Describe("NodeGetId", func() {
It("should return appropriate values", func() {
nid, err := c.NodeGetId(
context.Background(),
&csi.NodeGetIdRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())
})
})
Describe("NodeGetInfo", func() {
var (
i csi.IdentityClient
@@ -146,7 +135,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
BeforeEach(func() {
i = csi.NewIdentityClient(sc.Conn)
accessibilityConstraintSupported = isPluginCapabilitySupported(i, csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS)
accessibilityConstraintSupported = isPluginCapabilitySupported(i, csi.PluginCapability_Service_VOLUME_ACCESSIBILITY_CONSTRAINTS)
})
It("should return approproate values", func() {
@@ -170,7 +159,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
_, err := c.NodePublishVolume(
context.Background(),
&csi.NodePublishVolumeRequest{
NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret,
Secrets: sc.Secrets.NodePublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -184,8 +173,8 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
_, err := c.NodePublishVolume(
context.Background(),
&csi.NodePublishVolumeRequest{
VolumeId: "id",
NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret,
VolumeId: "id",
Secrets: sc.Secrets.NodePublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -199,9 +188,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
_, err := c.NodePublishVolume(
context.Background(),
&csi.NodePublishVolumeRequest{
VolumeId: "id",
TargetPath: sc.Config.TargetPath,
NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret,
VolumeId: "id",
TargetPath: sc.Config.TargetPath,
Secrets: sc.Secrets.NodePublishVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -266,10 +255,10 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
PublishInfo: map[string]string{
PublishContext: map[string]string{
"device": device,
},
NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret,
Secrets: sc.Secrets.NodeStageVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -292,10 +281,10 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
PublishInfo: map[string]string{
PublishContext: map[string]string{
"device": device,
},
NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret,
Secrets: sc.Secrets.NodeStageVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -311,10 +300,10 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
&csi.NodeStageVolumeRequest{
VolumeId: "id",
StagingTargetPath: sc.Config.StagingPath,
PublishInfo: map[string]string{
PublishContext: map[string]string{
"device": device,
},
NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret,
Secrets: sc.Secrets.NodeStageVolumeSecret,
},
)
Expect(err).To(HaveOccurred())
@@ -380,19 +369,19 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
},
},
},
ControllerCreateSecrets: sc.Secrets.CreateVolumeSecret,
Secrets: sc.Secrets.CreateVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
Expect(vol).NotTo(BeNil())
Expect(vol.GetVolume()).NotTo(BeNil())
Expect(vol.GetVolume().GetId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId()})
Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()})
By("getting a node id")
nid, err := c.NodeGetId(
nid, err := c.NodeGetInfo(
context.Background(),
&csi.NodeGetIdRequest{})
&csi.NodeGetInfoRequest{})
Expect(err).NotTo(HaveOccurred())
Expect(nid).NotTo(BeNil())
Expect(nid.GetNodeId()).NotTo(BeEmpty())
@@ -404,7 +393,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
conpubvol, err = s.ControllerPublishVolume(
context.Background(),
&csi.ControllerPublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
@@ -414,13 +403,13 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
VolumeAttributes: vol.GetVolume().GetAttributes(),
Readonly: false,
ControllerPublishSecrets: sc.Secrets.ControllerPublishVolumeSecret,
VolumeContext: vol.GetVolume().GetVolumeContext(),
Readonly: false,
Secrets: sc.Secrets.ControllerPublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetId(), NodeID: nid.GetNodeId()})
cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()})
Expect(conpubvol).NotTo(BeNil())
}
// NodeStageVolume
@@ -429,7 +418,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
nodestagevol, err := c.NodeStageVolume(
context.Background(),
&csi.NodeStageVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
VolumeCapability: &csi.VolumeCapability{
AccessType: &csi.VolumeCapability_Mount{
Mount: &csi.VolumeCapability_MountVolume{},
@@ -439,9 +428,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
},
},
StagingTargetPath: sc.Config.StagingPath,
VolumeAttributes: vol.GetVolume().GetAttributes(),
PublishInfo: conpubvol.GetPublishInfo(),
NodeStageSecrets: sc.Secrets.NodeStageVolumeSecret,
VolumeContext: vol.GetVolume().GetVolumeContext(),
PublishContext: conpubvol.GetPublishContext(),
Secrets: sc.Secrets.NodeStageVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -456,7 +445,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
nodepubvol, err := c.NodePublishVolume(
context.Background(),
&csi.NodePublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
TargetPath: sc.Config.TargetPath,
StagingTargetPath: stagingPath,
VolumeCapability: &csi.VolumeCapability{
@@ -467,9 +456,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
Mode: csi.VolumeCapability_AccessMode_SINGLE_NODE_WRITER,
},
},
VolumeAttributes: vol.GetVolume().GetAttributes(),
PublishInfo: conpubvol.GetPublishInfo(),
NodePublishSecrets: sc.Secrets.NodePublishVolumeSecret,
VolumeContext: vol.GetVolume().GetVolumeContext(),
PublishContext: conpubvol.GetPublishContext(),
Secrets: sc.Secrets.NodePublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -480,7 +469,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
nodeunpubvol, err := c.NodeUnpublishVolume(
context.Background(),
&csi.NodeUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
TargetPath: sc.Config.TargetPath,
})
Expect(err).NotTo(HaveOccurred())
@@ -491,7 +480,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
nodeunstagevol, err := c.NodeUnstageVolume(
context.Background(),
&csi.NodeUnstageVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
StagingTargetPath: sc.Config.StagingPath,
},
)
@@ -505,9 +494,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
controllerunpubvol, err := s.ControllerUnpublishVolume(
context.Background(),
&csi.ControllerUnpublishVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
VolumeId: vol.GetVolume().GetVolumeId(),
NodeId: nid.GetNodeId(),
ControllerUnpublishSecrets: sc.Secrets.ControllerUnpublishVolumeSecret,
Secrets: sc.Secrets.ControllerUnpublishVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())
@@ -519,8 +508,8 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) {
_, err = s.DeleteVolume(
context.Background(),
&csi.DeleteVolumeRequest{
VolumeId: vol.GetVolume().GetId(),
ControllerDeleteSecrets: sc.Secrets.DeleteVolumeSecret,
VolumeId: vol.GetVolume().GetVolumeId(),
Secrets: sc.Secrets.DeleteVolumeSecret,
},
)
Expect(err).NotTo(HaveOccurred())

View File

@@ -47,11 +47,14 @@ type CSISecrets struct {
// Config provides the configuration for the sanity tests. It
// needs to be initialized by the user of the sanity package.
type Config struct {
TargetPath string
StagingPath string
Address string
SecretsFile string
TestVolumeSize int64
TargetPath string
StagingPath string
Address string
SecretsFile string
TestVolumeSize int64
TestVolumeParametersFile string
TestVolumeParameters map[string]string
}
// SanityContext holds the variables that each test can depend on. It
@@ -60,11 +63,25 @@ type SanityContext struct {
Config *Config
Conn *grpc.ClientConn
Secrets *CSISecrets
connAddress string
}
// Test will test the CSI driver at the specified address by
// setting up a Ginkgo suite and running it.
func Test(t *testing.T, reqConfig *Config) {
path := reqConfig.TestVolumeParametersFile
if len(path) != 0 {
yamlFile, err := ioutil.ReadFile(path)
if err != nil {
panic(fmt.Sprintf("failed to read file %q: %v", path, err))
}
err = yaml.Unmarshal(yamlFile, &reqConfig.TestVolumeParameters)
if err != nil {
panic(fmt.Sprintf("error unmarshaling yaml: %v", err))
}
}
sc := &SanityContext{
Config: reqConfig,
}
@@ -92,9 +109,17 @@ func (sc *SanityContext) setup() {
sc.Secrets = &CSISecrets{}
}
By("connecting to CSI driver")
sc.Conn, err = utils.Connect(sc.Config.Address)
Expect(err).NotTo(HaveOccurred())
// It is possible that a test sets sc.Config.Address
// dynamically (and differently!) in a BeforeEach, so only
// reuse the connection if the address is still the same.
if sc.Conn == nil || sc.connAddress != sc.Config.Address {
By("connecting to CSI driver")
sc.Conn, err = utils.Connect(sc.Config.Address)
Expect(err).NotTo(HaveOccurred())
sc.connAddress = sc.Config.Address
} else {
By(fmt.Sprintf("reusing connection to CSI driver at %s", sc.connAddress))
}
By("creating mount and staging directories")
err = createMountTargetLocation(sc.Config.TargetPath)
@@ -106,10 +131,16 @@ func (sc *SanityContext) setup() {
}
func (sc *SanityContext) teardown() {
if sc.Conn != nil {
sc.Conn.Close()
sc.Conn = nil
}
// We intentionally do not close the connection to the CSI
// driver here because the large amount of connection attempts
// caused test failures
// (https://github.com/kubernetes-csi/csi-test/issues/101). We
// could fix this with retries
// (https://github.com/kubernetes-csi/csi-test/pull/97) but
// that requires more discussion, so instead we just connect
// once per process instead of once per test case. This was
// also said to be faster
// (https://github.com/kubernetes-csi/csi-test/pull/98).
}
func createMountTargetLocation(targetPath string) error {