Skip to content

Commit

Permalink
e2e: TestTaskRunTimeout uses variables for task/taskrun names
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Demeester <[email protected]>
  • Loading branch information
vdemeester committed Mar 28, 2019
1 parent 2bb7678 commit 52b552a
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions test/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,40 @@ func TestTaskRunTimeout(t *testing.T) {
c, namespace := setup(t)
t.Parallel()

taskName := "giraffe"
taskRunName := "run-giraffe"

knativetest.CleanupOnInterrupt(func() { tearDown(t, c, namespace) }, t.Logf)
defer tearDown(t, c, namespace)

t.Logf("Creating Task and TaskRun in namespace %s", namespace)
if _, err := c.TaskClient.Create(tb.Task("giraffe", namespace,
if _, err := c.TaskClient.Create(tb.Task(taskName, namespace,
tb.TaskSpec(tb.Step("amazing-busybox", "busybox", tb.Command("/bin/sh"), tb.Args("-c", "sleep 3000"))))); err != nil {
t.Fatalf("Failed to create Task `%s`: %s", "giraffe", err)
t.Fatalf("Failed to create Task `%s`: %s", taskName, err)
}
if _, err := c.TaskRunClient.Create(tb.TaskRun("run-giraffe", namespace, tb.TaskRunSpec(tb.TaskRunTaskRef("giraffe"),
if _, err := c.TaskRunClient.Create(tb.TaskRun(taskRunName, namespace, tb.TaskRunSpec(tb.TaskRunTaskRef(taskName),
// Do not reduce this timeout. Taskrun e2e test is also verifying
// if reconcile is triggered from timeout handler and not by pod informers
tb.TaskRunTimeout(30*time.Second)))); err != nil {
t.Fatalf("Failed to create TaskRun `%s`: %s", "run-giraffe", err)
t.Fatalf("Failed to create TaskRun `%s`: %s", taskRunName, err)
}

t.Logf("Waiting for TaskRun %s in namespace %s to complete", "run-giraffe", namespace)
if err := WaitForTaskRunState(c, "run-giraffe", func(tr *v1alpha1.TaskRun) (bool, error) {
t.Logf("Waiting for TaskRun %s in namespace %s to complete", taskRunName, namespace)
if err := WaitForTaskRunState(c, taskRunName, func(tr *v1alpha1.TaskRun) (bool, error) {
cond := tr.Status.GetCondition(duckv1alpha1.ConditionSucceeded)
if cond != nil {
if cond.Status == corev1.ConditionFalse {
if cond.Reason == "TaskRunTimeout" {
return true, nil
}
return true, fmt.Errorf("taskRun %s completed with the wrong reason: %s", "run-giraffe", cond.Reason)
return true, fmt.Errorf("taskRun %s completed with the wrong reason: %s", taskRunName, cond.Reason)
} else if cond.Status == corev1.ConditionTrue {
return true, fmt.Errorf("taskRun %s completed successfully, should have been timed out", "run-giraffe")
return true, fmt.Errorf("taskRun %s completed successfully, should have been timed out", taskRunName)
}
}

return false, nil
}, "TaskRunTimeout"); err != nil {
t.Errorf("Error waiting for TaskRun %s to finish: %s", "run-giraffe", err)
t.Errorf("Error waiting for TaskRun %s to finish: %s", taskRunName, err)
}
}

0 comments on commit 52b552a

Please sign in to comment.