Skip to content

Commit

Permalink
Fixes for drivers with STAGE_UNSTAGE_VOLUME capability
Browse files Browse the repository at this point in the history
  • Loading branch information
davidz627 committed Mar 14, 2018
1 parent d2bc801 commit 5d98462
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 199 deletions.
12 changes: 6 additions & 6 deletions cmd/csi-sanity/sanity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,16 @@ const (
)

var (
VERSION = "(dev)"
endpoint string
mountPoint string
version bool
VERSION = "(dev)"
endpoint string
mountDir string
version bool
)

func init() {
flag.StringVar(&endpoint, prefix+"endpoint", "", "CSI endpoint")
flag.BoolVar(&version, prefix+"version", false, "Version of this program")
flag.StringVar(&mountPoint, prefix+"mountpoint", os.TempDir()+"/csi", "Mount point for NodePublish")
flag.StringVar(&mountDir, prefix+"mountdir", os.TempDir()+"/csi", "Mount point for NodePublish")
flag.Parse()
}

Expand All @@ -50,5 +50,5 @@ func TestSanity(t *testing.T) {
if len(endpoint) == 0 {
t.Fatalf("--%sendpoint must be provided with an CSI endpoint", prefix)
}
sanity.Test(t, endpoint, mountPoint)
sanity.Test(t, endpoint, mountDir)
}
4 changes: 4 additions & 0 deletions mock/service/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ func (s *service) ControllerUnpublishVolume(
s.volsRWL.Lock()
defer s.volsRWL.Unlock()

if len(req.GetVolumeId()) == 0 {
return nil, status.Error(codes.InvalidArgument, fmt.Sprintf("Expected a volume ID, got none"))
}

i, v := s.findVolNoLock("id", req.VolumeId)
if i < 0 {
return nil, status.Error(codes.NotFound, req.VolumeId)
Expand Down
16 changes: 8 additions & 8 deletions pkg/sanity/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func verifyVolumeInfo(v *csi.Volume) {
Expect(v.GetId()).NotTo(BeEmpty())
}

func isCapabilitySupported(
func isControllerCapabilitySupported(
c csi.ControllerClient,
capType csi.ControllerServiceCapability_RPC_Type,
) bool {
Expand Down Expand Up @@ -97,7 +97,7 @@ var _ = Describe("GetCapacity [Controller Server]", func() {
BeforeEach(func() {
c = csi.NewControllerClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_GET_CAPACITY) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_GET_CAPACITY) {
Skip("GetCapacity not supported")
}
})
Expand All @@ -121,7 +121,7 @@ var _ = Describe("ListVolumes [Controller Server]", func() {
BeforeEach(func() {
c = csi.NewControllerClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_LIST_VOLUMES) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_LIST_VOLUMES) {
Skip("ListVolumes not supported")
}
})
Expand Down Expand Up @@ -152,7 +152,7 @@ var _ = Describe("CreateVolume [Controller Server]", func() {
BeforeEach(func() {
c = csi.NewControllerClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME) {
Skip("CreateVolume not supported")
}
})
Expand Down Expand Up @@ -419,7 +419,7 @@ var _ = Describe("DeleteVolume [Controller Server]", func() {
BeforeEach(func() {
c = csi.NewControllerClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_CREATE_DELETE_VOLUME) {
Skip("DeleteVolume not supported")
}
})
Expand Down Expand Up @@ -585,7 +585,7 @@ var _ = Describe("ControllerPublishVolume [Controller Server]", func() {
c = csi.NewControllerClient(conn)
n = csi.NewNodeClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME) {
Skip("ControllerPublishVolume not supported")
}
})
Expand Down Expand Up @@ -715,7 +715,7 @@ var _ = Describe("ControllerUnpublishVolume [Controller Server]", func() {
c = csi.NewControllerClient(conn)
n = csi.NewNodeClient(conn)

if !isCapabilitySupported(c, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME) {
if !isControllerCapabilitySupported(c, csi.ControllerServiceCapability_RPC_PUBLISH_UNPUBLISH_VOLUME) {
Skip("ControllerUnpublishVolume not supported")
}
})
Expand All @@ -729,7 +729,7 @@ var _ = Describe("ControllerUnpublishVolume [Controller Server]", func() {

serverError, ok := status.FromError(err)
Expect(ok).To(BeTrue())
Expect(serverError.Code()).To(Equal(codes.NotFound))
Expect(serverError.Code()).To(Equal(codes.InvalidArgument))
})

It("should return appropriate values (no optional values added)", func() {
Expand Down
Loading

0 comments on commit 5d98462

Please sign in to comment.