Commit 5036f245 authored by Diptanu Choudhury's avatar Diptanu Choudhury
Browse files

Attempting to fix alloc status test

parent 7eaefc06
Showing with 24 additions and 3 deletions
+24 -3
......@@ -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{})
}
......
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}}
......
......@@ -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,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment