Skip to content

Commit

Permalink
in multiple packages: fixed goroutine leak bugs in tests (cont.d) (et…
Browse files Browse the repository at this point in the history
  • Loading branch information
sfzhu93 authored Jan 30, 2020
1 parent cad9270 commit 467e08c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion clientv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion clientv3/txn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions lease/lessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/proxy/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
}()
Expand Down Expand Up @@ -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)
}()
Expand Down

0 comments on commit 467e08c

Please sign in to comment.