- // 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))