mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
in multiple packages: fixed goroutine leak bugs in tests (cont.d) (#11570)
This commit is contained in:
parent
cad92706cf
commit
467e08c32a
@ -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()
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
}()
|
||||
|
Loading…
x
Reference in New Issue
Block a user