From 30ede9da17a562bf4baf5f3f6f9552333b194786 Mon Sep 17 00:00:00 2001 From: Sunny Date: Wed, 20 Jun 2018 16:30:55 +0530 Subject: [PATCH] sanity: test NodeGetInfo() & accessibility capability * Adds test for NodeGetInfo() * Adds ACCESSIBILITY_CONSTRAINT plugin capability in the known plugin capability list. * Adds isPluginCapabilitySupported() to check if the ACCESSIBILITY_CONSTRAINT plugin capability is supported. --- pkg/sanity/identity.go | 1 + pkg/sanity/node.go | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/pkg/sanity/identity.go b/pkg/sanity/identity.go index cb5aad48..c4a30e0e 100644 --- a/pkg/sanity/identity.go +++ b/pkg/sanity/identity.go @@ -50,6 +50,7 @@ var _ = Describe("GetPluginCapabilities [Identity Service]", func() { for _, cap := range res.GetCapabilities() { switch cap.GetService().GetType() { case csi.PluginCapability_Service_CONTROLLER_SERVICE: + case csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS: default: Fail(fmt.Sprintf("Unknown capability: %v\n", cap.GetService().GetType())) } diff --git a/pkg/sanity/node.go b/pkg/sanity/node.go index d57621de..5085bc50 100644 --- a/pkg/sanity/node.go +++ b/pkg/sanity/node.go @@ -49,6 +49,26 @@ func isNodeCapabilitySupported(c csi.NodeClient, return false } +func isPluginCapabilitySupported(c csi.IdentityClient, + capType csi.PluginCapability_Service_Type, +) bool { + + caps, err := c.GetPluginCapabilities( + context.Background(), + &csi.GetPluginCapabilitiesRequest{}) + Expect(err).NotTo(HaveOccurred()) + Expect(caps).NotTo(BeNil()) + Expect(caps.GetCapabilities()).NotTo(BeNil()) + + for _, cap := range caps.GetCapabilities() { + Expect(cap.GetService()).NotTo(BeNil()) + if cap.GetService().GetType() == capType { + return true + } + } + return false +} + var _ = Describe("NodeGetCapabilities [Node Server]", func() { var ( c csi.NodeClient @@ -101,6 +121,35 @@ var _ = Describe("NodeGetId [Node Server]", func() { }) }) +var _ = Describe("NodeGetInfo [Node Server]", func() { + var ( + c csi.NodeClient + i csi.IdentityClient + accessibilityConstraintSupported bool + ) + + BeforeEach(func() { + c = csi.NewNodeClient(conn) + i = csi.NewIdentityClient(conn) + accessibilityConstraintSupported = isPluginCapabilitySupported(i, csi.PluginCapability_Service_ACCESSIBILITY_CONSTRAINTS) + }) + + It("should return approproate values", func() { + ninfo, err := c.NodeGetInfo( + context.Background(), + &csi.NodeGetInfoRequest{}) + + Expect(err).NotTo(HaveOccurred()) + Expect(ninfo).NotTo(BeNil()) + Expect(ninfo.GetNodeId()).NotTo(BeEmpty()) + Expect(ninfo.GetMaxVolumesPerNode()).NotTo(BeNumerically("<", 0)) + + if accessibilityConstraintSupported { + Expect(ninfo.GetAccessibleTopology()).NotTo(BeNil()) + } + }) +}) + var _ = Describe("NodePublishVolume [Node Server]", func() { var ( s csi.ControllerClient