summaryrefslogtreecommitdiffhomepage
path: root/runsc/test/testutil/testutil.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2018-08-07 13:47:16 -0700
committerShentubot <shentubot@google.com>2018-08-07 13:48:35 -0700
commitcb23232c37c092b60d7e3ee91cb8dd8bed855028 (patch)
treef0390f71cea833c3ac7214d5ec30c1862a4e6a95 /runsc/test/testutil/testutil.go
parentc036da5dffdf6cad912abe2723e69c04b59430b7 (diff)
Fix build break in test
integration_test runs manually and breakage wasn't detected. Added test to kokoro to ensure breakages are detected in the future. PiperOrigin-RevId: 207772835 Change-Id: Iada81b579b558477d4db3516b38366ef6a2e933d
Diffstat (limited to 'runsc/test/testutil/testutil.go')
-rw-r--r--runsc/test/testutil/testutil.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/runsc/test/testutil/testutil.go b/runsc/test/testutil/testutil.go
index 721478353..4e7ab3760 100644
--- a/runsc/test/testutil/testutil.go
+++ b/runsc/test/testutil/testutil.go
@@ -21,6 +21,7 @@ import (
"fmt"
"io"
"io/ioutil"
+ "net/http"
"os"
"path/filepath"
"time"
@@ -182,3 +183,12 @@ func Poll(cb func() error, timeout time.Duration) error {
b := backoff.WithContext(backoff.NewConstantBackOff(100*time.Millisecond), ctx)
return backoff.Retry(cb, b)
}
+
+// WaitForHTTP tries GET requests on a port until the call succeeds or timeout.
+func WaitForHTTP(port int, timeout time.Duration) error {
+ cb := func() error {
+ _, err := http.Get(fmt.Sprintf("http://localhost:%d/", port))
+ return err
+ }
+ return Poll(cb, timeout)
+}