Skip to content

Commit

Permalink
Add CSI info test for agent
Browse files Browse the repository at this point in the history
Signed-off-by: Ameya Gawde <agawde@mirantis.com>
  • Loading branch information
ameyag committed Jul 30, 2020
1 parent c740688 commit f35a141
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions agent/agent_test.go
Expand Up @@ -15,6 +15,7 @@ import (
"google.golang.org/grpc/credentials"

events "github.com/docker/go-events"
"github.com/docker/swarmkit/agent/csi"
agentutils "github.com/docker/swarmkit/agent/testutils"
"github.com/docker/swarmkit/api"
"github.com/docker/swarmkit/ca"
Expand Down Expand Up @@ -437,6 +438,25 @@ func TestAgentExitsBasedOnSessionTracker(t *testing.T) {
require.Len(t, closedSessions, 3)
}

func TestAgentCSIInfo(t *testing.T) {
tlsCh := make(chan events.Event, 1)
defer close(tlsCh)
tester := agentTestEnv(t, nil, tlsCh)
fakeNodePlugin := &csi.NodePlugin{
Name: "testDriver",
NodeID: "node1",
}
tester.agent.CSIPlugins = append(tester.agent.CSIPlugins, fakeNodePlugin)
defer tester.cleanup()
defer tester.StartAgent(t)

currSession, closedSessions := tester.dispatcher.GetSessions()
require.NotNil(t, currSession)
require.NotNil(t, currSession.Description)
require.NotNil(t, currSession.Description.CSIInfo)
require.Equal(t, currSession.Description.CSIInfo[0].NodeID, fakeNodePlugin.NodeID)
}

// If we pass a session tracker, established sessions get tracked.
func TestAgentRegistersSessionsWithSessionTracker(t *testing.T) {
tlsCh := make(chan events.Event, 1)
Expand Down

0 comments on commit f35a141

Please sign in to comment.