Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2018-03-14 13:26:00 +0300
committerJacob Vosmaer <jacob@gitlab.com>2018-03-14 13:26:00 +0300
commit8efe1a3a46bdd523a5013e804816260d91111fa7 (patch)
treedf64b291f841be9b7023f61ee86099c67606282b /helpers_test.go
parent6da2f42ce87582107902e5c81d12d07d398b5601 (diff)
Wait for a successful roundtrip
Diffstat (limited to 'helpers_test.go')
-rw-r--r--helpers_test.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/helpers_test.go b/helpers_test.go
index d3e24b92..44fc3797 100644
--- a/helpers_test.go
+++ b/helpers_test.go
@@ -268,15 +268,23 @@ func GetRedirectPage(t *testing.T, spec ListenSpec, host, urlsuffix string) (*ht
return InsecureHTTPSClient.Transport.RoundTrip(req)
}
-func waitForTCPListeners(t *testing.T, listeners []ListenSpec, timeout time.Duration) {
+func waitForRoundtrips(t *testing.T, listeners []ListenSpec, timeout time.Duration) {
nListening := 0
start := time.Now()
for _, spec := range listeners {
for time.Since(start) < timeout {
- if _, err := net.DialTimeout("tcp", spec.JoinHostPort(), 100*time.Millisecond); err == nil {
+ req, err := http.NewRequest("GET", spec.URL("/"), nil)
+ if err != nil {
+ t.Fatal(err)
+ }
+
+ if response, err := InsecureHTTPSClient.Transport.RoundTrip(req); err == nil {
nListening++
+ response.Body.Close()
break
}
+
+ time.Sleep(100 * time.Millisecond)
}
}