Switch to in-process agent

This commit is contained in:
Alex Dadgar
2017-07-20 21:07:32 -07:00
parent 57e34b66ea
commit da25a3d5ce
20 changed files with 64 additions and 83 deletions

View File

@@ -774,7 +774,7 @@ func (c *Config) normalizeAddrs() error {
addr, err = normalizeAdvertise(c.AdvertiseAddrs.HTTP, c.Addresses.HTTP, c.Ports.HTTP, c.DevMode)
if err != nil {
return fmt.Errorf("Failed to parse HTTP advertise address: %v", err)
return fmt.Errorf("Failed to parse HTTP advertise address (%v, %v, %v, %v): %v", c.AdvertiseAddrs.HTTP, c.Addresses.HTTP, c.Ports.HTTP, c.DevMode, err)
}
c.AdvertiseAddrs.HTTP = addr

View File

@@ -102,7 +102,9 @@ func (a *TestAgent) Start() *TestAgent {
for i := 10; i >= 0; i-- {
pickRandomPorts(a.Config)
a.Config.NodeName = fmt.Sprintf("Node %d", a.Config.Ports.RPC)
if a.Config.NodeName == "" {
a.Config.NodeName = fmt.Sprintf("Node %d", a.Config.Ports.RPC)
}
// write the keyring
if a.Key != "" {
@@ -202,7 +204,7 @@ func (a *TestAgent) HTTPAddr() string {
if a.Server == nil {
return ""
}
return a.Server.Addr
return "http://" + a.Server.Addr
}
func (a *TestAgent) Client() *api.Client {
@@ -210,7 +212,7 @@ func (a *TestAgent) Client() *api.Client {
conf.Address = a.HTTPAddr()
c, err := api.NewClient(conf)
if err != nil {
panic(fmt.Sprintf("Error creating consul API client: %s", err))
panic(fmt.Sprintf("Error creating Nomad API client: %s", err))
}
return c
}
@@ -249,6 +251,9 @@ func (a *TestAgent) config() *Config {
config := nomad.DefaultConfig()
conf.NomadConfig = config
// Set the name
conf.NodeName = a.Name
// Bind and set ports
conf.BindAddr = "127.0.0.1"