Unit test for dev agent

This commit is contained in:
Alex Dadgar
2018-05-22 14:39:51 -07:00
parent 598596c7f6
commit 091e628b38
2 changed files with 24 additions and 1 deletions

View File

@@ -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)
}

View File

@@ -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"
@@ -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)
}
}