Attempting to fix alloc status test

This commit is contained in:
Diptanu Choudhury 2016-08-22 11:35:25 -05:00
parent 6c5c9fdee9
commit 94571eab5d
3 changed files with 24 additions and 3 deletions

View File

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

View File

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

View File

@ -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,