Normalize configs for agent tests
This commit is contained in:
parent
6d83a192cf
commit
293c596411
|
@ -13,6 +13,14 @@ import (
|
||||||
sconfig "github.com/hashicorp/nomad/nomad/structs/config"
|
sconfig "github.com/hashicorp/nomad/nomad/structs/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// getTestLogger returns a log func appropriate for passing to
|
||||||
|
// Config.normalize()
|
||||||
|
func getTestLogger(t testing.TB) func(string) {
|
||||||
|
return func(s string) {
|
||||||
|
t.Log(s)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getPort() int {
|
func getPort() int {
|
||||||
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
|
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,6 +80,9 @@ func makeAgent(t testing.TB, cb func(*Config)) (string, *Agent) {
|
||||||
cb(conf)
|
cb(conf)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ok := conf.normalize(getTestLogger(t), config.DevMode); !ok {
|
||||||
|
t.Fatalf("error normalizing config")
|
||||||
|
}
|
||||||
agent, err := NewAgent(conf, os.Stderr)
|
agent, err := NewAgent(conf, os.Stderr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
|
@ -94,9 +105,7 @@ func TestAgent_RPCPing(t *testing.T) {
|
||||||
func TestAgent_ServerConfig(t *testing.T) {
|
func TestAgent_ServerConfig(t *testing.T) {
|
||||||
conf := DefaultConfig()
|
conf := DefaultConfig()
|
||||||
a := &Agent{config: conf}
|
a := &Agent{config: conf}
|
||||||
testlogger := func(s string) {
|
testlogger := getTestLogger(t)
|
||||||
t.Log(s)
|
|
||||||
}
|
|
||||||
dev := false
|
dev := false
|
||||||
|
|
||||||
// Returns error on bad serf addr
|
// Returns error on bad serf addr
|
||||||
|
|
Loading…
Reference in New Issue