Skip to content

Commit

Permalink
wait for the LB to be balanced
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarkhas committed May 8, 2023
1 parent ca1e5c6 commit d362055
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/suite_test.go
Expand Up @@ -104,13 +104,15 @@ func (s *Suite) TestDatacenterAwareLoadBalancedClient() {
s.T().Fatal(err)
}

// Wait for 2 instances to be registered in dc1
s.Assert().Eventually(func() bool {
svcs, _, err := s.consulClients[0].Catalog().Service(serviceName, "", nil)
return len(svcs) == 2 && err == nil
},
10*time.Second,
1*time.Second)

// Wait for 1 instance to be registered in dc2
s.Assert().Eventually(func() bool {
svcs, _, err := s.consulClients[1].Catalog().Service(serviceName, "", nil)
return len(svcs) == 1 && err == nil
Expand All @@ -136,6 +138,9 @@ func (s *Suite) TestDatacenterAwareLoadBalancedClient() {

client := &http.Client{Transport: transport}

// Wait for resolver to be notified
time.Sleep(1 * time.Second)

results := s.executeServiceRequests(4, client)
s.Assert().Equal(map[string]int{"0": 2, "1": 2}, results)

Expand Down

0 comments on commit d362055

Please sign in to comment.