fix:etcd get&watch not atomic (#2321)
This commit is contained in:
@@ -2,6 +2,7 @@ package internal
|
||||
|
||||
import (
|
||||
"context"
|
||||
"go.etcd.io/etcd/api/v3/etcdserverpb"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
@@ -112,6 +113,7 @@ func TestCluster_Load(t *testing.T) {
|
||||
restore := setMockClient(cli)
|
||||
defer restore()
|
||||
cli.EXPECT().Get(gomock.Any(), "any/", gomock.Any()).Return(&clientv3.GetResponse{
|
||||
Header: &etcdserverpb.ResponseHeader{},
|
||||
Kvs: []*mvccpb.KeyValue{
|
||||
{
|
||||
Key: []byte("hello"),
|
||||
@@ -168,7 +170,7 @@ func TestCluster_Watch(t *testing.T) {
|
||||
listener.EXPECT().OnDelete(gomock.Any()).Do(func(_ interface{}) {
|
||||
wg.Done()
|
||||
}).MaxTimes(1)
|
||||
go c.watch(cli, "any")
|
||||
go c.watch(cli, "any", 0)
|
||||
ch <- clientv3.WatchResponse{
|
||||
Events: []*clientv3.Event{
|
||||
{
|
||||
@@ -212,7 +214,7 @@ func TestClusterWatch_RespFailures(t *testing.T) {
|
||||
ch <- resp
|
||||
close(c.done)
|
||||
}()
|
||||
c.watch(cli, "any")
|
||||
c.watch(cli, "any", 0)
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -232,7 +234,7 @@ func TestClusterWatch_CloseChan(t *testing.T) {
|
||||
close(ch)
|
||||
close(c.done)
|
||||
}()
|
||||
c.watch(cli, "any")
|
||||
c.watch(cli, "any", 0)
|
||||
}
|
||||
|
||||
func TestValueOnlyContext(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user