Преглед на файлове

clientv3: close balancer to avoid goroutine leak in balancer_test.go

fanmin shi преди 8 години
родител
ревизия
7a25257fb2
променени са 1 файла, в които са добавени 2 реда и са изтрити 0 реда
  1. 2 0
      clientv3/balancer_test.go

+ 2 - 0
clientv3/balancer_test.go

@@ -29,6 +29,7 @@ var (
 
 
 func TestBalancerGetUnblocking(t *testing.T) {
 func TestBalancerGetUnblocking(t *testing.T) {
 	sb := newSimpleBalancer(endpoints)
 	sb := newSimpleBalancer(endpoints)
+	defer sb.Close()
 	if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
 	if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
 		t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
 		t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
 	}
 	}
@@ -72,6 +73,7 @@ func TestBalancerGetUnblocking(t *testing.T) {
 
 
 func TestBalancerGetBlocking(t *testing.T) {
 func TestBalancerGetBlocking(t *testing.T) {
 	sb := newSimpleBalancer(endpoints)
 	sb := newSimpleBalancer(endpoints)
+	defer sb.Close()
 	if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
 	if addrs := <-sb.Notify(); len(addrs) != len(endpoints) {
 		t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
 		t.Errorf("Initialize newSimpleBalancer should have triggered Notify() chan, but it didn't")
 	}
 	}