-
Notifications
You must be signed in to change notification settings - Fork 153
Update build execution time #335
Changes from 2 commits
dae3fed
3f17b56
b01d6af
e028b2f
9d5e48b
958b00b
b0809d6
c09dbdc
73f1478
6e1fcdd
45bd5c0
fbd2d41
eb0ea68
7286782
61b4568
6fc208c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -120,3 +120,63 @@ func TestFailingBuild(t *testing.T) { | |
| t.Fatalf("watchBuild did not return expected error: %v", err) | ||
| } | ||
| } | ||
|
|
||
| func TestBuildLowTimeout(t *testing.T) { | ||
| clients := setup(t) | ||
|
|
||
| buildName := "build-low-timeout" | ||
| if _, err := clients.buildClient.builds.Create(&v1alpha1.Build{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: buildTestNamespace, | ||
| Name: buildName, | ||
| }, | ||
| Spec: v1alpha1.BuildSpec{ | ||
| Timeout: "20s", | ||
| Steps: []corev1.Container{{ | ||
| Name: "lowtimeoutstep", | ||
| Image: "ubuntu", | ||
| Command: []string{"/bin/bash"}, | ||
| Args: []string{"-c", "sleep 2000"}, | ||
| }}, | ||
| }, | ||
| }); err != nil { | ||
| t.Fatalf("Error creating build: %v", err) | ||
| } | ||
|
|
||
| b, err := clients.buildClient.watchBuild(buildName) | ||
| if err == nil { | ||
| t.Fatalf("watchBuild did not return expected BuildTimeout error") | ||
| } | ||
|
|
||
| // verify reason for build failure is timeout | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a check that the build executed for 20s, +/- some wiggle room? That wiggle room will be pretty high today, since we only poll every 30s.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay how about we check if build duration is between buildTimeout and buildTimeout + 40s(30s poll + 10s tolerance)?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that sounds good. Add a TODO to reduce the wiggle room once we're more strict, and maybe run the test a few times to make sure it's not flaky.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I ran into couple of edge cases while re-running the test. So I fixed couple of bugs in this PR. |
||
| if b.Status.GetCondition(v1alpha1.BuildSucceeded).Reason != "BuildTimeout" { | ||
| t.Fatalf("wanted BuildTimeout; got %q", b.Status.GetCondition(v1alpha1.BuildSucceeded).Reason) | ||
| } | ||
| } | ||
|
|
||
| func TestBuildWithHighTimeout(t *testing.T) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure you need this test here, since the build is actually successful
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1, our test that a build under the timeout passes is
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree. I wanted to test a build with higher timeout set. As an alternate idea I could alter the |
||
| clients := setup(t) | ||
|
|
||
| buildName := "build-high-timeout" | ||
| if _, err := clients.buildClient.builds.Create(&v1alpha1.Build{ | ||
| ObjectMeta: metav1.ObjectMeta{ | ||
| Namespace: buildTestNamespace, | ||
| Name: buildName, | ||
| }, | ||
| Spec: v1alpha1.BuildSpec{ | ||
| Timeout: "40s", | ||
| Steps: []corev1.Container{{ | ||
| Name: "hightimeoutstep", | ||
| Image: "ubuntu", | ||
| Command: []string{"/bin/bash"}, | ||
| Args: []string{"-c", "sleep 20"}, | ||
| }}, | ||
| }, | ||
| }); err != nil { | ||
| t.Fatalf("Error creating build: %v", err) | ||
| } | ||
|
|
||
| if _, err := clients.buildClient.watchBuild(buildName); err != nil { | ||
| t.Fatalf("Did not expect error: %v", err) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could probably be
t.Error, and we can keep checking other things about the returned build.