diff options
author | Ayush Ranjan <ayushranjan@google.com> | 2020-09-17 17:56:07 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-09-17 17:58:08 -0700 |
commit | 23fcbd8722cc19e662b2cfcb802becc257013df7 (patch) | |
tree | b3a0a9974e34b8438337e78fef8e455a67c863bc /pkg/test/testutil | |
parent | 1e8beb5f1d925ed0c30a2b810fc2a0bffbd3cf58 (diff) |
[testing] Use container address to talk to server running inside container.
Docker does not have IPv6 port forwarding as tracked by the following issue:
https://github.com/moby/moby/issues/11518
So when running bazel itself inside a docker container, we can not use the host
port bindings to communicate with sockets inside the container. This was causing
integration tests and image tests to fail when run through our Makefile targets.
PiperOrigin-RevId: 332355051
Diffstat (limited to 'pkg/test/testutil')
-rw-r--r-- | pkg/test/testutil/testutil.go | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/pkg/test/testutil/testutil.go b/pkg/test/testutil/testutil.go index b7f873392..06fb823f6 100644 --- a/pkg/test/testutil/testutil.go +++ b/pkg/test/testutil/testutil.go @@ -332,13 +332,13 @@ func PollContext(ctx context.Context, cb func() error) error { } // WaitForHTTP tries GET requests on a port until the call succeeds or timeout. -func WaitForHTTP(port int, timeout time.Duration) error { +func WaitForHTTP(ip string, port int, timeout time.Duration) error { cb := func() error { c := &http.Client{ // Calculate timeout to be able to do minimum 5 attempts. Timeout: timeout / 5, } - url := fmt.Sprintf("http://localhost:%d/", port) + url := fmt.Sprintf("http://%s:%d/", ip, port) resp, err := c.Get(url) if err != nil { log.Printf("Waiting %s: %v", url, err) |