File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -859,12 +859,15 @@ func (s) TestUpdateAddresses_RetryFromFirstAddr(t *testing.T) {
859859 defer lis3 .Close ()
860860
861861 closeServer2 := make (chan struct {})
862+ exitCh := make (chan struct {})
862863 server1ContactedFirstTime := make (chan struct {})
863864 server1ContactedSecondTime := make (chan struct {})
864865 server2ContactedFirstTime := make (chan struct {})
865866 server2ContactedSecondTime := make (chan struct {})
866867 server3Contacted := make (chan struct {})
867868
869+ defer close (exitCh )
870+
868871 // Launch server 1.
869872 go func () {
870873 // First, let's allow the initial connection to go READY. We need to do
@@ -888,12 +891,18 @@ func (s) TestUpdateAddresses_RetryFromFirstAddr(t *testing.T) {
888891 // until balancer is built to process the addresses.
889892 stateNotifications := testBalancerBuilder .nextStateNotifier ()
890893 // Wait for the transport to become ready.
891- for s := range stateNotifications {
892- if s == connectivity .Ready {
893- break
894+ for {
895+ select {
896+ case st := <- stateNotifications :
897+ if st == connectivity .Ready {
898+ goto ready
899+ }
900+ case <- exitCh :
901+ return
894902 }
895903 }
896904
905+ ready:
897906 // Once it's ready, curAddress has been set. So let's close this
898907 // connection prompting the first reconnect cycle.
899908 conn1 .Close ()
You can’t perform that action at this time.
0 commit comments