Browse Source

clientv3: send frst down() func after recieving first notified addr

This ensures the ordering of down and up calls.
fanmin shi 9 years ago
parent
commit
310641630e
1 changed files with 2 additions and 1 deletions
  1. 2 1
      clientv3/balancer_test.go

+ 2 - 1
clientv3/balancer_test.go

@@ -95,10 +95,11 @@ func TestBalancerGetBlocking(t *testing.T) {
 	go func() {
 	go func() {
 		// ensure sb.Up() will be called after sb.Get() to see if Up() releases blocking Get()
 		// ensure sb.Up() will be called after sb.Get() to see if Up() releases blocking Get()
 		time.Sleep(time.Millisecond * 100)
 		time.Sleep(time.Millisecond * 100)
-		downC <- sb.Up(grpc.Address{Addr: endpoints[1]})
+		f := sb.Up(grpc.Address{Addr: endpoints[1]})
 		if addrs := <-sb.Notify(); len(addrs) != 1 {
 		if addrs := <-sb.Notify(); len(addrs) != 1 {
 			t.Errorf("first Up() should have triggered balancer to send the first connected address via Notify chan so that other connections can be closed")
 			t.Errorf("first Up() should have triggered balancer to send the first connected address via Notify chan so that other connections can be closed")
 		}
 		}
+		downC <- f
 	}()
 	}()
 	addrFirst, putFun, err := sb.Get(context.Background(), blockingOpts)
 	addrFirst, putFun, err := sb.Get(context.Background(), blockingOpts)
 	if err != nil {
 	if err != nil {