diff --git a/test/build-with-timeout/build-with-high-timeout.yaml b/test/build-with-timeout/build-with-high-timeout.yaml index 1698051b..7f2c0c1e 100644 --- a/test/build-with-timeout/build-with-high-timeout.yaml +++ b/test/build-with-timeout/build-with-high-timeout.yaml @@ -18,7 +18,7 @@ metadata: labels: expect: succeeded spec: - timeout: "500s" + timeout: 500s steps: - name: step1 image: ubuntu diff --git a/test/build-with-timeout/build-with-low-timeout.yaml b/test/build-with-timeout/build-with-low-timeout.yaml index 9936d763..76a30176 100644 --- a/test/build-with-timeout/build-with-low-timeout.yaml +++ b/test/build-with-timeout/build-with-low-timeout.yaml @@ -18,7 +18,7 @@ metadata: labels: expect: failed spec: - timeout: "50s" + timeout: 50s steps: - name: step1 image: ubuntu diff --git a/test/e2e/simple_test.go b/test/e2e/simple_test.go index 8e7176cd..6b3e26d4 100644 --- a/test/e2e/simple_test.go +++ b/test/e2e/simple_test.go @@ -127,14 +127,15 @@ func TestBuildLowTimeout(t *testing.T) { clients := setup(t) buildName := "build-low-timeout" - buildTimeout := "50s" + buildTimeout := 50 * time.Second + if _, err := clients.buildClient.builds.Create(&v1alpha1.Build{ ObjectMeta: metav1.ObjectMeta{ Namespace: buildTestNamespace, Name: buildName, }, Spec: v1alpha1.BuildSpec{ - Timeout: buildTimeout, + Timeout: buildTimeout.String(), Steps: []corev1.Container{{ Name: "lowtimeoutstep", Image: "ubuntu", @@ -166,15 +167,11 @@ func TestBuildLowTimeout(t *testing.T) { t.Fatalf("wanted BuildTimeout; got %q", successCondition.Reason) } buildDuration := b.Status.CompletionTime.Time.Sub(b.Status.StartTime.Time).Seconds() - lowerEnd, err := time.ParseDuration(buildTimeout) - if err != nil { - t.Errorf("Error parsing build duration: %v", err) - } - higherEnd := 90 * time.Second // build timeout + 30 sec poll time + 10 sec + higherEnd := buildTimeout + 30*time.Second + 10*time.Second // build timeout + 30 sec poll time + 10 sec - if !(buildDuration >= lowerEnd.Seconds() && buildDuration < higherEnd.Seconds()) { + if !(buildDuration >= buildTimeout.Seconds() && buildDuration < higherEnd.Seconds()) { t.Fatalf("Expected the build duration to be within range %.2fs to %.2fs; but got build duration: %f, start time: %q and completed time: %q \n", - lowerEnd.Seconds(), + buildTimeout.Seconds(), higherEnd.Seconds(), buildDuration, b.Status.StartTime.Time,