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

This commit is contained in:
fanmin shi 2017-03-08 13:37:18 -08:00
parent 3f515e1849
commit 7a25257fb2

View File

@ -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")
} }