Skip to content

Commit

Permalink
Merge pull request #82 from darkowlzz/nodeGetInfo-sanity
Browse files Browse the repository at this point in the history
sanity: test NodeGetInfo() & accessibility capability
  • Loading branch information
lpabon authored Jul 2, 2018
2 parents cb19415 + 3f1ba09 commit 08efbab
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/sanity/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
}
Expand Down
49 changes: 49 additions & 0 deletions pkg/sanity/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 08efbab

Please sign in to comment.