summaryrefslogtreecommitdiffhomepage
path: root/runsc/test/testutil/testutil.go
diff options
context:
space:
mode:
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)
+}