mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #7869 from heyitsanthony/fix-lease-require-leader-test
clientv3/integration: drain keepalives before waiting for leader loss
This commit is contained in:
commit
2e32d2142d
@ -729,6 +729,12 @@ func TestLeaseWithRequireLeader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clus.Members[1].Stop(t)
|
clus.Members[1].Stop(t)
|
||||||
|
// kaReqLeader may issue multiple requests while waiting for the first
|
||||||
|
// response from proxy server; drain any stray keepalive responses
|
||||||
|
time.Sleep(100 * time.Millisecond)
|
||||||
|
for len(kaReqLeader) > 0 {
|
||||||
|
<-kaReqLeader
|
||||||
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case resp, ok := <-kaReqLeader:
|
case resp, ok := <-kaReqLeader:
|
||||||
|
@ -75,6 +75,7 @@ type proxyCloser struct {
|
|||||||
clientv3.Watcher
|
clientv3.Watcher
|
||||||
wdonec <-chan struct{}
|
wdonec <-chan struct{}
|
||||||
kvdonec <-chan struct{}
|
kvdonec <-chan struct{}
|
||||||
|
lclose func()
|
||||||
lpdonec <-chan struct{}
|
lpdonec <-chan struct{}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +84,7 @@ func (pc *proxyCloser) Close() error {
|
|||||||
<-pc.kvdonec
|
<-pc.kvdonec
|
||||||
err := pc.Watcher.Close()
|
err := pc.Watcher.Close()
|
||||||
<-pc.wdonec
|
<-pc.wdonec
|
||||||
|
pc.lclose()
|
||||||
<-pc.lpdonec
|
<-pc.lpdonec
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -95,11 +97,13 @@ func newClientV3(cfg clientv3.Config) (*clientv3.Client, error) {
|
|||||||
rpc := toGRPC(c)
|
rpc := toGRPC(c)
|
||||||
c.KV = clientv3.NewKVFromKVClient(rpc.KV)
|
c.KV = clientv3.NewKVFromKVClient(rpc.KV)
|
||||||
pmu.Lock()
|
pmu.Lock()
|
||||||
|
lc := c.Lease
|
||||||
c.Lease = clientv3.NewLeaseFromLeaseClient(rpc.Lease, cfg.DialTimeout)
|
c.Lease = clientv3.NewLeaseFromLeaseClient(rpc.Lease, cfg.DialTimeout)
|
||||||
c.Watcher = &proxyCloser{
|
c.Watcher = &proxyCloser{
|
||||||
Watcher: clientv3.NewWatchFromWatchClient(rpc.Watch),
|
Watcher: clientv3.NewWatchFromWatchClient(rpc.Watch),
|
||||||
wdonec: proxies[c].wdonec,
|
wdonec: proxies[c].wdonec,
|
||||||
kvdonec: proxies[c].kvdonec,
|
kvdonec: proxies[c].kvdonec,
|
||||||
|
lclose: func() { lc.Close() },
|
||||||
lpdonec: proxies[c].lpdonec,
|
lpdonec: proxies[c].lpdonec,
|
||||||
}
|
}
|
||||||
pmu.Unlock()
|
pmu.Unlock()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user