diff --git a/api/tasks.go b/api/tasks.go index ab5fbbc52..054b5043a 100644 --- a/api/tasks.go +++ b/api/tasks.go @@ -164,7 +164,7 @@ func NewTask(name, driver string) *Task { // Configure is used to configure a single k/v pair on // the task. -func (t *Task) SetConfig(key, val string) *Task { +func (t *Task) SetConfig(key string, val interface{}) *Task { if t.Config == nil { t.Config = make(map[string]interface{}) } diff --git a/command/alloc_status_test.go b/command/alloc_status_test.go index 623da21e2..c553997c8 100644 --- a/command/alloc_status_test.go +++ b/command/alloc_status_test.go @@ -1,9 +1,11 @@ package command import ( + "fmt" "strings" "testing" + "github.com/hashicorp/nomad/nomad/structs" "github.com/hashicorp/nomad/testutil" "github.com/mitchellh/cli" ) @@ -78,6 +80,23 @@ func TestAllocStatusCommand_Run(t *testing.T) { c.DevMode = true }) defer srv.Stop() + + // Wait for a node to be ready + testutil.WaitForResult(func() (bool, error) { + nodes, _, err := client.Nodes().List(nil) + if err != nil { + return false, err + } + for _, node := range nodes { + if node.Status == structs.NodeStatusReady { + return true, nil + } + } + return false, fmt.Errorf("no ready nodes") + }, func(err error) { + t.Fatalf("err: %v", err) + }) + ui := new(cli.MockUi) cmd := &AllocStatusCommand{Meta: Meta{Ui: ui}} diff --git a/command/util_test.go b/command/util_test.go index 7671d933c..00fdd339d 100644 --- a/command/util_test.go +++ b/command/util_test.go @@ -39,8 +39,10 @@ func testServer( } func testJob(jobID string) *api.Job { - task := api.NewTask("task1", "raw_exec"). - SetConfig("command", "/bin/sleep"). + task := api.NewTask("task1", "mock_driver"). + SetConfig("kill_after", "1s"). + SetConfig("run_for", "5s"). + SetConfig("exit_code", 0). Require(&api.Resources{ MemoryMB: 256, DiskMB: 20,