in multiple packages: fixed goroutine leak bugs in tests (cont.d) (#11570)

release-3.5
sfzhu93 2020-01-30 13:55:59 -05:00 committed by GitHub
parent cad92706cf
commit 467e08c32a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 10 deletions

View File

@ -285,7 +285,7 @@ func TestSimpleHTTPClientDoHeaderTimeout(t *testing.T) {
tr.finishCancel <- struct{}{}
c := &simpleHTTPClient{transport: tr, headerTimeout: time.Millisecond}
errc := make(chan error)
errc := make(chan error, 1)
go func() {
_, _, err := c.Do(context.Background(), &fakeAction{})
errc <- err
@ -452,7 +452,7 @@ func TestHTTPClusterClientDoDeadlineExceedContext(t *testing.T) {
endpoints: []url.URL{fakeURL},
}
errc := make(chan error)
errc := make(chan error, 1)
go func() {
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond)
defer cancel()
@ -502,7 +502,7 @@ func TestHTTPClusterClientDoCanceledContext(t *testing.T) {
endpoints: []url.URL{fakeURL},
}
errc := make(chan error)
errc := make(chan error, 1)
go func() {
ctx, cancel := withTimeout(fakeCancelContext{}, time.Millisecond)
cancel()

View File

@ -99,7 +99,7 @@ func TestDialTimeout(t *testing.T) {
}
for i, cfg := range testCfgs {
donec := make(chan error)
donec := make(chan error, 1)
go func() {
// without timeout, dial continues forever on ipv4 black hole
c, err := New(cfg)

View File

@ -26,7 +26,7 @@ func TestTxnPanics(t *testing.T) {
kv := &kv{}
errc := make(chan string)
errc := make(chan string, 1)
df := func() {
if s := recover(); s != nil {
errc <- s.(string)

View File

@ -429,7 +429,7 @@ func TestLessorExpire(t *testing.T) {
t.Fatalf("failed to receive expired lease")
}
donec := make(chan struct{})
donec := make(chan struct{}, 1)
go func() {
// expired lease cannot be renewed
if _, err := le.Renew(l.ID); err != ErrLeaseNotFound {
@ -482,7 +482,7 @@ func TestLessorExpireAndDemote(t *testing.T) {
t.Fatalf("failed to receive expired lease")
}
donec := make(chan struct{})
donec := make(chan struct{}, 1)
go func() {
// expired lease cannot be renewed
if _, err := le.Renew(l.ID); err != ErrNotPrimary {

View File

@ -94,7 +94,7 @@ func testServer(t *testing.T, scheme string, secure bool, delayTx bool) {
}
}()
recvc := make(chan []byte)
recvc := make(chan []byte, 1)
go func() {
for i := 0; i < 2; i++ {
recvc <- receive(t, ln)
@ -247,7 +247,7 @@ func TestServer_PauseTx(t *testing.T) {
data := []byte("Hello World!")
send(t, data, scheme, srcAddr, transport.TLSInfo{})
recvc := make(chan []byte)
recvc := make(chan []byte, 1)
go func() {
recvc <- receive(t, ln)
}()
@ -364,7 +364,7 @@ func TestServer_BlackholeTx(t *testing.T) {
data := []byte("Hello World!")
send(t, data, scheme, srcAddr, transport.TLSInfo{})
recvc := make(chan []byte)
recvc := make(chan []byte, 1)
go func() {
recvc <- receive(t, ln)
}()