Skip to content

Commit

Permalink
Unit test for dev agent
Browse files Browse the repository at this point in the history
  • Loading branch information
dadgar committed May 22, 2018
1 parent 2c5df09 commit f7a4445
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) {
conf.Servers = a.config.Client.Servers
if a.server != nil {
conf.Servers = append(conf.Servers,
a.config.Addresses.RPC,
a.config.normalizedAddrs.RPC,
a.config.AdvertiseAddrs.RPC)
}

Expand Down
23 changes: 23 additions & 0 deletions command/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ import (
"testing"
"time"

cstructs "github.com/hashicorp/nomad/client/structs"
"github.com/hashicorp/nomad/helper"
"github.com/hashicorp/nomad/nomad/structs"
sconfig "github.com/hashicorp/nomad/nomad/structs/config"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -1057,3 +1059,24 @@ func TestServer_ShouldReload_ShouldHandleMultipleChanges(t *testing.T) {
require.False(shouldReloadRPC)
}
}

func TestAgent_ProxyRPC_Dev(t *testing.T) {
t.Parallel()
agent := NewTestAgent(t, t.Name(), nil)
defer agent.Shutdown()

id := agent.client.NodeID()
req := &structs.NodeSpecificRequest{
NodeID: id,
QueryOptions: structs.QueryOptions{
Region: agent.server.Region(),
},
}

time.Sleep(100 * time.Millisecond)

var resp cstructs.ClientStatsResponse
if err := agent.RPC("ClientStats.Stats", req, &resp); err != nil {
t.Fatalf("err: %v", err)
}
}

0 comments on commit f7a4445

Please sign in to comment.