Fix tests

This commit is contained in:
Alex Dadgar
2016-02-03 19:58:39 -08:00
parent 03aca9887b
commit cc90670210
2 changed files with 16 additions and 3 deletions

View File

@@ -1,6 +1,7 @@
package client
import (
"fmt"
"os"
"testing"
"time"
@@ -49,10 +50,13 @@ func TestAllocRunner_SimpleRun(t *testing.T) {
testutil.WaitForResult(func() (bool, error) {
if upd.Count == 0 {
return false, nil
return false, fmt.Errorf("No updates")
}
last := upd.Allocs[upd.Count-1]
return last.ClientStatus == structs.AllocClientStatusDead, nil
if last.ClientStatus == structs.AllocClientStatusDead {
return false, fmt.Errorf("got status %v; want %v", last.ClientStatus, structs.AllocClientStatusDead)
}
return true, nil
}, func(err error) {
t.Fatalf("err: %v", err)
})

View File

@@ -131,7 +131,7 @@ func TestTaskRunner_Update(t *testing.T) {
// Change command to ensure we run for a bit
tr.task.Config["command"] = "/bin/sleep"
tr.task.Config["args"] = []string{"10"}
tr.task.Config["args"] = []string{"100"}
go tr.Run()
defer tr.Destroy()
defer tr.ctx.AllocDir.Destroy()
@@ -148,6 +148,15 @@ func TestTaskRunner_Update(t *testing.T) {
newTask.Driver = "foobar"
// Update the kill timeout
testutil.WaitForResult(func() (bool, error) {
if tr.handle == nil {
return false, fmt.Errorf("task not started")
}
return true, nil
}, func(err error) {
t.Fatalf("err: %v", err)
})
oldHandle := tr.handle.ID()
newTask.KillTimeout = time.Hour