Skip to content
This repository was archived by the owner on Sep 5, 2019. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/build-with-timeout/build-with-high-timeout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
labels:
expect: succeeded
spec:
timeout: "500s"
timeout: 500s
steps:
- name: step1
image: ubuntu
Expand Down
2 changes: 1 addition & 1 deletion test/build-with-timeout/build-with-low-timeout.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
labels:
expect: failed
spec:
timeout: "50s"
timeout: 50s
steps:
- name: step1
image: ubuntu
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/simple_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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,
Expand Down