From c23933efdc540a75224f2dfb5f9f343d06a22234 Mon Sep 17 00:00:00 2001 From: mpl Date: Sat, 5 Jul 2014 00:14:10 +0200 Subject: [PATCH] buildbot: be more patient when waiting for camlistored I'm hoping this will help with our first test suite run (Go1) which is often failing at the test trying to hit http://localhost:3179/ui Change-Id: I972072ebc27b7a59136a90532000ca7e9d58a471 --- misc/buildbot/builder/builder.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/misc/buildbot/builder/builder.go b/misc/buildbot/builder/builder.go index 1314173a8..dd14e1956 100644 --- a/misc/buildbot/builder/builder.go +++ b/misc/buildbot/builder/builder.go @@ -45,12 +45,14 @@ import ( "syscall" "time" + "camlistore.org/pkg/netutil" "camlistore.org/pkg/osutil" ) const ( - interval = 60 * time.Second // polling frequency - warmup = 30 * time.Second // duration before we test if devcam server has started properly + interval = 60 * time.Second // polling frequency + warmup = 30 * time.Second // duration before we test if devcam server has started properly + camlistoredTimeOut = time.Minute // how long we try to dial camlistored after warmup ) var ( @@ -841,8 +843,8 @@ func hitCamliUi() error { return nil } -func hitURL(url string) (err error) { - tsk := newTask("http.Get", url) +func hitURL(uri string) (err error) { + tsk := newTask("http.Get", uri) defer func() { if err != nil { tsk.Err = fmt.Sprintf("%v", err) @@ -853,8 +855,17 @@ func hitURL(url string) (err error) { }() dbg.Println(tsk.String()) tsk.Start = time.Now() + u, err := url.Parse(uri) + if err != nil { + return fmt.Errorf("%v: could not get host:port to dial from %v: %v\n", tsk.String(), uri, err) + } + hostPort := u.Host + err = netutil.AwaitReachable(hostPort, camlistoredTimeOut) + if err != nil { + return fmt.Errorf("%v: camlistored unreachable at %v after %v: %v\n", tsk.String(), hostPort, camlistoredTimeOut, err) + } var resp *http.Response - resp, err = http.Get(url) + resp, err = http.Get(uri) if err != nil { return fmt.Errorf("%v: %v\n", tsk.String(), err) }