github.com/lazyboychen7/engine@v17.12.1-ce-rc2+incompatible/integration/util/requirement/requirement.go (about) 1 package requirement 2 3 import ( 4 "net/http" 5 "strings" 6 "testing" 7 "time" 8 ) 9 10 // HasHubConnectivity checks to see if https://hub.docker.com is 11 // accessible from the present environment 12 func HasHubConnectivity(t *testing.T) bool { 13 // Set a timeout on the GET at 15s 14 var timeout = 15 * time.Second 15 var url = "https://hub.docker.com" 16 17 client := http.Client{Timeout: timeout} 18 resp, err := client.Get(url) 19 if err != nil && strings.Contains(err.Error(), "use of closed network connection") { 20 t.Fatalf("Timeout for GET request on %s", url) 21 } 22 if resp != nil { 23 resp.Body.Close() 24 } 25 return err == nil 26 }