balancer_test: possible ctx leak, cancel before break (#1479)

This commit is contained in:
ZhouyihaiDing
2017-08-28 08:51:54 -07:00
committed by dfawley
parent 5db24c9758
commit 41127174ce
2 changed files with 4 additions and 0 deletions

0
.please-update Normal file
View File

View File

@ -163,6 +163,7 @@ func TestEmptyAddrs(t *testing.T) {
time.Sleep(10 * time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
if err := Invoke(ctx, "/foo/bar", &expectedRequest, &reply, cc); err != nil {
cancel()
break
}
cancel()
@ -239,6 +240,7 @@ func TestCloseWithPendingRPC(t *testing.T) {
for {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
if err := Invoke(ctx, "/foo/bar", &expectedRequest, &reply, cc, FailFast(false)); Code(err) == codes.DeadlineExceeded {
cancel()
break
}
time.Sleep(10 * time.Millisecond)
@ -466,6 +468,7 @@ func TestPickFirstEmptyAddrs(t *testing.T) {
time.Sleep(10 * time.Millisecond)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
if err := Invoke(ctx, "/foo/bar", &expectedRequest, &reply, cc); err != nil {
cancel()
break
}
cancel()
@ -493,6 +496,7 @@ func TestPickFirstCloseWithPendingRPC(t *testing.T) {
for {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Millisecond)
if err := Invoke(ctx, "/foo/bar", &expectedRequest, &reply, cc, FailFast(false)); Code(err) == codes.DeadlineExceeded {
cancel()
break
}
time.Sleep(10 * time.Millisecond)