diff --git a/pkg/sanity/controller.go b/pkg/sanity/controller.go index 53732745..8fe27c54 100644 --- a/pkg/sanity/controller.go +++ b/pkg/sanity/controller.go @@ -1119,8 +1119,26 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(serverError.Code()).To(Equal(codes.InvalidArgument)) }) + // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform + // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported It("should return appropriate values (no optional values added)", func() { + By("getting node information") + ni, err := n.NodeGetInfo( + context.Background(), + &csi.NodeGetInfoRequest{}) + Expect(err).NotTo(HaveOccurred()) + Expect(ni).NotTo(BeNil()) + Expect(ni.GetNodeId()).NotTo(BeEmpty()) + + var accReqs *csi.TopologyRequirement + if ni.AccessibleTopology != nil { + // Topology requirements are honored if provided by the driver + accReqs = &csi.TopologyRequirement{ + Requisite: []*csi.Topology{ni.AccessibleTopology}, + } + } + // Create Volume First By("creating a single node writer volume") name := UniqueString("sanity-controller-publish") @@ -1139,8 +1157,9 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, }, }, - Secrets: sc.Secrets.CreateVolumeSecret, - Parameters: sc.Config.TestVolumeParameters, + Secrets: sc.Secrets.CreateVolumeSecret, + Parameters: sc.Config.TestVolumeParameters, + AccessibilityRequirements: accReqs, }, ) Expect(err).NotTo(HaveOccurred()) @@ -1149,14 +1168,6 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()}) - By("getting a node id") - nid, err := n.NodeGetInfo( - context.Background(), - &csi.NodeGetInfoRequest{}) - Expect(err).NotTo(HaveOccurred()) - Expect(nid).NotTo(BeNil()) - Expect(nid.GetNodeId()).NotTo(BeEmpty()) - // ControllerPublishVolume By("calling controllerpublish on that volume") @@ -1164,7 +1175,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { context.Background(), &csi.ControllerPublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), VolumeCapability: &csi.VolumeCapability{ AccessType: &csi.VolumeCapability_Mount{ Mount: &csi.VolumeCapability_MountVolume{}, @@ -1178,7 +1189,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) - cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()}) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()}) Expect(conpubvol).NotTo(BeNil()) By("cleaning up unpublishing the volume") @@ -1188,7 +1199,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { &csi.ControllerUnpublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), // NodeID is optional in ControllerUnpublishVolume - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), Secrets: sc.Secrets.ControllerUnpublishVolumeSecret, }, ) @@ -1474,12 +1485,30 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(serverError.Code()).To(Equal(codes.InvalidArgument)) }) + // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform + // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported It("should return appropriate values (no optional values added)", func() { // Create Volume First By("creating a single node writer volume") name := UniqueString("sanity-controller-unpublish") + By("getting node information") + ni, err := n.NodeGetInfo( + context.Background(), + &csi.NodeGetInfoRequest{}) + Expect(err).NotTo(HaveOccurred()) + Expect(ni).NotTo(BeNil()) + Expect(ni.GetNodeId()).NotTo(BeEmpty()) + + var accReqs *csi.TopologyRequirement + if ni.AccessibleTopology != nil { + // Topology requirements are honored if provided by the driver + accReqs = &csi.TopologyRequirement{ + Requisite: []*csi.Topology{ni.AccessibleTopology}, + } + } + vol, err := c.CreateVolume( context.Background(), &csi.CreateVolumeRequest{ @@ -1494,8 +1523,9 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, }, }, - Secrets: sc.Secrets.CreateVolumeSecret, - Parameters: sc.Config.TestVolumeParameters, + Secrets: sc.Secrets.CreateVolumeSecret, + Parameters: sc.Config.TestVolumeParameters, + AccessibilityRequirements: accReqs, }, ) Expect(err).NotTo(HaveOccurred()) @@ -1504,14 +1534,6 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()}) - By("getting a node id") - nid, err := n.NodeGetInfo( - context.Background(), - &csi.NodeGetInfoRequest{}) - Expect(err).NotTo(HaveOccurred()) - Expect(nid).NotTo(BeNil()) - Expect(nid.GetNodeId()).NotTo(BeEmpty()) - // ControllerPublishVolume By("calling controllerpublish on that volume") @@ -1519,7 +1541,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { context.Background(), &csi.ControllerPublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), VolumeCapability: &csi.VolumeCapability{ AccessType: &csi.VolumeCapability_Mount{ Mount: &csi.VolumeCapability_MountVolume{}, @@ -1533,7 +1555,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) - cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()}) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()}) Expect(conpubvol).NotTo(BeNil()) // ControllerUnpublishVolume @@ -1544,7 +1566,7 @@ var _ = DescribeSanity("Controller Service", func(sc *SanityContext) { &csi.ControllerUnpublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), // NodeID is optional in ControllerUnpublishVolume - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), Secrets: sc.Secrets.ControllerUnpublishVolumeSecret, }, ) diff --git a/pkg/sanity/node.go b/pkg/sanity/node.go index f4ceddcd..c0d69d8b 100644 --- a/pkg/sanity/node.go +++ b/pkg/sanity/node.go @@ -622,9 +622,27 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { }) + // CSI spec poses no specific requirements for the cluster/storage setups that a SP MUST support. To perform + // meaningful checks the following test assumes that topology-aware provisioning on a single node setup is supported It("should work", func() { name := UniqueString("sanity-node-full") + By("getting node information") + ni, err := c.NodeGetInfo( + context.Background(), + &csi.NodeGetInfoRequest{}) + Expect(err).NotTo(HaveOccurred()) + Expect(ni).NotTo(BeNil()) + Expect(ni.GetNodeId()).NotTo(BeEmpty()) + + var accReqs *csi.TopologyRequirement + if ni.AccessibleTopology != nil { + // Topology requirements are honored if provided by the driver + accReqs = &csi.TopologyRequirement{ + Requisite: []*csi.Topology{ni.AccessibleTopology}, + } + } + // Create Volume First By("creating a single node writer volume") vol, err := s.CreateVolume( @@ -641,8 +659,9 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { }, }, }, - Secrets: sc.Secrets.CreateVolumeSecret, - Parameters: sc.Config.TestVolumeParameters, + Secrets: sc.Secrets.CreateVolumeSecret, + Parameters: sc.Config.TestVolumeParameters, + AccessibilityRequirements: accReqs, }, ) Expect(err).NotTo(HaveOccurred()) @@ -651,14 +670,6 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { Expect(vol.GetVolume().GetVolumeId()).NotTo(BeEmpty()) cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId()}) - By("getting a node id") - nid, err := c.NodeGetInfo( - context.Background(), - &csi.NodeGetInfoRequest{}) - Expect(err).NotTo(HaveOccurred()) - Expect(nid).NotTo(BeNil()) - Expect(nid.GetNodeId()).NotTo(BeEmpty()) - var conpubvol *csi.ControllerPublishVolumeResponse if controllerPublishSupported { By("controller publishing volume") @@ -667,7 +678,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { context.Background(), &csi.ControllerPublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), VolumeCapability: &csi.VolumeCapability{ AccessType: &csi.VolumeCapability_Mount{ Mount: &csi.VolumeCapability_MountVolume{}, @@ -682,7 +693,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { }, ) Expect(err).NotTo(HaveOccurred()) - cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: nid.GetNodeId()}) + cl.RegisterVolume(name, VolumeInfo{VolumeID: vol.GetVolume().GetVolumeId(), NodeID: ni.GetNodeId()}) Expect(conpubvol).NotTo(BeNil()) } // NodeStageVolume @@ -782,7 +793,7 @@ var _ = DescribeSanity("Node Service", func(sc *SanityContext) { context.Background(), &csi.ControllerUnpublishVolumeRequest{ VolumeId: vol.GetVolume().GetVolumeId(), - NodeId: nid.GetNodeId(), + NodeId: ni.GetNodeId(), Secrets: sc.Secrets.ControllerUnpublishVolumeSecret, }, )