Fixed a java test

This commit is contained in:
Diptanu Choudhury 2016-08-23 16:51:09 -05:00
parent 05fe72e89e
commit 9309247f9d
3 changed files with 13 additions and 8 deletions

View file

@ -20,6 +20,7 @@ import (
var basicResources = &structs.Resources{
CPU: 250,
MemoryMB: 256,
DiskMB: 20,
Networks: []*structs.NetworkResource{
&structs.NetworkResource{
IP: "0.0.0.0",

View file

@ -31,7 +31,11 @@ func javaLocated() bool {
// The fingerprinter test should always pass, even if Java is not installed.
func TestJavaDriver_Fingerprint(t *testing.T) {
ctestutils.JavaCompatible(t)
driverCtx, _ := testDriverContexts(&structs.Task{Name: "foo"})
task := &structs.Task{
Name: "foo",
Resources: structs.DefaultResources(),
}
driverCtx, _ := testDriverContexts(task)
d := NewJavaDriver(driverCtx)
node := &structs.Node{
Attributes: map[string]string{

View file

@ -71,7 +71,7 @@ func TestTaskRunner_SimpleRun(t *testing.T) {
upd, tr := testTaskRunner(false)
tr.MarkReceived()
go tr.Run()
defer tr.Destroy(structs.TaskKilled)
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
defer tr.ctx.AllocDir.Destroy()
select {
@ -138,7 +138,7 @@ func TestTaskRunner_Destroy(t *testing.T) {
}
// Begin the tear down
tr.Destroy(structs.TaskKilled)
tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
select {
case <-tr.WaitCh():
@ -171,7 +171,7 @@ func TestTaskRunner_Update(t *testing.T) {
tr.task.Config["command"] = "/bin/sleep"
tr.task.Config["args"] = []string{"100"}
go tr.Run()
defer tr.Destroy(structs.TaskKilled)
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
defer tr.ctx.AllocDir.Destroy()
// Update the task definition
@ -225,7 +225,7 @@ func TestTaskRunner_SaveRestoreState(t *testing.T) {
tr.task.Config["command"] = "/bin/sleep"
tr.task.Config["args"] = []string{"10"}
go tr.Run()
defer tr.Destroy(structs.TaskKilled)
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
// Snapshot state
time.Sleep(2 * time.Second)
@ -240,7 +240,7 @@ func TestTaskRunner_SaveRestoreState(t *testing.T) {
t.Fatalf("err: %v", err)
}
go tr2.Run()
defer tr2.Destroy(structs.TaskKilled)
defer tr2.Destroy(structs.NewTaskEvent(structs.TaskKilled))
// Destroy and wait
testutil.WaitForResult(func() (bool, error) {
@ -272,7 +272,7 @@ func TestTaskRunner_Download_List(t *testing.T) {
upd, tr := testTaskRunnerFromAlloc(false, alloc)
tr.MarkReceived()
go tr.Run()
defer tr.Destroy(structs.TaskKilled)
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
defer tr.ctx.AllocDir.Destroy()
select {
@ -337,7 +337,7 @@ func TestTaskRunner_Download_Retries(t *testing.T) {
upd, tr := testTaskRunnerFromAlloc(true, alloc)
tr.MarkReceived()
go tr.Run()
defer tr.Destroy(structs.TaskKilled)
defer tr.Destroy(structs.NewTaskEvent(structs.TaskKilled))
defer tr.ctx.AllocDir.Destroy()
select {