diff --git a/client/driver/rkt_test.go b/client/driver/rkt_test.go index ffdbdc1e4..9a3ec06bc 100644 --- a/client/driver/rkt_test.go +++ b/client/driver/rkt_test.go @@ -445,13 +445,19 @@ func TestRktDriver_PortsMapping(t *testing.T) { if handle == nil { t.Fatalf("missing handle") } - defer handle.Kill() + + failCh := make(chan error, 1) + go func() { + time.Sleep(1 * time.Second) + if err := handle.Kill(); err != nil { + failCh <- err + } + }() select { - case res := <-handle.WaitCh(): - if !res.Successful() { - t.Fatalf("err: %v", res) - } + case err := <-failCh: + t.Fatalf("failed to kill handle: %v", err) + case <-handle.WaitCh(): case <-time.After(time.Duration(testutil.TestMultiplier()*15) * time.Second): t.Fatalf("timeout") } diff --git a/command/agent/agent.go b/command/agent/agent.go index 5c8399270..e684365f5 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -241,7 +241,7 @@ func (a *Agent) clientConfig() (*clientconfig.Config, error) { if a.config.Client.MaxKillTimeout != "" { dur, err := time.ParseDuration(a.config.Client.MaxKillTimeout) if err != nil { - return nil, fmt.Errorf("Error parsing retry interval: %s", err) + return nil, fmt.Errorf("Error parsing max kill timeout: %s", err) } conf.MaxKillTimeout = dur } diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 71283dcef..735dfca97 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -43,6 +43,10 @@ func makeAgent(t testing.TB, cb func(*Config)) (string, *Agent) { config := nomad.DefaultConfig() conf.NomadConfig = config + // Set the data_dir + conf.DataDir = dir + conf.NomadConfig.DataDir = dir + // Bind and set ports conf.BindAddr = "127.0.0.1" conf.Ports = &Ports{ diff --git a/command/agent/command_test.go b/command/agent/command_test.go index 248ef1185..342390913 100644 --- a/command/agent/command_test.go +++ b/command/agent/command_test.go @@ -80,12 +80,6 @@ func TestRetryJoin(t *testing.T) { defer os.RemoveAll(dir) defer agent.Shutdown() - tmpDir, err := ioutil.TempDir("", "nomad") - if err != nil { - t.Fatalf("err: %s", err) - } - defer os.RemoveAll(tmpDir) - doneCh := make(chan struct{}) shutdownCh := make(chan struct{}) @@ -96,7 +90,11 @@ func TestRetryJoin(t *testing.T) { cmd := &Command{ ShutdownCh: shutdownCh, - Ui: new(cli.MockUi), + Ui: &cli.BasicUi{ + Reader: os.Stdin, + Writer: os.Stdout, + ErrorWriter: os.Stderr, + }, } serfAddr := fmt.Sprintf( @@ -105,8 +103,7 @@ func TestRetryJoin(t *testing.T) { agent.config.Ports.Serf) args := []string{ - "-server", - "-data-dir", tmpDir, + "-dev", "-node", fmt.Sprintf(`"Node %d"`, getPort()), "-retry-join", serfAddr, "-retry-interval", "1s",