Make the loadbalancers servers order random
Co-authored-by: Mathieu Lonjaret <mathieu.lonjaret@gmail.com> Co-authored-by: Romain <rtribotte@users.noreply.github.com>
This commit is contained in:
parent
89dc466b23
commit
788f8fa951
7 changed files with 177 additions and 46 deletions
|
@ -36,13 +36,11 @@ func (s *RetrySuite) TestRetry(c *check.C) {
|
|||
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("PathPrefix(`/`)"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
start := time.Now()
|
||||
// This simulates a DialTimeout when connecting to the backend server.
|
||||
response, err := http.Get("http://127.0.0.1:8000/")
|
||||
duration, allowed := time.Since(start), time.Millisecond*250
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// The test only verifies that the retry middleware makes sure that the working service is eventually reached.
|
||||
c.Assert(response.StatusCode, checker.Equals, http.StatusOK)
|
||||
c.Assert(int64(duration), checker.LessThan, int64(allowed))
|
||||
}
|
||||
|
||||
func (s *RetrySuite) TestRetryBackoff(c *check.C) {
|
||||
|
@ -58,16 +56,11 @@ func (s *RetrySuite) TestRetryBackoff(c *check.C) {
|
|||
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("PathPrefix(`/`)"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
start := time.Now()
|
||||
// This simulates a DialTimeout when connecting to the backend server.
|
||||
response, err := http.Get("http://127.0.0.1:8000/")
|
||||
duration := time.Since(start)
|
||||
// test case delays: 500 + 700 + 1000ms with randomization. It should be safely > 1500ms
|
||||
minAllowed := time.Millisecond * 1400
|
||||
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// The test only verifies that the retry middleware allows finally to reach the working service.
|
||||
c.Assert(response.StatusCode, checker.Equals, http.StatusOK)
|
||||
c.Assert(int64(duration), checker.GreaterThan, int64(minAllowed))
|
||||
}
|
||||
|
||||
func (s *RetrySuite) TestRetryWebsocket(c *check.C) {
|
||||
|
@ -83,11 +76,12 @@ func (s *RetrySuite) TestRetryWebsocket(c *check.C) {
|
|||
err = try.GetRequest("http://127.0.0.1:8080/api/rawdata", 60*time.Second, try.BodyContains("PathPrefix(`/`)"))
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
// This simulates a DialTimeout when connecting to the backend server.
|
||||
// The test only verifies that the retry middleware makes sure that the working service is eventually reached.
|
||||
_, response, err := websocket.DefaultDialer.Dial("ws://127.0.0.1:8000/echo", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(response.StatusCode, checker.Equals, http.StatusSwitchingProtocols)
|
||||
|
||||
// The test verifies a second time that the working service is eventually reached.
|
||||
_, response, err = websocket.DefaultDialer.Dial("ws://127.0.0.1:8000/echo", nil)
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(response.StatusCode, checker.Equals, http.StatusSwitchingProtocols)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue