X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/1a3a8b0a7cc31e9bfb63c6001bc049a831e13dd1..9ce1f09357f146cefe582690b1468d032866b3ca:/lib/controller/rails_restart_test.go diff --git a/lib/controller/rails_restart_test.go b/lib/controller/rails_restart_test.go index 75dd22b4a9..5db37c4b8a 100644 --- a/lib/controller/rails_restart_test.go +++ b/lib/controller/rails_restart_test.go @@ -13,6 +13,7 @@ import ( "net/http" "net/url" "os" + "strings" "time" "git.arvados.org/arvados.git/lib/config" @@ -72,14 +73,19 @@ func (s *railsRestartSuite) TestConfigReload(c *check.C) { newhash := fmt.Sprintf("%x", sha256.Sum256(append(confdata, '\n'))) c.Logf("newhash %s", newhash) - // Wait 2s to give RailsAPI's 1 Hz reload_config thread time - // to poll and hit restart.txt - time.Sleep(2 * time.Second) - - resp, err = hc.Do(req) - c.Assert(err, check.IsNil) - c.Check(resp.StatusCode, check.Equals, http.StatusOK) - body, err = ioutil.ReadAll(resp.Body) - c.Assert(err, check.IsNil) + // Wait for RailsAPI's 1 Hz reload_config thread to poll and + // hit restart.txt + pollstart := time.Now() + for deadline := time.Now().Add(20 * time.Second); time.Now().Before(deadline); time.Sleep(time.Second) { + resp, err = hc.Do(req) + c.Assert(err, check.IsNil) + c.Check(resp.StatusCode, check.Equals, http.StatusOK) + body, err = ioutil.ReadAll(resp.Body) + c.Assert(err, check.IsNil) + if strings.Contains(string(body), newhash) { + break + } + } + c.Logf("waited %s for rails to restart", time.Now().Sub(pollstart)) c.Check(string(body), check.Matches, `(?ms).*`+newhash+`.*`) }