From 6e4c6da81916e25081c32d3e5f8880ef4d03ad36 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Mon, 6 Jul 2015 16:27:17 +0200 Subject: [PATCH] Fix integration tests with testRequires(c, Network) It seems http://hub.docker.com is not accessible anymore, so switching to https://hub.docker.com for testRequires(c, Network). Adds a Timeout check on the TestRequirement to *panic* if there is a timeout (fail fast). Signed-off-by: Vincent Demeester --- integration-cli/requirements.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/integration-cli/requirements.go b/integration-cli/requirements.go index ff14360042..5e9d72a27f 100644 --- a/integration-cli/requirements.go +++ b/integration-cli/requirements.go @@ -8,6 +8,7 @@ import ( "net/http" "os/exec" "strings" + "time" "github.com/go-check/check" ) @@ -37,7 +38,18 @@ var ( } Network = TestRequirement{ func() bool { - resp, err := http.Get("http://hub.docker.com") + // Set a timeout on the GET at 15s + var timeout = time.Duration(15 * time.Second) + var url = "https://hub.docker.com" + + client := http.Client{ + Timeout: timeout, + } + + resp, err := client.Get(url) + if err != nil && strings.Contains(err.Error(), "use of closed network connection") { + panic(fmt.Sprintf("Timeout for GET request on %s", url)) + } if resp != nil { resp.Body.Close() }