Replace all executor_test timeouts by util.ForeverTestTimeout

This commit is contained in:
Dr. Stefan Schimanski 2015-10-08 15:57:25 +01:00
parent b629278d7d
commit 0d8384c820

View File

@ -45,6 +45,7 @@ import (
"k8s.io/kubernetes/pkg/kubelet/dockertools"
kubetypes "k8s.io/kubernetes/pkg/kubelet/types"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/util"
"k8s.io/kubernetes/pkg/watch"
"github.com/mesos/mesos-go/mesosproto"
@ -72,7 +73,7 @@ func TestExecutorRegister(t *testing.T) {
if reflect.DeepEqual(initialPodUpdate, update) {
receivedInitialPodUpdate = true
}
case <-time.After(time.Second):
case <-time.After(util.ForeverTestTimeout):
}
assert.Equal(t, true, receivedInitialPodUpdate,
"executor should have sent an initial PodUpdate "+
@ -163,7 +164,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
select {
case <-updates:
case <-time.After(time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("Executor should send an initial update on Registration")
}
@ -193,7 +194,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
executor.LaunchTask(mockDriver, taskInfo)
assertext.EventuallyTrue(t, 5*time.Second, func() bool {
assertext.EventuallyTrue(t, util.ForeverTestTimeout, func() bool {
executor.lock.Lock()
defer executor.lock.Unlock()
return len(executor.tasks) == 1 && len(executor.pods) == 1
@ -205,7 +206,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
if len(update.Pods) == 1 {
gotPodUpdate = true
}
case <-time.After(time.Second):
case <-time.After(util.ForeverTestTimeout):
}
assert.Equal(t, true, gotPodUpdate,
"the executor should send an update about a new pod to "+
@ -215,7 +216,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
finished := kmruntime.After(statusUpdateCalls.Wait)
select {
case <-finished:
case <-time.After(5 * time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("timed out waiting for status update calls to finish")
}
@ -227,7 +228,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
executor.KillTask(mockDriver, taskInfo.TaskId)
assertext.EventuallyTrue(t, 5*time.Second, func() bool {
assertext.EventuallyTrue(t, util.ForeverTestTimeout, func() bool {
executor.lock.Lock()
defer executor.lock.Unlock()
return len(executor.tasks) == 0 && len(executor.pods) == 0
@ -237,7 +238,7 @@ func TestExecutorLaunchAndKillTask(t *testing.T) {
finished = kmruntime.After(statusUpdateCalls.Wait)
select {
case <-finished:
case <-time.After(5 * time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("timed out waiting for status update calls to finish")
}
mockDriver.AssertExpectations(t)
@ -338,7 +339,7 @@ func TestExecutorStaticPods(t *testing.T) {
// wait for static pod to start
seenPods := map[string]struct{}{}
timeout := time.After(time.Second)
timeout := time.After(util.ForeverTestTimeout)
defer mockDriver.AssertExpectations(t)
for {
// filter by PodUpdate type
@ -438,7 +439,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
// when removing the task from k.tasks through the "task-lost:foo" message below.
select {
case <-called:
case <-time.After(5 * time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("timed out waiting for SendStatusUpdate for the running task")
}
@ -450,7 +451,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
).Return(mesosproto.Status_DRIVER_RUNNING, nil).Run(func(_ mock.Arguments) { close(called) }).Once()
executor.FrameworkMessage(mockDriver, "task-lost:foo")
assertext.EventuallyTrue(t, 5*time.Second, func() bool {
assertext.EventuallyTrue(t, util.ForeverTestTimeout, func() bool {
executor.lock.Lock()
defer executor.lock.Unlock()
return len(executor.tasks) == 0 && len(executor.pods) == 0
@ -458,7 +459,7 @@ func TestExecutorFrameworkMessage(t *testing.T) {
select {
case <-called:
case <-time.After(5 * time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("timed out waiting for SendStatusUpdate")
}
@ -621,7 +622,7 @@ func TestExecutorsendFrameworkMessage(t *testing.T) {
// guard against data race in mock driver between AssertExpectations and Called
select {
case <-called: // expected
case <-time.After(5 * time.Second):
case <-time.After(util.ForeverTestTimeout):
t.Fatalf("expected call to SendFrameworkMessage")
}
mockDriver.AssertExpectations(t)