mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
clientv3: wait for Get goroutine in TestDialCancel
This commit is contained in:
parent
6511171725
commit
d1a9ccb2b9
@ -49,7 +49,13 @@ func TestDialCancel(t *testing.T) {
|
||||
c.SetEndpoints("http://254.0.0.1:12345")
|
||||
|
||||
// issue Get to force redial attempts
|
||||
go c.Get(context.TODO(), "abc")
|
||||
getc := make(chan struct{})
|
||||
go func() {
|
||||
defer close(getc)
|
||||
// Get may hang forever on grpc's Stream.Header() if its
|
||||
// context is never canceled.
|
||||
c.Get(c.Ctx(), "abc")
|
||||
}()
|
||||
|
||||
// wait a little bit so client close is after dial starts
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
@ -65,6 +71,11 @@ func TestDialCancel(t *testing.T) {
|
||||
t.Fatalf("failed to close")
|
||||
case <-donec:
|
||||
}
|
||||
select {
|
||||
case <-time.After(5 * time.Second):
|
||||
t.Fatalf("get failed to exit")
|
||||
case <-getc:
|
||||
}
|
||||
}
|
||||
|
||||
func TestDialTimeout(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user