mirror of https://github.com/milvus-io/milvus.git
add interface for non-watch metakv (#25092)
Signed-off-by: yiwangdr <yiwangdr@gmail.com>pull/25126/head
parent
7b999b42bd
commit
c7b851f870
|
@ -426,15 +426,28 @@ type MetaKv interface {
|
|||
TxnKV
|
||||
GetPath(key string) string
|
||||
LoadWithPrefix(key string) ([]string, []string, error)
|
||||
Watch(key string) clientv3.WatchChan
|
||||
WatchWithPrefix(key string) clientv3.WatchChan
|
||||
WatchWithRevision(key string, revision int64) clientv3.WatchChan
|
||||
CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) error
|
||||
CompareVersionAndSwap(key string, version int64, target string) error
|
||||
WalkWithPrefix(prefix string, paginationSize int, fn func([]byte, []byte) error) error
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
###### A.7.4 MetaKv
|
||||
###### A.7.4 WatchKV
|
||||
|
||||
```go
|
||||
// WatchKV is watchable MetaKv.
|
||||
//
|
||||
//go:generate mockery --name=WatchKv --with-expecter
|
||||
type WatchKV interface {
|
||||
MetaKv
|
||||
Watch(key string) clientv3.WatchChan
|
||||
WatchWithPrefix(key string) clientv3.WatchChan
|
||||
WatchWithRevision(key string, revision int64) clientv3.WatchChan
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
###### A.7.5 SnapShotKv
|
||||
|
||||
```go
|
||||
// SnapShotKV is TxnKV for snapshot data. It must save timestamp.
|
||||
|
@ -446,7 +459,7 @@ type SnapShotKV interface {
|
|||
MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string, ts typeutil.Timestamp, additions ...func(ts typeutil.Timestamp) (string, string, error)) error
|
||||
```
|
||||
|
||||
###### A.7.5 Etcd KV
|
||||
###### A.7.6 Etcd KV
|
||||
|
||||
```go
|
||||
type etcdKV struct {
|
||||
|
@ -475,7 +488,7 @@ func NewEtcdKV(etcdAddr string, rootPath string) *etcdKV
|
|||
|
||||
etcdKV implements all _TxnKV_ interfaces.
|
||||
|
||||
###### A.7.6 Memory KV
|
||||
###### A.7.7 Memory KV
|
||||
|
||||
```go
|
||||
type MemoryKV struct {
|
||||
|
@ -500,7 +513,7 @@ func (kv *MemoryKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, remova
|
|||
|
||||
MemoryKV implements all _TxnKV_ interfaces.
|
||||
|
||||
###### A.7.7 MinIO KV
|
||||
###### A.7.8 MinIO KV
|
||||
|
||||
```go
|
||||
type MinIOKV struct {
|
||||
|
@ -522,7 +535,7 @@ func (kv *MinIOKV) Close()
|
|||
|
||||
MinIOKV implements all _KV_ interfaces.
|
||||
|
||||
###### A.7.8 RocksdbKV KV
|
||||
###### A.7.9 RocksdbKV KV
|
||||
|
||||
```go
|
||||
type RocksdbKV struct {
|
||||
|
|
|
@ -34,7 +34,7 @@ import (
|
|||
)
|
||||
|
||||
type channelStateTimer struct {
|
||||
watchkv kv.MetaKv
|
||||
watchkv kv.WatchKV
|
||||
|
||||
runningTimers sync.Map
|
||||
runningTimerStops sync.Map // channel name to timer stop channels
|
||||
|
@ -45,7 +45,7 @@ type channelStateTimer struct {
|
|||
runningTimerCount atomic.Int32
|
||||
}
|
||||
|
||||
func newChannelStateTimer(kv kv.MetaKv) *channelStateTimer {
|
||||
func newChannelStateTimer(kv kv.WatchKV) *channelStateTimer {
|
||||
return &channelStateTimer{
|
||||
watchkv: kv,
|
||||
timeoutWatcher: make(chan *ackEvent, 20),
|
||||
|
|
|
@ -29,7 +29,7 @@ import (
|
|||
)
|
||||
|
||||
func TestChannelStateTimer(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer kv.Close()
|
||||
|
||||
prefix := Params.CommonCfg.DataCoordWatchSubPath.GetValue()
|
||||
|
|
|
@ -98,7 +98,7 @@ func withBgChecker() ChannelManagerOpt {
|
|||
|
||||
// NewChannelManager creates and returns a new ChannelManager instance.
|
||||
func NewChannelManager(
|
||||
kv kv.MetaKv, // for TxnKv and MetaKv
|
||||
kv kv.WatchKV, // for TxnKv, MetaKv and WatchKV
|
||||
h Handler,
|
||||
options ...ChannelManagerOpt,
|
||||
) (*ChannelManager, error) {
|
||||
|
|
|
@ -35,9 +35,9 @@ import (
|
|||
)
|
||||
|
||||
// waitAndStore simulates DataNode's action
|
||||
func waitAndStore(t *testing.T, metakv kv.MetaKv, key string, waitState, storeState datapb.ChannelWatchState) {
|
||||
func waitAndStore(t *testing.T, watchkv kv.MetaKv, key string, waitState, storeState datapb.ChannelWatchState) {
|
||||
for {
|
||||
v, err := metakv.Load(key)
|
||||
v, err := watchkv.Load(key)
|
||||
if err == nil && len(v) > 0 {
|
||||
watchInfo, err := parseWatchInfo(key, []byte(v))
|
||||
require.NoError(t, err)
|
||||
|
@ -47,7 +47,7 @@ func waitAndStore(t *testing.T, metakv kv.MetaKv, key string, waitState, storeSt
|
|||
data, err := proto.Marshal(watchInfo)
|
||||
require.NoError(t, err)
|
||||
|
||||
metakv.Save(key, string(data))
|
||||
watchkv.Save(key, string(data))
|
||||
break
|
||||
}
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
|
@ -84,10 +84,10 @@ func getOpsWithWatchInfo(nodeID UniqueID, ch *channel) ChannelOpSet {
|
|||
}
|
||||
|
||||
func TestChannelManager_StateTransfer(t *testing.T) {
|
||||
metakv := getMetaKv(t)
|
||||
watchkv := getWatchKV(t)
|
||||
defer func() {
|
||||
metakv.RemoveWithPrefix("")
|
||||
metakv.Close()
|
||||
watchkv.RemoveWithPrefix("")
|
||||
watchkv.Close()
|
||||
}()
|
||||
|
||||
p := "/tmp/milvus_ut/rdb_data"
|
||||
|
@ -105,11 +105,11 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
)
|
||||
|
||||
t.Run("ToWatch-WatchSuccess", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
cName := channelNamePrefix + "ToWatch-WatchSuccess"
|
||||
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -123,8 +123,8 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
chManager.Watch(&channel{Name: cName, CollectionID: collectionID})
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_WatchSuccess, nodeID, cName, collectionID)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_WatchSuccess, nodeID, cName, collectionID)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
_, loaded := chManager.stateTimer.runningTimerStops.Load(cName)
|
||||
|
@ -136,10 +136,10 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ToWatch-WatchFail-ToRelease", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
cName := channelNamePrefix + "ToWatch-WatchFail-ToRelase"
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -153,8 +153,8 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
chManager.Watch(&channel{Name: cName, CollectionID: collectionID})
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchFailure)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToRelease, nodeID, cName, collectionID)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchFailure)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToRelease, nodeID, cName, collectionID)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
_, loaded := chManager.stateTimer.runningTimerStops.Load(cName)
|
||||
|
@ -167,10 +167,10 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ToWatch-Timeout", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
cName := channelNamePrefix + "ToWatch-Timeout"
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -191,7 +191,7 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}
|
||||
chManager.stateTimer.notifyTimeoutWatcher(e)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToRelease, nodeID, cName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToRelease, nodeID, cName, collectionID)
|
||||
assert.Eventually(t, func() bool {
|
||||
_, loaded := chManager.stateTimer.runningTimerStops.Load(cName)
|
||||
return loaded
|
||||
|
@ -206,9 +206,9 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
var oldNode = UniqueID(120)
|
||||
cName := channelNamePrefix + "ToRelease-ReleaseSuccess-Reassign-ToWatch-2-DN"
|
||||
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -219,7 +219,7 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}()
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{
|
||||
{Name: cName, CollectionID: collectionID},
|
||||
|
@ -232,13 +232,13 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, oldNode, cName, collectionID)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, oldNode, cName, collectionID)
|
||||
|
||||
cancel()
|
||||
wg.Wait()
|
||||
|
||||
w, err := metakv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
w, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, w)
|
||||
|
||||
|
@ -248,10 +248,10 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ToRelease-ReleaseSuccess-Reassign-ToWatch-1-DN", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
cName := channelNamePrefix + "ToRelease-ReleaseSuccess-Reassign-ToWatch-1-DN"
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -262,7 +262,7 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}()
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{
|
||||
{Name: cName, CollectionID: collectionID},
|
||||
|
@ -274,9 +274,9 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeID, cName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeID, cName, collectionID)
|
||||
|
||||
assert.Eventually(t, func() bool {
|
||||
_, loaded := chManager.stateTimer.runningTimerStops.Load(cName)
|
||||
|
@ -292,12 +292,12 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
var oldNode = UniqueID(121)
|
||||
|
||||
cName := channelNamePrefix + "ToRelease-ReleaseFail-CleanUpAndDelete-Reassign-ToWatch-2-DN"
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
factory := dependency.NewDefaultFactory(true)
|
||||
_, err := factory.NewMsgStream(context.TODO())
|
||||
require.NoError(t, err)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -308,7 +308,7 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}()
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{
|
||||
{Name: cName, CollectionID: collectionID},
|
||||
|
@ -321,13 +321,13 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseFailure)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, oldNode, cName, collectionID)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseFailure)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, oldNode, cName, collectionID)
|
||||
|
||||
cancel()
|
||||
wg.Wait()
|
||||
|
||||
w, err := metakv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
w, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, w)
|
||||
|
||||
|
@ -337,13 +337,13 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ToRelease-ReleaseFail-CleanUpAndDelete-Reassign-ToWatch-1-DN", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
cName := channelNamePrefix + "ToRelease-ReleaseFail-CleanUpAndDelete-Reassign-ToWatch-1-DN"
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
factory := dependency.NewDefaultFactory(true)
|
||||
_, err := factory.NewMsgStream(context.TODO())
|
||||
require.NoError(t, err)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
require.NoError(t, err)
|
||||
|
||||
wg := sync.WaitGroup{}
|
||||
|
@ -354,7 +354,7 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}()
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{
|
||||
{Name: cName, CollectionID: collectionID},
|
||||
|
@ -366,9 +366,9 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseFailure)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseFailure)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeID, cName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeID, cName, collectionID)
|
||||
assert.Eventually(t, func() bool {
|
||||
_, loaded := chManager.stateTimer.runningTimerStops.Load(cName)
|
||||
return loaded
|
||||
|
@ -381,26 +381,26 @@ func TestChannelManager_StateTransfer(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestChannelManager(t *testing.T) {
|
||||
metakv := getMetaKv(t)
|
||||
watchkv := getWatchKV(t)
|
||||
defer func() {
|
||||
metakv.RemoveWithPrefix("")
|
||||
metakv.Close()
|
||||
watchkv.RemoveWithPrefix("")
|
||||
watchkv.Close()
|
||||
}()
|
||||
|
||||
prefix := Params.CommonCfg.DataCoordWatchSubPath.GetValue()
|
||||
t.Run("test AddNode with avalible node", func(t *testing.T) {
|
||||
// Note: this test is based on the default registerPolicy
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
collectionID = UniqueID(8)
|
||||
nodeID, nodeToAdd = UniqueID(118), UniqueID(811)
|
||||
channel1, channel2 = "channel1", "channel2"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{
|
||||
{Name: channel1, CollectionID: collectionID},
|
||||
|
@ -422,23 +422,23 @@ func TestChannelManager(t *testing.T) {
|
|||
|
||||
assert.True(t, chManager.Match(nodeToAdd, "channel-3"))
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeToAdd, "channel-3", collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeToAdd, "channel-3", collectionID)
|
||||
chManager.stateTimer.removeTimers([]string{"channel-3"})
|
||||
})
|
||||
|
||||
t.Run("test AddNode with no available node", func(t *testing.T) {
|
||||
// Note: this test is based on the default registerPolicy
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
collectionID = UniqueID(8)
|
||||
nodeID = UniqueID(119)
|
||||
channel1, channel2 = "channel1", "channel2"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
bufferID: {bufferID, []*channel{
|
||||
{Name: channel1, CollectionID: collectionID},
|
||||
|
@ -451,10 +451,10 @@ func TestChannelManager(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), channel1)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
key = path.Join(prefix, strconv.FormatInt(nodeID, 10), channel2)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
assert.True(t, chManager.Match(nodeID, channel1))
|
||||
assert.True(t, chManager.Match(nodeID, channel2))
|
||||
|
@ -462,12 +462,12 @@ func TestChannelManager(t *testing.T) {
|
|||
err = chManager.Watch(&channel{Name: "channel-3", CollectionID: collectionID})
|
||||
assert.NoError(t, err)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeID, "channel-3", collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeID, "channel-3", collectionID)
|
||||
chManager.stateTimer.removeTimers([]string{"channel-3"})
|
||||
})
|
||||
|
||||
t.Run("test Watch", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
collectionID = UniqueID(7)
|
||||
nodeID = UniqueID(117)
|
||||
|
@ -475,34 +475,34 @@ func TestChannelManager(t *testing.T) {
|
|||
chanToAdd = "new-channel-watch"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
err = chManager.Watch(&channel{Name: bufferCh, CollectionID: collectionID})
|
||||
assert.NoError(t, err)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, bufferID, bufferCh, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, bufferID, bufferCh, collectionID)
|
||||
|
||||
chManager.store.Add(nodeID)
|
||||
err = chManager.Watch(&channel{Name: chanToAdd, CollectionID: collectionID})
|
||||
assert.NoError(t, err)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeID, chanToAdd, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeID, chanToAdd, collectionID)
|
||||
|
||||
chManager.stateTimer.removeTimers([]string{chanToAdd})
|
||||
})
|
||||
|
||||
t.Run("test Release", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
collectionID = UniqueID(4)
|
||||
nodeID, invalidNodeID = UniqueID(114), UniqueID(999)
|
||||
channelName, invalidChName = "to-release", "invalid-to-release"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{{Name: channelName, CollectionID: collectionID}}},
|
||||
},
|
||||
|
@ -515,11 +515,11 @@ func TestChannelManager(t *testing.T) {
|
|||
assert.NoError(t, err)
|
||||
chManager.stateTimer.removeTimers([]string{channelName})
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToRelease, nodeID, channelName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToRelease, nodeID, channelName, collectionID)
|
||||
})
|
||||
|
||||
t.Run("test Reassign", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var collectionID = UniqueID(5)
|
||||
|
||||
tests := []struct {
|
||||
|
@ -530,7 +530,7 @@ func TestChannelManager(t *testing.T) {
|
|||
{UniqueID(115), "to-delete-chan"},
|
||||
}
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
// prepare tests
|
||||
|
@ -540,7 +540,7 @@ func TestChannelManager(t *testing.T) {
|
|||
err = chManager.store.Update(ops)
|
||||
require.NoError(t, err)
|
||||
|
||||
info, err := metakv.Load(path.Join(prefix, strconv.FormatInt(test.nodeID, 10), test.chName))
|
||||
info, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(test.nodeID, 10), test.chName))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, info)
|
||||
}
|
||||
|
@ -565,19 +565,19 @@ func TestChannelManager(t *testing.T) {
|
|||
chManager.stateTimer.stopIfExist(&ackEvent{releaseSuccessAck, reassignTest.chName, reassignTest.nodeID})
|
||||
|
||||
// channel is added to remainTest because there's only one node left
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, remainTest.nodeID, remainTest.chName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, remainTest.nodeID, remainTest.chName, collectionID)
|
||||
})
|
||||
|
||||
t.Run("test DeleteNode", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
|
||||
var (
|
||||
collectionID = UniqueID(999)
|
||||
)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withStateChecker())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withStateChecker())
|
||||
require.NoError(t, err)
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
1: {1, []*channel{
|
||||
{Name: "channel-1", CollectionID: collectionID},
|
||||
|
@ -595,7 +595,7 @@ func TestChannelManager(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("test CleanupAndReassign", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var collectionID = UniqueID(6)
|
||||
|
||||
tests := []struct {
|
||||
|
@ -609,7 +609,7 @@ func TestChannelManager(t *testing.T) {
|
|||
factory := dependency.NewDefaultFactory(true)
|
||||
_, err := factory.NewMsgStream(context.TODO())
|
||||
require.NoError(t, err)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withMsgstreamFactory(factory))
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
|
@ -620,7 +620,7 @@ func TestChannelManager(t *testing.T) {
|
|||
err = chManager.store.Update(ops)
|
||||
require.NoError(t, err)
|
||||
|
||||
info, err := metakv.Load(path.Join(prefix, strconv.FormatInt(test.nodeID, 10), test.chName))
|
||||
info, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(test.nodeID, 10), test.chName))
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, info)
|
||||
}
|
||||
|
@ -646,18 +646,18 @@ func TestChannelManager(t *testing.T) {
|
|||
chManager.stateTimer.stopIfExist(&ackEvent{releaseSuccessAck, reassignTest.chName, reassignTest.nodeID})
|
||||
|
||||
// channel is added to remainTest because there's only one node left
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, remainTest.nodeID, remainTest.chName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, remainTest.nodeID, remainTest.chName, collectionID)
|
||||
})
|
||||
|
||||
t.Run("test getChannelByNodeAndName", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
nodeID = UniqueID(113)
|
||||
collectionID = UniqueID(3)
|
||||
channelName = "get-channel-by-node-and-name"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
ch := chManager.getChannelByNodeAndName(nodeID, channelName)
|
||||
|
@ -668,7 +668,7 @@ func TestChannelManager(t *testing.T) {
|
|||
assert.Nil(t, ch)
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{{Name: channelName, CollectionID: collectionID}}},
|
||||
},
|
||||
|
@ -680,14 +680,14 @@ func TestChannelManager(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("test fillChannelWatchInfoWithState", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
var (
|
||||
nodeID = UniqueID(111)
|
||||
collectionID = UniqueID(1)
|
||||
channelName = "fill-channel-watchInfo-with-state"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
|
||||
tests := []struct {
|
||||
|
@ -722,7 +722,7 @@ func TestChannelManager(t *testing.T) {
|
|||
channelName = "update-with-timer"
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
chManager.store.Add(nodeID)
|
||||
|
||||
|
@ -731,12 +731,12 @@ func TestChannelManager(t *testing.T) {
|
|||
chManager.updateWithTimer(opSet, datapb.ChannelWatchState_ToWatch)
|
||||
chManager.stateTimer.removeTimers([]string{channelName})
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, nodeID, channelName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, nodeID, channelName, collectionID)
|
||||
})
|
||||
|
||||
t.Run("test background check silent", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
prefix := Params.CommonCfg.DataCoordWatchSubPath.GetValue()
|
||||
var (
|
||||
collectionID = UniqueID(9)
|
||||
|
@ -748,7 +748,7 @@ func TestChannelManager(t *testing.T) {
|
|||
//1. set up channel_manager
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
defer cancel()
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withBgChecker())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withBgChecker())
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, chManager.bgChecker)
|
||||
chManager.Startup(ctx, []int64{nodeID})
|
||||
|
@ -763,8 +763,8 @@ func TestChannelManager(t *testing.T) {
|
|||
assert.False(t, chManager.isSilent())
|
||||
assert.True(t, chManager.stateTimer.hasRunningTimers())
|
||||
key := path.Join(prefix, strconv.FormatInt(nodeID, 10), cName)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_WatchSuccess, nodeID, cName, collectionID)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_WatchSuccess, nodeID, cName, collectionID)
|
||||
|
||||
//4. wait for duration and check silent again
|
||||
time.Sleep(Params.DataCoordCfg.ChannelBalanceSilentDuration.GetAsDuration(time.Second))
|
||||
|
@ -775,10 +775,10 @@ func TestChannelManager(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestChannelManager_Reload(t *testing.T) {
|
||||
metakv := getMetaKv(t)
|
||||
watchkv := getWatchKV(t)
|
||||
defer func() {
|
||||
metakv.RemoveWithPrefix("")
|
||||
metakv.Close()
|
||||
watchkv.RemoveWithPrefix("")
|
||||
watchkv.Close()
|
||||
}()
|
||||
|
||||
var (
|
||||
|
@ -799,15 +799,15 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run("test checkOldNodes", func(t *testing.T) {
|
||||
metakv.RemoveWithPrefix("")
|
||||
watchkv.RemoveWithPrefix("")
|
||||
|
||||
t.Run("ToWatch", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_ToWatch, collectionID, channelName))
|
||||
require.NoError(t, err)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
require.NoError(t, err)
|
||||
|
||||
chManager.checkOldNodes([]UniqueID{nodeID})
|
||||
|
@ -817,12 +817,12 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("ToRelease", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_ToRelease, collectionID, channelName))
|
||||
require.NoError(t, err)
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
require.NoError(t, err)
|
||||
err = chManager.checkOldNodes([]UniqueID{nodeID})
|
||||
assert.NoError(t, err)
|
||||
|
@ -833,73 +833,73 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("WatchFail", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{{Name: channelName, CollectionID: collectionID}}}},
|
||||
}
|
||||
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_WatchFailure, collectionID, channelName))
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
require.NoError(t, err)
|
||||
err = chManager.checkOldNodes([]UniqueID{nodeID})
|
||||
assert.NoError(t, err)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToRelease, nodeID, channelName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToRelease, nodeID, channelName, collectionID)
|
||||
chManager.stateTimer.removeTimers([]string{channelName})
|
||||
})
|
||||
|
||||
t.Run("ReleaseSuccess", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_ReleaseSuccess, collectionID, channelName))
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{{Name: channelName, CollectionID: collectionID}}}},
|
||||
}
|
||||
|
||||
require.NoError(t, err)
|
||||
chManager.AddNode(UniqueID(111))
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
require.NoError(t, err)
|
||||
err = chManager.checkOldNodes([]UniqueID{nodeID})
|
||||
assert.NoError(t, err)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, 111, channelName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, 111, channelName, collectionID)
|
||||
chManager.stateTimer.removeTimers([]string{channelName})
|
||||
|
||||
v, err := metakv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
v, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10)))
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, v)
|
||||
})
|
||||
|
||||
t.Run("ReleaseFail", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler())
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler())
|
||||
require.NoError(t, err)
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_ReleaseFailure, collectionID, channelName))
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
nodeID: {nodeID, []*channel{{Name: channelName, CollectionID: collectionID}}},
|
||||
999: {999, []*channel{}},
|
||||
},
|
||||
}
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName), string(data))
|
||||
require.NoError(t, err)
|
||||
err = chManager.checkOldNodes([]UniqueID{nodeID})
|
||||
assert.NoError(t, err)
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, 999, channelName, collectionID)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, 999, channelName, collectionID)
|
||||
|
||||
v, err := metakv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName))
|
||||
v, err := watchkv.Load(path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName))
|
||||
assert.Error(t, err)
|
||||
assert.Empty(t, v)
|
||||
|
||||
|
@ -907,17 +907,17 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
})
|
||||
|
||||
t.Run("test reload with data", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
defer cancel()
|
||||
|
||||
cm, err := NewChannelManager(metakv, newMockHandler())
|
||||
cm, err := NewChannelManager(watchkv, newMockHandler())
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, cm.AddNode(1))
|
||||
assert.Nil(t, cm.AddNode(2))
|
||||
cm.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
1: {1, []*channel{{Name: "channel1", CollectionID: 1}}},
|
||||
2: {2, []*channel{{Name: "channel2", CollectionID: 1}}},
|
||||
|
@ -926,19 +926,19 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
|
||||
data, err := proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_WatchSuccess, 1, "channel1"))
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(1, 10), "channel1"), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(1, 10), "channel1"), string(data))
|
||||
require.NoError(t, err)
|
||||
data, err = proto.Marshal(getWatchInfoWithState(datapb.ChannelWatchState_WatchSuccess, 1, "channel2"))
|
||||
require.NoError(t, err)
|
||||
err = metakv.Save(path.Join(prefix, strconv.FormatInt(2, 10), "channel2"), string(data))
|
||||
err = watchkv.Save(path.Join(prefix, strconv.FormatInt(2, 10), "channel2"), string(data))
|
||||
require.NoError(t, err)
|
||||
|
||||
cm2, err := NewChannelManager(metakv, newMockHandler())
|
||||
cm2, err := NewChannelManager(watchkv, newMockHandler())
|
||||
assert.NoError(t, err)
|
||||
assert.Nil(t, cm2.Startup(ctx, []int64{3}))
|
||||
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, 3, "channel1", 1)
|
||||
waitAndCheckState(t, metakv, datapb.ChannelWatchState_ToWatch, 3, "channel2", 1)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, 3, "channel1", 1)
|
||||
waitAndCheckState(t, watchkv, datapb.ChannelWatchState_ToWatch, 3, "channel2", 1)
|
||||
assert.True(t, cm2.Match(3, "channel1"))
|
||||
assert.True(t, cm2.Match(3, "channel2"))
|
||||
|
||||
|
@ -947,22 +947,22 @@ func TestChannelManager_Reload(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
||||
metakv := getMetaKv(t)
|
||||
watchkv := getWatchKV(t)
|
||||
defer func() {
|
||||
metakv.RemoveWithPrefix("")
|
||||
metakv.Close()
|
||||
watchkv.RemoveWithPrefix("")
|
||||
watchkv.Close()
|
||||
}()
|
||||
|
||||
prefix := Params.CommonCfg.DataCoordWatchSubPath.GetValue()
|
||||
|
||||
t.Run("one node with three channels add a new node", func(t *testing.T) {
|
||||
defer metakv.RemoveWithPrefix("")
|
||||
defer watchkv.RemoveWithPrefix("")
|
||||
|
||||
var (
|
||||
collectionID = UniqueID(999)
|
||||
)
|
||||
|
||||
chManager, err := NewChannelManager(metakv, newMockHandler(), withStateChecker())
|
||||
chManager, err := NewChannelManager(watchkv, newMockHandler(), withStateChecker())
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.TODO())
|
||||
|
@ -971,7 +971,7 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
go chManager.stateChecker(ctx, common.LatestRevision)
|
||||
|
||||
chManager.store = &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
1: {1, []*channel{
|
||||
{Name: "channel-1", CollectionID: collectionID},
|
||||
|
@ -989,7 +989,7 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
// waitAndStore := func(waitState, storeState datapb.ChannelWatchState, nodeID UniqueID, channelName string) {
|
||||
// for {
|
||||
// key := path.Join(prefix, strconv.FormatInt(nodeID, 10), channelName)
|
||||
// v, err := metakv.Load(key)
|
||||
// v, err := watchkv.Load(key)
|
||||
// if err == nil && len(v) > 0 {
|
||||
// watchInfo, err := parseWatchInfo(key, []byte(v))
|
||||
// require.NoError(t, err)
|
||||
|
@ -999,7 +999,7 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
// data, err := proto.Marshal(watchInfo)
|
||||
// require.NoError(t, err)
|
||||
//
|
||||
// metakv.Save(key, string(data))
|
||||
// watchkv.Save(key, string(data))
|
||||
// break
|
||||
// }
|
||||
// time.Sleep(100 * time.Millisecond)
|
||||
|
@ -1007,10 +1007,10 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
// }
|
||||
|
||||
key := path.Join(prefix, "1", channelBalanced)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToRelease, datapb.ChannelWatchState_ReleaseSuccess)
|
||||
|
||||
key = path.Join(prefix, "2", channelBalanced)
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
assert.True(t, chManager.Match(1, "channel-2"))
|
||||
assert.True(t, chManager.Match(1, "channel-3"))
|
||||
|
@ -1020,7 +1020,7 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
chManager.AddNode(3)
|
||||
chManager.Watch(&channel{Name: "channel-4", CollectionID: collectionID})
|
||||
key = path.Join(prefix, "3", "channel-4")
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
assert.True(t, chManager.Match(1, "channel-2"))
|
||||
assert.True(t, chManager.Match(1, "channel-3"))
|
||||
|
@ -1029,7 +1029,7 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
|
||||
chManager.DeleteNode(3)
|
||||
key = path.Join(prefix, "2", "channel-4")
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
assert.True(t, chManager.Match(1, "channel-2"))
|
||||
assert.True(t, chManager.Match(1, "channel-3"))
|
||||
|
@ -1038,9 +1038,9 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
|
||||
chManager.DeleteNode(2)
|
||||
key = path.Join(prefix, "1", "channel-4")
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
key = path.Join(prefix, "1", "channel-1")
|
||||
waitAndStore(t, metakv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
waitAndStore(t, watchkv, key, datapb.ChannelWatchState_ToWatch, datapb.ChannelWatchState_WatchSuccess)
|
||||
|
||||
assert.True(t, chManager.Match(1, "channel-2"))
|
||||
assert.True(t, chManager.Match(1, "channel-3"))
|
||||
|
@ -1051,10 +1051,10 @@ func TestChannelManager_BalanceBehaviour(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestChannelManager_RemoveChannel(t *testing.T) {
|
||||
metakv := getMetaKv(t)
|
||||
watchkv := getWatchKV(t)
|
||||
defer func() {
|
||||
metakv.RemoveWithPrefix("")
|
||||
metakv.Close()
|
||||
watchkv.RemoveWithPrefix("")
|
||||
watchkv.Close()
|
||||
}()
|
||||
|
||||
type fields struct {
|
||||
|
@ -1073,7 +1073,7 @@ func TestChannelManager_RemoveChannel(t *testing.T) {
|
|||
"test remove existed channel",
|
||||
fields{
|
||||
store: &ChannelStore{
|
||||
store: metakv,
|
||||
store: watchkv,
|
||||
channelsInfo: map[int64]*NodeChannelInfo{
|
||||
1: {
|
||||
NodeID: 1,
|
||||
|
|
|
@ -35,14 +35,22 @@ import (
|
|||
|
||||
func getMetaKv(t *testing.T) kv.MetaKv {
|
||||
rootPath := "/etcd/test/root/" + t.Name()
|
||||
metakv, err := etcdkv.NewMetaKvFactory(rootPath, &Params.EtcdCfg)
|
||||
kv, err := etcdkv.NewMetaKvFactory(rootPath, &Params.EtcdCfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
return metakv
|
||||
return kv
|
||||
}
|
||||
|
||||
func getWatchKV(t *testing.T) kv.WatchKV {
|
||||
rootPath := "/etcd/test/root/" + t.Name()
|
||||
kv, err := etcdkv.NewWatchKVFactory(rootPath, &Params.EtcdCfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
return kv
|
||||
}
|
||||
|
||||
func TestClusterCreate(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -155,7 +163,7 @@ func TestClusterCreate(t *testing.T) {
|
|||
t.Run("loadKv Fails", func(t *testing.T) {
|
||||
defer kv.RemoveWithPrefix("")
|
||||
|
||||
fkv := &loadPrefixFailKV{MetaKv: kv}
|
||||
fkv := &loadPrefixFailKV{WatchKV: kv}
|
||||
_, err := NewChannelManager(fkv, newMockHandler())
|
||||
assert.Error(t, err)
|
||||
})
|
||||
|
@ -163,7 +171,7 @@ func TestClusterCreate(t *testing.T) {
|
|||
|
||||
// a mock kv that always fail when LoadWithPrefix
|
||||
type loadPrefixFailKV struct {
|
||||
kv.MetaKv
|
||||
kv.WatchKV
|
||||
}
|
||||
|
||||
// LoadWithPrefix override behavior
|
||||
|
@ -172,7 +180,7 @@ func (kv *loadPrefixFailKV) LoadWithPrefix(key string) ([]string, []string, erro
|
|||
}
|
||||
|
||||
func TestRegister(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -268,7 +276,7 @@ func TestRegister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestUnregister(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -369,7 +377,7 @@ func TestUnregister(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestWatchIfNeeded(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -426,7 +434,7 @@ func TestWatchIfNeeded(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestConsistentHashPolicy(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -508,7 +516,7 @@ func TestConsistentHashPolicy(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCluster_Flush(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -555,7 +563,7 @@ func TestCluster_Flush(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCluster_Import(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -587,7 +595,7 @@ func TestCluster_Import(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestCluster_ReCollectSegmentStats(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
|
|
@ -79,7 +79,7 @@ func (mm *metaMemoryKV) WatchWithRevision(key string, revision int64) clientv3.W
|
|||
panic("implement me")
|
||||
}
|
||||
|
||||
func (mm *metaMemoryKV) CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) (bool, error) {
|
||||
func (mm *metaMemoryKV) CompareVersionAndSwap(key string, version int64, target string) (bool, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ type Server struct {
|
|||
|
||||
etcdCli *clientv3.Client
|
||||
address string
|
||||
kvClient kv.MetaKv
|
||||
kvClient kv.WatchKV
|
||||
meta *meta
|
||||
segmentManager Manager
|
||||
allocator allocator
|
||||
|
|
|
@ -3171,7 +3171,7 @@ func TestGetCompactionStateWithPlans(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestOptions(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
@ -3242,7 +3242,7 @@ func (p *mockPolicyFactory) NewDeregisterPolicy() DeregisterPolicy {
|
|||
}
|
||||
|
||||
func TestHandleSessionEvent(t *testing.T) {
|
||||
kv := getMetaKv(t)
|
||||
kv := getWatchKV(t)
|
||||
defer func() {
|
||||
kv.RemoveWithPrefix("")
|
||||
kv.Close()
|
||||
|
|
|
@ -121,7 +121,7 @@ type DataNode struct {
|
|||
wg sync.WaitGroup
|
||||
sessionMu sync.Mutex // to fix data race
|
||||
session *sessionutil.Session
|
||||
watchKv kv.MetaKv
|
||||
watchKv kv.WatchKV
|
||||
chunkManager storage.ChunkManager
|
||||
allocator allocator.Allocator
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ func makeNewChannelNames(names []string, suffix string) []string {
|
|||
return ret
|
||||
}
|
||||
|
||||
func newTestEtcdKV() (kv.MetaKv, error) {
|
||||
func newTestEtcdKV() (kv.WatchKV, error) {
|
||||
etcdCli, err := etcd.GetEtcdClient(
|
||||
Params.EtcdCfg.UseEmbedEtcd.GetAsBool(),
|
||||
Params.EtcdCfg.EtcdUseSSL.GetAsBool(),
|
||||
|
|
|
@ -499,7 +499,7 @@ func (kv *EmbedEtcdKV) MultiSaveBytesAndRemoveWithPrefix(saves map[string][]byte
|
|||
|
||||
// CompareVersionAndSwap compares the existing key-value's version with version, and if
|
||||
// they are equal, the target is stored in etcd.
|
||||
func (kv *EmbedEtcdKV) CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) (bool, error) {
|
||||
func (kv *EmbedEtcdKV) CompareVersionAndSwap(key string, version int64, target string) (bool, error) {
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), RequestTimeout)
|
||||
defer cancel()
|
||||
resp, err := kv.client.Txn(ctx).If(
|
||||
|
@ -507,7 +507,7 @@ func (kv *EmbedEtcdKV) CompareVersionAndSwap(key string, version int64, target s
|
|||
clientv3.Version(path.Join(kv.rootPath, key)),
|
||||
"=",
|
||||
version)).
|
||||
Then(clientv3.OpPut(path.Join(kv.rootPath, key), target, opts...)).Commit()
|
||||
Then(clientv3.OpPut(path.Join(kv.rootPath, key), target)).Commit()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
@ -701,17 +701,17 @@ func TestEmbedEtcd(te *testing.T) {
|
|||
|
||||
te.Run("etcdKV Watch", func(t *testing.T) {
|
||||
rootPath := "/etcd/test/root/watch"
|
||||
metaKv, err := embed_etcd_kv.NewMetaKvFactory(rootPath, ¶m.EtcdCfg)
|
||||
watchKv, err := embed_etcd_kv.NewWatchKVFactory(rootPath, ¶m.EtcdCfg)
|
||||
assert.NoError(t, err)
|
||||
|
||||
defer metaKv.Close()
|
||||
defer metaKv.RemoveWithPrefix("")
|
||||
defer watchKv.Close()
|
||||
defer watchKv.RemoveWithPrefix("")
|
||||
|
||||
ch := metaKv.Watch("x")
|
||||
ch := watchKv.Watch("x")
|
||||
resp := <-ch
|
||||
assert.True(t, resp.Created)
|
||||
|
||||
ch = metaKv.WatchWithPrefix("x")
|
||||
ch = watchKv.WatchWithPrefix("x")
|
||||
resp = <-ch
|
||||
assert.True(t, resp.Created)
|
||||
})
|
||||
|
|
|
@ -579,7 +579,7 @@ func (kv *etcdKV) MultiSaveBytesAndRemoveWithPrefix(saves map[string][]byte, rem
|
|||
|
||||
// CompareVersionAndSwap compares the existing key-value's version with version, and if
|
||||
// they are equal, the target is stored in etcd.
|
||||
func (kv *etcdKV) CompareVersionAndSwap(key string, source int64, target string, opts ...clientv3.OpOption) (bool, error) {
|
||||
func (kv *etcdKV) CompareVersionAndSwap(key string, source int64, target string) (bool, error) {
|
||||
start := time.Now()
|
||||
ctx, cancel := context.WithTimeout(context.TODO(), RequestTimeout)
|
||||
defer cancel()
|
||||
|
@ -588,7 +588,7 @@ func (kv *etcdKV) CompareVersionAndSwap(key string, source int64, target string,
|
|||
clientv3.Version(path.Join(kv.rootPath, key)),
|
||||
"=",
|
||||
source)).
|
||||
Then(clientv3.OpPut(path.Join(kv.rootPath, key), target, opts...)).Commit()
|
||||
Then(clientv3.OpPut(path.Join(kv.rootPath, key), target)).Commit()
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
|
|
@ -26,9 +26,9 @@ import (
|
|||
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
||||
)
|
||||
|
||||
// NewMetaKvFactory returns an object that implements the kv.MetaKv interface using etcd.
|
||||
// NewWatchKVFactory returns an object that implements the kv.WatchKV interface using etcd.
|
||||
// The UseEmbedEtcd in the param is used to determine whether the etcd service is external or embedded.
|
||||
func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaKv, error) {
|
||||
func NewWatchKVFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.WatchKV, error) {
|
||||
log.Info("start etcd with rootPath",
|
||||
zap.String("rootpath", rootPath),
|
||||
zap.Bool("isEmbed", etcdCfg.UseEmbedEtcd.GetAsBool()))
|
||||
|
@ -45,11 +45,11 @@ func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaK
|
|||
cfg = embed.NewConfig()
|
||||
}
|
||||
cfg.Dir = etcdCfg.DataDir.GetValue()
|
||||
metaKv, err := NewEmbededEtcdKV(cfg, rootPath)
|
||||
watchKv, err := NewEmbededEtcdKV(cfg, rootPath)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return metaKv, err
|
||||
return watchKv, err
|
||||
}
|
||||
client, err := etcd.GetEtcdClient(
|
||||
etcdCfg.UseEmbedEtcd.GetAsBool(),
|
||||
|
@ -62,6 +62,12 @@ func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaK
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
metaKv := NewEtcdKV(client, rootPath)
|
||||
return metaKv, err
|
||||
watchKv := NewEtcdKV(client, rootPath)
|
||||
return watchKv, err
|
||||
}
|
||||
|
||||
// NewMetaKvFactory returns an object that implements the kv.MetaKv interface using etcd.
|
||||
// The UseEmbedEtcd in the param is used to determine whether the etcd service is external or embedded.
|
||||
func NewMetaKvFactory(rootPath string, etcdCfg *paramtable.EtcdConfig) (kv.MetaKv, error) {
|
||||
return NewWatchKVFactory(rootPath, etcdCfg)
|
||||
}
|
||||
|
|
|
@ -67,11 +67,18 @@ type MetaKv interface {
|
|||
TxnKV
|
||||
GetPath(key string) string
|
||||
LoadWithPrefix(key string) ([]string, []string, error)
|
||||
CompareVersionAndSwap(key string, version int64, target string) (bool, error)
|
||||
WalkWithPrefix(prefix string, paginationSize int, fn func([]byte, []byte) error) error
|
||||
}
|
||||
|
||||
// WatchKV is watchable MetaKv. As of today(2023/06/24), it's coupled with etcd.
|
||||
//
|
||||
//go:generate mockery --name=WatchKV --with-expecter
|
||||
type WatchKV interface {
|
||||
MetaKv
|
||||
Watch(key string) clientv3.WatchChan
|
||||
WatchWithPrefix(key string) clientv3.WatchChan
|
||||
WatchWithRevision(key string, revision int64) clientv3.WatchChan
|
||||
CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) (bool, error)
|
||||
WalkWithPrefix(prefix string, paginationSize int, fn func([]byte, []byte) error) error
|
||||
}
|
||||
|
||||
// SnapShotKV is TxnKV for snapshot data. It must save timestamp.
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
// Code generated by mockery v2.16.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.30.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
import mock "github.com/stretchr/testify/mock"
|
||||
|
||||
// MetaKv is an autogenerated mock type for the MetaKv type
|
||||
type MetaKv struct {
|
||||
|
@ -48,88 +44,28 @@ func (_c *MetaKv_Close_Call) Return() *MetaKv_Close_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
// CompareValueAndSwap provides a mock function with given fields: key, value, target, opts
|
||||
func (_m *MetaKv) CompareValueAndSwap(key string, value string, target string, opts ...clientv3.OpOption) (bool, error) {
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, key, value, target)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
func (_c *MetaKv_Close_Call) RunAndReturn(run func()) *MetaKv_Close_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// CompareVersionAndSwap provides a mock function with given fields: key, version, target
|
||||
func (_m *MetaKv) CompareVersionAndSwap(key string, version int64, target string) (bool, error) {
|
||||
ret := _m.Called(key, version, target)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(string, string, string, ...clientv3.OpOption) bool); ok {
|
||||
r0 = rf(key, value, target, opts...)
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, int64, string) (bool, error)); ok {
|
||||
return rf(key, version, target)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, int64, string) bool); ok {
|
||||
r0 = rf(key, version, target)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, string, ...clientv3.OpOption) error); ok {
|
||||
r1 = rf(key, value, target, opts...)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MetaKv_CompareValueAndSwap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CompareValueAndSwap'
|
||||
type MetaKv_CompareValueAndSwap_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// CompareValueAndSwap is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - value string
|
||||
// - target string
|
||||
// - opts ...clientv3.OpOption
|
||||
func (_e *MetaKv_Expecter) CompareValueAndSwap(key interface{}, value interface{}, target interface{}, opts ...interface{}) *MetaKv_CompareValueAndSwap_Call {
|
||||
return &MetaKv_CompareValueAndSwap_Call{Call: _e.mock.On("CompareValueAndSwap",
|
||||
append([]interface{}{key, value, target}, opts...)...)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_CompareValueAndSwap_Call) Run(run func(key string, value string, target string, opts ...clientv3.OpOption)) *MetaKv_CompareValueAndSwap_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]clientv3.OpOption, len(args)-3)
|
||||
for i, a := range args[3:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(clientv3.OpOption)
|
||||
}
|
||||
}
|
||||
run(args[0].(string), args[1].(string), args[2].(string), variadicArgs...)
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_CompareValueAndSwap_Call) Return(_a0 bool, _a1 error) *MetaKv_CompareValueAndSwap_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
// CompareVersionAndSwap provides a mock function with given fields: key, version, target, opts
|
||||
func (_m *MetaKv) CompareVersionAndSwap(key string, version int64, target string, opts ...clientv3.OpOption) (bool, error) {
|
||||
_va := make([]interface{}, len(opts))
|
||||
for _i := range opts {
|
||||
_va[_i] = opts[_i]
|
||||
}
|
||||
var _ca []interface{}
|
||||
_ca = append(_ca, key, version, target)
|
||||
_ca = append(_ca, _va...)
|
||||
ret := _m.Called(_ca...)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(string, int64, string, ...clientv3.OpOption) bool); ok {
|
||||
r0 = rf(key, version, target, opts...)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, int64, string, ...clientv3.OpOption) error); ok {
|
||||
r1 = rf(key, version, target, opts...)
|
||||
if rf, ok := ret.Get(1).(func(string, int64, string) error); ok {
|
||||
r1 = rf(key, version, target)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
@ -146,21 +82,13 @@ type MetaKv_CompareVersionAndSwap_Call struct {
|
|||
// - key string
|
||||
// - version int64
|
||||
// - target string
|
||||
// - opts ...clientv3.OpOption
|
||||
func (_e *MetaKv_Expecter) CompareVersionAndSwap(key interface{}, version interface{}, target interface{}, opts ...interface{}) *MetaKv_CompareVersionAndSwap_Call {
|
||||
return &MetaKv_CompareVersionAndSwap_Call{Call: _e.mock.On("CompareVersionAndSwap",
|
||||
append([]interface{}{key, version, target}, opts...)...)}
|
||||
func (_e *MetaKv_Expecter) CompareVersionAndSwap(key interface{}, version interface{}, target interface{}) *MetaKv_CompareVersionAndSwap_Call {
|
||||
return &MetaKv_CompareVersionAndSwap_Call{Call: _e.mock.On("CompareVersionAndSwap", key, version, target)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_CompareVersionAndSwap_Call) Run(run func(key string, version int64, target string, opts ...clientv3.OpOption)) *MetaKv_CompareVersionAndSwap_Call {
|
||||
func (_c *MetaKv_CompareVersionAndSwap_Call) Run(run func(key string, version int64, target string)) *MetaKv_CompareVersionAndSwap_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
variadicArgs := make([]clientv3.OpOption, len(args)-3)
|
||||
for i, a := range args[3:] {
|
||||
if a != nil {
|
||||
variadicArgs[i] = a.(clientv3.OpOption)
|
||||
}
|
||||
}
|
||||
run(args[0].(string), args[1].(int64), args[2].(string), variadicArgs...)
|
||||
run(args[0].(string), args[1].(int64), args[2].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
@ -170,6 +98,11 @@ func (_c *MetaKv_CompareVersionAndSwap_Call) Return(_a0 bool, _a1 error) *MetaKv
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_CompareVersionAndSwap_Call) RunAndReturn(run func(string, int64, string) (bool, error)) *MetaKv_CompareVersionAndSwap_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetPath provides a mock function with given fields: key
|
||||
func (_m *MetaKv) GetPath(key string) string {
|
||||
ret := _m.Called(key)
|
||||
|
@ -207,93 +140,8 @@ func (_c *MetaKv_GetPath_Call) Return(_a0 string) *MetaKv_GetPath_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
// Grant provides a mock function with given fields: ttl
|
||||
func (_m *MetaKv) Grant(ttl int64) (clientv3.LeaseID, error) {
|
||||
ret := _m.Called(ttl)
|
||||
|
||||
var r0 clientv3.LeaseID
|
||||
if rf, ok := ret.Get(0).(func(int64) clientv3.LeaseID); ok {
|
||||
r0 = rf(ttl)
|
||||
} else {
|
||||
r0 = ret.Get(0).(clientv3.LeaseID)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(int64) error); ok {
|
||||
r1 = rf(ttl)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MetaKv_Grant_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Grant'
|
||||
type MetaKv_Grant_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Grant is a helper method to define mock.On call
|
||||
// - ttl int64
|
||||
func (_e *MetaKv_Expecter) Grant(ttl interface{}) *MetaKv_Grant_Call {
|
||||
return &MetaKv_Grant_Call{Call: _e.mock.On("Grant", ttl)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Grant_Call) Run(run func(ttl int64)) *MetaKv_Grant_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(int64))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Grant_Call) Return(id clientv3.LeaseID, err error) *MetaKv_Grant_Call {
|
||||
_c.Call.Return(id, err)
|
||||
return _c
|
||||
}
|
||||
|
||||
// KeepAlive provides a mock function with given fields: id
|
||||
func (_m *MetaKv) KeepAlive(id clientv3.LeaseID) (<-chan *clientv3.LeaseKeepAliveResponse, error) {
|
||||
ret := _m.Called(id)
|
||||
|
||||
var r0 <-chan *clientv3.LeaseKeepAliveResponse
|
||||
if rf, ok := ret.Get(0).(func(clientv3.LeaseID) <-chan *clientv3.LeaseKeepAliveResponse); ok {
|
||||
r0 = rf(id)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(<-chan *clientv3.LeaseKeepAliveResponse)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(clientv3.LeaseID) error); ok {
|
||||
r1 = rf(id)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// MetaKv_KeepAlive_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'KeepAlive'
|
||||
type MetaKv_KeepAlive_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// KeepAlive is a helper method to define mock.On call
|
||||
// - id clientv3.LeaseID
|
||||
func (_e *MetaKv_Expecter) KeepAlive(id interface{}) *MetaKv_KeepAlive_Call {
|
||||
return &MetaKv_KeepAlive_Call{Call: _e.mock.On("KeepAlive", id)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_KeepAlive_Call) Run(run func(id clientv3.LeaseID)) *MetaKv_KeepAlive_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(clientv3.LeaseID))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_KeepAlive_Call) Return(_a0 <-chan *clientv3.LeaseKeepAliveResponse, _a1 error) *MetaKv_KeepAlive_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
func (_c *MetaKv_GetPath_Call) RunAndReturn(run func(string) string) *MetaKv_GetPath_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
|
@ -302,13 +150,16 @@ func (_m *MetaKv) Load(key string) (string, error) {
|
|||
ret := _m.Called(key)
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
|
@ -341,11 +192,21 @@ func (_c *MetaKv_Load_Call) Return(_a0 string, _a1 error) *MetaKv_Load_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Load_Call) RunAndReturn(run func(string) (string, error)) *MetaKv_Load_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithPrefix provides a mock function with given fields: key
|
||||
func (_m *MetaKv) LoadWithPrefix(key string) ([]string, []string, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
var r1 []string
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(string) ([]string, []string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
|
@ -354,7 +215,6 @@ func (_m *MetaKv) LoadWithPrefix(key string) ([]string, []string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
|
@ -363,7 +223,6 @@ func (_m *MetaKv) LoadWithPrefix(key string) ([]string, []string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(2).(func(string) error); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
|
@ -396,200 +255,8 @@ func (_c *MetaKv_LoadWithPrefix_Call) Return(_a0 []string, _a1 []string, _a2 err
|
|||
return _c
|
||||
}
|
||||
|
||||
// LoadWithPrefix2 provides a mock function with given fields: key
|
||||
func (_m *MetaKv) LoadWithPrefix2(key string) ([]string, []string, []int64, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r2 []int64
|
||||
if rf, ok := ret.Get(2).(func(string) []int64); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
if ret.Get(2) != nil {
|
||||
r2 = ret.Get(2).([]int64)
|
||||
}
|
||||
}
|
||||
|
||||
var r3 error
|
||||
if rf, ok := ret.Get(3).(func(string) error); ok {
|
||||
r3 = rf(key)
|
||||
} else {
|
||||
r3 = ret.Error(3)
|
||||
}
|
||||
|
||||
return r0, r1, r2, r3
|
||||
}
|
||||
|
||||
// MetaKv_LoadWithPrefix2_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadWithPrefix2'
|
||||
type MetaKv_LoadWithPrefix2_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LoadWithPrefix2 is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *MetaKv_Expecter) LoadWithPrefix2(key interface{}) *MetaKv_LoadWithPrefix2_Call {
|
||||
return &MetaKv_LoadWithPrefix2_Call{Call: _e.mock.On("LoadWithPrefix2", key)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithPrefix2_Call) Run(run func(key string)) *MetaKv_LoadWithPrefix2_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithPrefix2_Call) Return(_a0 []string, _a1 []string, _a2 []int64, _a3 error) *MetaKv_LoadWithPrefix2_Call {
|
||||
_c.Call.Return(_a0, _a1, _a2, _a3)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithRevision provides a mock function with given fields: key
|
||||
func (_m *MetaKv) LoadWithRevision(key string) ([]string, []string, int64, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r2 int64
|
||||
if rf, ok := ret.Get(2).(func(string) int64); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
r2 = ret.Get(2).(int64)
|
||||
}
|
||||
|
||||
var r3 error
|
||||
if rf, ok := ret.Get(3).(func(string) error); ok {
|
||||
r3 = rf(key)
|
||||
} else {
|
||||
r3 = ret.Error(3)
|
||||
}
|
||||
|
||||
return r0, r1, r2, r3
|
||||
}
|
||||
|
||||
// MetaKv_LoadWithRevision_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadWithRevision'
|
||||
type MetaKv_LoadWithRevision_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LoadWithRevision is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *MetaKv_Expecter) LoadWithRevision(key interface{}) *MetaKv_LoadWithRevision_Call {
|
||||
return &MetaKv_LoadWithRevision_Call{Call: _e.mock.On("LoadWithRevision", key)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithRevision_Call) Run(run func(key string)) *MetaKv_LoadWithRevision_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithRevision_Call) Return(_a0 []string, _a1 []string, _a2 int64, _a3 error) *MetaKv_LoadWithRevision_Call {
|
||||
_c.Call.Return(_a0, _a1, _a2, _a3)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithRevisionAndVersions provides a mock function with given fields: key
|
||||
func (_m *MetaKv) LoadWithRevisionAndVersions(key string) ([]string, []string, []int64, int64, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
var r2 []int64
|
||||
if rf, ok := ret.Get(2).(func(string) []int64); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
if ret.Get(2) != nil {
|
||||
r2 = ret.Get(2).([]int64)
|
||||
}
|
||||
}
|
||||
|
||||
var r3 int64
|
||||
if rf, ok := ret.Get(3).(func(string) int64); ok {
|
||||
r3 = rf(key)
|
||||
} else {
|
||||
r3 = ret.Get(3).(int64)
|
||||
}
|
||||
|
||||
var r4 error
|
||||
if rf, ok := ret.Get(4).(func(string) error); ok {
|
||||
r4 = rf(key)
|
||||
} else {
|
||||
r4 = ret.Error(4)
|
||||
}
|
||||
|
||||
return r0, r1, r2, r3, r4
|
||||
}
|
||||
|
||||
// MetaKv_LoadWithRevisionAndVersions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadWithRevisionAndVersions'
|
||||
type MetaKv_LoadWithRevisionAndVersions_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LoadWithRevisionAndVersions is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *MetaKv_Expecter) LoadWithRevisionAndVersions(key interface{}) *MetaKv_LoadWithRevisionAndVersions_Call {
|
||||
return &MetaKv_LoadWithRevisionAndVersions_Call{Call: _e.mock.On("LoadWithRevisionAndVersions", key)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithRevisionAndVersions_Call) Run(run func(key string)) *MetaKv_LoadWithRevisionAndVersions_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_LoadWithRevisionAndVersions_Call) Return(_a0 []string, _a1 []string, _a2 []int64, _a3 int64, _a4 error) *MetaKv_LoadWithRevisionAndVersions_Call {
|
||||
_c.Call.Return(_a0, _a1, _a2, _a3, _a4)
|
||||
func (_c *MetaKv_LoadWithPrefix_Call) RunAndReturn(run func(string) ([]string, []string, error)) *MetaKv_LoadWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
|
@ -598,6 +265,10 @@ func (_m *MetaKv) MultiLoad(keys []string) ([]string, error) {
|
|||
ret := _m.Called(keys)
|
||||
|
||||
var r0 []string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]string) ([]string, error)); ok {
|
||||
return rf(keys)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]string) []string); ok {
|
||||
r0 = rf(keys)
|
||||
} else {
|
||||
|
@ -606,7 +277,6 @@ func (_m *MetaKv) MultiLoad(keys []string) ([]string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]string) error); ok {
|
||||
r1 = rf(keys)
|
||||
} else {
|
||||
|
@ -639,6 +309,11 @@ func (_c *MetaKv_MultiLoad_Call) Return(_a0 []string, _a1 error) *MetaKv_MultiLo
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiLoad_Call) RunAndReturn(run func([]string) ([]string, error)) *MetaKv_MultiLoad_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemove provides a mock function with given fields: keys
|
||||
func (_m *MetaKv) MultiRemove(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
@ -676,6 +351,11 @@ func (_c *MetaKv_MultiRemove_Call) Return(_a0 error) *MetaKv_MultiRemove_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiRemove_Call) RunAndReturn(run func([]string) error) *MetaKv_MultiRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemoveWithPrefix provides a mock function with given fields: keys
|
||||
func (_m *MetaKv) MultiRemoveWithPrefix(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
@ -713,6 +393,11 @@ func (_c *MetaKv_MultiRemoveWithPrefix_Call) Return(_a0 error) *MetaKv_MultiRemo
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiRemoveWithPrefix_Call) RunAndReturn(run func([]string) error) *MetaKv_MultiRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSave provides a mock function with given fields: kvs
|
||||
func (_m *MetaKv) MultiSave(kvs map[string]string) error {
|
||||
ret := _m.Called(kvs)
|
||||
|
@ -750,6 +435,11 @@ func (_c *MetaKv_MultiSave_Call) Return(_a0 error) *MetaKv_MultiSave_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiSave_Call) RunAndReturn(run func(map[string]string) error) *MetaKv_MultiSave_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemove provides a mock function with given fields: saves, removals
|
||||
func (_m *MetaKv) MultiSaveAndRemove(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
@ -788,6 +478,11 @@ func (_c *MetaKv_MultiSaveAndRemove_Call) Return(_a0 error) *MetaKv_MultiSaveAnd
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiSaveAndRemove_Call) RunAndReturn(run func(map[string]string, []string) error) *MetaKv_MultiSaveAndRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemoveWithPrefix provides a mock function with given fields: saves, removals
|
||||
func (_m *MetaKv) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
@ -826,6 +521,11 @@ func (_c *MetaKv_MultiSaveAndRemoveWithPrefix_Call) Return(_a0 error) *MetaKv_Mu
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_MultiSaveAndRemoveWithPrefix_Call) RunAndReturn(run func(map[string]string, []string) error) *MetaKv_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Remove provides a mock function with given fields: key
|
||||
func (_m *MetaKv) Remove(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
@ -863,6 +563,11 @@ func (_c *MetaKv_Remove_Call) Return(_a0 error) *MetaKv_Remove_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Remove_Call) RunAndReturn(run func(string) error) *MetaKv_Remove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// RemoveWithPrefix provides a mock function with given fields: key
|
||||
func (_m *MetaKv) RemoveWithPrefix(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
@ -900,6 +605,11 @@ func (_c *MetaKv_RemoveWithPrefix_Call) Return(_a0 error) *MetaKv_RemoveWithPref
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_RemoveWithPrefix_Call) RunAndReturn(run func(string) error) *MetaKv_RemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: key, value
|
||||
func (_m *MetaKv) Save(key string, value string) error {
|
||||
ret := _m.Called(key, value)
|
||||
|
@ -938,80 +648,8 @@ func (_c *MetaKv_Save_Call) Return(_a0 error) *MetaKv_Save_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
// SaveWithIgnoreLease provides a mock function with given fields: key, value
|
||||
func (_m *MetaKv) SaveWithIgnoreLease(key string, value string) error {
|
||||
ret := _m.Called(key, value)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(key, value)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MetaKv_SaveWithIgnoreLease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveWithIgnoreLease'
|
||||
type MetaKv_SaveWithIgnoreLease_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SaveWithIgnoreLease is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - value string
|
||||
func (_e *MetaKv_Expecter) SaveWithIgnoreLease(key interface{}, value interface{}) *MetaKv_SaveWithIgnoreLease_Call {
|
||||
return &MetaKv_SaveWithIgnoreLease_Call{Call: _e.mock.On("SaveWithIgnoreLease", key, value)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_SaveWithIgnoreLease_Call) Run(run func(key string, value string)) *MetaKv_SaveWithIgnoreLease_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_SaveWithIgnoreLease_Call) Return(_a0 error) *MetaKv_SaveWithIgnoreLease_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
// SaveWithLease provides a mock function with given fields: key, value, id
|
||||
func (_m *MetaKv) SaveWithLease(key string, value string, id clientv3.LeaseID) error {
|
||||
ret := _m.Called(key, value, id)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string, clientv3.LeaseID) error); ok {
|
||||
r0 = rf(key, value, id)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MetaKv_SaveWithLease_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveWithLease'
|
||||
type MetaKv_SaveWithLease_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// SaveWithLease is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - value string
|
||||
// - id clientv3.LeaseID
|
||||
func (_e *MetaKv_Expecter) SaveWithLease(key interface{}, value interface{}, id interface{}) *MetaKv_SaveWithLease_Call {
|
||||
return &MetaKv_SaveWithLease_Call{Call: _e.mock.On("SaveWithLease", key, value, id)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_SaveWithLease_Call) Run(run func(key string, value string, id clientv3.LeaseID)) *MetaKv_SaveWithLease_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string), args[2].(clientv3.LeaseID))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_SaveWithLease_Call) Return(_a0 error) *MetaKv_SaveWithLease_Call {
|
||||
_c.Call.Return(_a0)
|
||||
func (_c *MetaKv_Save_Call) RunAndReturn(run func(string, string) error) *MetaKv_Save_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
|
@ -1054,131 +692,17 @@ func (_c *MetaKv_WalkWithPrefix_Call) Return(_a0 error) *MetaKv_WalkWithPrefix_C
|
|||
return _c
|
||||
}
|
||||
|
||||
// Watch provides a mock function with given fields: key
|
||||
func (_m *MetaKv) Watch(key string) clientv3.WatchChan {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string) clientv3.WatchChan); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MetaKv_Watch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Watch'
|
||||
type MetaKv_Watch_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Watch is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *MetaKv_Expecter) Watch(key interface{}) *MetaKv_Watch_Call {
|
||||
return &MetaKv_Watch_Call{Call: _e.mock.On("Watch", key)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Watch_Call) Run(run func(key string)) *MetaKv_Watch_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
func (_c *MetaKv_WalkWithPrefix_Call) RunAndReturn(run func(string, int, func([]byte, []byte) error) error) *MetaKv_WalkWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_Watch_Call) Return(_a0 clientv3.WatchChan) *MetaKv_Watch_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
// WatchWithPrefix provides a mock function with given fields: key
|
||||
func (_m *MetaKv) WatchWithPrefix(key string) clientv3.WatchChan {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string) clientv3.WatchChan); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MetaKv_WatchWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchWithPrefix'
|
||||
type MetaKv_WatchWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// WatchWithPrefix is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *MetaKv_Expecter) WatchWithPrefix(key interface{}) *MetaKv_WatchWithPrefix_Call {
|
||||
return &MetaKv_WatchWithPrefix_Call{Call: _e.mock.On("WatchWithPrefix", key)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_WatchWithPrefix_Call) Run(run func(key string)) *MetaKv_WatchWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_WatchWithPrefix_Call) Return(_a0 clientv3.WatchChan) *MetaKv_WatchWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
// WatchWithRevision provides a mock function with given fields: key, revision
|
||||
func (_m *MetaKv) WatchWithRevision(key string, revision int64) clientv3.WatchChan {
|
||||
ret := _m.Called(key, revision)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string, int64) clientv3.WatchChan); ok {
|
||||
r0 = rf(key, revision)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// MetaKv_WatchWithRevision_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchWithRevision'
|
||||
type MetaKv_WatchWithRevision_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// WatchWithRevision is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - revision int64
|
||||
func (_e *MetaKv_Expecter) WatchWithRevision(key interface{}, revision interface{}) *MetaKv_WatchWithRevision_Call {
|
||||
return &MetaKv_WatchWithRevision_Call{Call: _e.mock.On("WatchWithRevision", key, revision)}
|
||||
}
|
||||
|
||||
func (_c *MetaKv_WatchWithRevision_Call) Run(run func(key string, revision int64)) *MetaKv_WatchWithRevision_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(int64))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *MetaKv_WatchWithRevision_Call) Return(_a0 clientv3.WatchChan) *MetaKv_WatchWithRevision_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewMetaKv interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}
|
||||
|
||||
// NewMetaKv creates a new instance of MetaKv. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewMetaKv(t mockConstructorTestingTNewMetaKv) *MetaKv {
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewMetaKv(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *MetaKv {
|
||||
mock := &MetaKv{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.16.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.30.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
@ -22,13 +22,16 @@ func (_m *SnapShotKV) Load(key string, ts uint64) (string, error) {
|
|||
ret := _m.Called(key, ts)
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, uint64) (string, error)); ok {
|
||||
return rf(key, ts)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, uint64) string); ok {
|
||||
r0 = rf(key, ts)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, uint64) error); ok {
|
||||
r1 = rf(key, ts)
|
||||
} else {
|
||||
|
@ -62,11 +65,21 @@ func (_c *SnapShotKV_Load_Call) Return(_a0 string, _a1 error) *SnapShotKV_Load_C
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *SnapShotKV_Load_Call) RunAndReturn(run func(string, uint64) (string, error)) *SnapShotKV_Load_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithPrefix provides a mock function with given fields: key, ts
|
||||
func (_m *SnapShotKV) LoadWithPrefix(key string, ts uint64) ([]string, []string, error) {
|
||||
ret := _m.Called(key, ts)
|
||||
|
||||
var r0 []string
|
||||
var r1 []string
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(string, uint64) ([]string, []string, error)); ok {
|
||||
return rf(key, ts)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, uint64) []string); ok {
|
||||
r0 = rf(key, ts)
|
||||
} else {
|
||||
|
@ -75,7 +88,6 @@ func (_m *SnapShotKV) LoadWithPrefix(key string, ts uint64) ([]string, []string,
|
|||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string, uint64) []string); ok {
|
||||
r1 = rf(key, ts)
|
||||
} else {
|
||||
|
@ -84,7 +96,6 @@ func (_m *SnapShotKV) LoadWithPrefix(key string, ts uint64) ([]string, []string,
|
|||
}
|
||||
}
|
||||
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(2).(func(string, uint64) error); ok {
|
||||
r2 = rf(key, ts)
|
||||
} else {
|
||||
|
@ -118,6 +129,11 @@ func (_c *SnapShotKV_LoadWithPrefix_Call) Return(_a0 []string, _a1 []string, _a2
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *SnapShotKV_LoadWithPrefix_Call) RunAndReturn(run func(string, uint64) ([]string, []string, error)) *SnapShotKV_LoadWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSave provides a mock function with given fields: kvs, ts
|
||||
func (_m *SnapShotKV) MultiSave(kvs map[string]string, ts uint64) error {
|
||||
ret := _m.Called(kvs, ts)
|
||||
|
@ -156,6 +172,11 @@ func (_c *SnapShotKV_MultiSave_Call) Return(_a0 error) *SnapShotKV_MultiSave_Cal
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *SnapShotKV_MultiSave_Call) RunAndReturn(run func(map[string]string, uint64) error) *SnapShotKV_MultiSave_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemoveWithPrefix provides a mock function with given fields: saves, removals, ts
|
||||
func (_m *SnapShotKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string, ts uint64) error {
|
||||
ret := _m.Called(saves, removals, ts)
|
||||
|
@ -195,6 +216,11 @@ func (_c *SnapShotKV_MultiSaveAndRemoveWithPrefix_Call) Return(_a0 error) *SnapS
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *SnapShotKV_MultiSaveAndRemoveWithPrefix_Call) RunAndReturn(run func(map[string]string, []string, uint64) error) *SnapShotKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: key, value, ts
|
||||
func (_m *SnapShotKV) Save(key string, value string, ts uint64) error {
|
||||
ret := _m.Called(key, value, ts)
|
||||
|
@ -234,13 +260,17 @@ func (_c *SnapShotKV_Save_Call) Return(_a0 error) *SnapShotKV_Save_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewSnapShotKV interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
func (_c *SnapShotKV_Save_Call) RunAndReturn(run func(string, string, uint64) error) *SnapShotKV_Save_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewSnapShotKV creates a new instance of SnapShotKV. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewSnapShotKV(t mockConstructorTestingTNewSnapShotKV) *SnapShotKV {
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewSnapShotKV(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *SnapShotKV {
|
||||
mock := &SnapShotKV{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by mockery v2.16.0. DO NOT EDIT.
|
||||
// Code generated by mockery v2.30.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
|
@ -44,18 +44,26 @@ func (_c *TxnKV_Close_Call) Return() *TxnKV_Close_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_Close_Call) RunAndReturn(run func()) *TxnKV_Close_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Load provides a mock function with given fields: key
|
||||
func (_m *TxnKV) Load(key string) (string, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
|
@ -88,11 +96,21 @@ func (_c *TxnKV_Load_Call) Return(_a0 string, _a1 error) *TxnKV_Load_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_Load_Call) RunAndReturn(run func(string) (string, error)) *TxnKV_Load_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithPrefix provides a mock function with given fields: key
|
||||
func (_m *TxnKV) LoadWithPrefix(key string) ([]string, []string, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
var r1 []string
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(string) ([]string, []string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
|
@ -101,7 +119,6 @@ func (_m *TxnKV) LoadWithPrefix(key string) ([]string, []string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r1 []string
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
|
@ -110,7 +127,6 @@ func (_m *TxnKV) LoadWithPrefix(key string) ([]string, []string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(2).(func(string) error); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
|
@ -143,11 +159,20 @@ func (_c *TxnKV_LoadWithPrefix_Call) Return(_a0 []string, _a1 []string, _a2 erro
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_LoadWithPrefix_Call) RunAndReturn(run func(string) ([]string, []string, error)) *TxnKV_LoadWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiLoad provides a mock function with given fields: keys
|
||||
func (_m *TxnKV) MultiLoad(keys []string) ([]string, error) {
|
||||
ret := _m.Called(keys)
|
||||
|
||||
var r0 []string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]string) ([]string, error)); ok {
|
||||
return rf(keys)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]string) []string); ok {
|
||||
r0 = rf(keys)
|
||||
} else {
|
||||
|
@ -156,7 +181,6 @@ func (_m *TxnKV) MultiLoad(keys []string) ([]string, error) {
|
|||
}
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func([]string) error); ok {
|
||||
r1 = rf(keys)
|
||||
} else {
|
||||
|
@ -189,6 +213,11 @@ func (_c *TxnKV_MultiLoad_Call) Return(_a0 []string, _a1 error) *TxnKV_MultiLoad
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiLoad_Call) RunAndReturn(run func([]string) ([]string, error)) *TxnKV_MultiLoad_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemove provides a mock function with given fields: keys
|
||||
func (_m *TxnKV) MultiRemove(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
@ -226,6 +255,11 @@ func (_c *TxnKV_MultiRemove_Call) Return(_a0 error) *TxnKV_MultiRemove_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiRemove_Call) RunAndReturn(run func([]string) error) *TxnKV_MultiRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemoveWithPrefix provides a mock function with given fields: keys
|
||||
func (_m *TxnKV) MultiRemoveWithPrefix(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
@ -263,6 +297,11 @@ func (_c *TxnKV_MultiRemoveWithPrefix_Call) Return(_a0 error) *TxnKV_MultiRemove
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiRemoveWithPrefix_Call) RunAndReturn(run func([]string) error) *TxnKV_MultiRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSave provides a mock function with given fields: kvs
|
||||
func (_m *TxnKV) MultiSave(kvs map[string]string) error {
|
||||
ret := _m.Called(kvs)
|
||||
|
@ -300,6 +339,11 @@ func (_c *TxnKV_MultiSave_Call) Return(_a0 error) *TxnKV_MultiSave_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiSave_Call) RunAndReturn(run func(map[string]string) error) *TxnKV_MultiSave_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemove provides a mock function with given fields: saves, removals
|
||||
func (_m *TxnKV) MultiSaveAndRemove(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
@ -338,6 +382,11 @@ func (_c *TxnKV_MultiSaveAndRemove_Call) Return(_a0 error) *TxnKV_MultiSaveAndRe
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiSaveAndRemove_Call) RunAndReturn(run func(map[string]string, []string) error) *TxnKV_MultiSaveAndRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemoveWithPrefix provides a mock function with given fields: saves, removals
|
||||
func (_m *TxnKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
@ -376,6 +425,11 @@ func (_c *TxnKV_MultiSaveAndRemoveWithPrefix_Call) Return(_a0 error) *TxnKV_Mult
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_MultiSaveAndRemoveWithPrefix_Call) RunAndReturn(run func(map[string]string, []string) error) *TxnKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Remove provides a mock function with given fields: key
|
||||
func (_m *TxnKV) Remove(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
@ -413,6 +467,11 @@ func (_c *TxnKV_Remove_Call) Return(_a0 error) *TxnKV_Remove_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_Remove_Call) RunAndReturn(run func(string) error) *TxnKV_Remove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// RemoveWithPrefix provides a mock function with given fields: key
|
||||
func (_m *TxnKV) RemoveWithPrefix(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
@ -450,6 +509,11 @@ func (_c *TxnKV_RemoveWithPrefix_Call) Return(_a0 error) *TxnKV_RemoveWithPrefix
|
|||
return _c
|
||||
}
|
||||
|
||||
func (_c *TxnKV_RemoveWithPrefix_Call) RunAndReturn(run func(string) error) *TxnKV_RemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: key, value
|
||||
func (_m *TxnKV) Save(key string, value string) error {
|
||||
ret := _m.Called(key, value)
|
||||
|
@ -488,13 +552,17 @@ func (_c *TxnKV_Save_Call) Return(_a0 error) *TxnKV_Save_Call {
|
|||
return _c
|
||||
}
|
||||
|
||||
type mockConstructorTestingTNewTxnKV interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
func (_c *TxnKV_Save_Call) RunAndReturn(run func(string, string) error) *TxnKV_Save_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewTxnKV creates a new instance of TxnKV. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
func NewTxnKV(t mockConstructorTestingTNewTxnKV) *TxnKV {
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewTxnKV(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *TxnKV {
|
||||
mock := &TxnKV{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
|
|
|
@ -0,0 +1,849 @@
|
|||
// Code generated by mockery v2.30.1. DO NOT EDIT.
|
||||
|
||||
package mocks
|
||||
|
||||
import (
|
||||
clientv3 "go.etcd.io/etcd/client/v3"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// WatchKV is an autogenerated mock type for the WatchKV type
|
||||
type WatchKV struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
type WatchKV_Expecter struct {
|
||||
mock *mock.Mock
|
||||
}
|
||||
|
||||
func (_m *WatchKV) EXPECT() *WatchKV_Expecter {
|
||||
return &WatchKV_Expecter{mock: &_m.Mock}
|
||||
}
|
||||
|
||||
// Close provides a mock function with given fields:
|
||||
func (_m *WatchKV) Close() {
|
||||
_m.Called()
|
||||
}
|
||||
|
||||
// WatchKV_Close_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Close'
|
||||
type WatchKV_Close_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Close is a helper method to define mock.On call
|
||||
func (_e *WatchKV_Expecter) Close() *WatchKV_Close_Call {
|
||||
return &WatchKV_Close_Call{Call: _e.mock.On("Close")}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Close_Call) Run(run func()) *WatchKV_Close_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run()
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Close_Call) Return() *WatchKV_Close_Call {
|
||||
_c.Call.Return()
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Close_Call) RunAndReturn(run func()) *WatchKV_Close_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// CompareVersionAndSwap provides a mock function with given fields: key, version, target
|
||||
func (_m *WatchKV) CompareVersionAndSwap(key string, version int64, target string) (bool, error) {
|
||||
ret := _m.Called(key, version, target)
|
||||
|
||||
var r0 bool
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string, int64, string) (bool, error)); ok {
|
||||
return rf(key, version, target)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string, int64, string) bool); ok {
|
||||
r0 = rf(key, version, target)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string, int64, string) error); ok {
|
||||
r1 = rf(key, version, target)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// WatchKV_CompareVersionAndSwap_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CompareVersionAndSwap'
|
||||
type WatchKV_CompareVersionAndSwap_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// CompareVersionAndSwap is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - version int64
|
||||
// - target string
|
||||
func (_e *WatchKV_Expecter) CompareVersionAndSwap(key interface{}, version interface{}, target interface{}) *WatchKV_CompareVersionAndSwap_Call {
|
||||
return &WatchKV_CompareVersionAndSwap_Call{Call: _e.mock.On("CompareVersionAndSwap", key, version, target)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_CompareVersionAndSwap_Call) Run(run func(key string, version int64, target string)) *WatchKV_CompareVersionAndSwap_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(int64), args[2].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_CompareVersionAndSwap_Call) Return(_a0 bool, _a1 error) *WatchKV_CompareVersionAndSwap_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_CompareVersionAndSwap_Call) RunAndReturn(run func(string, int64, string) (bool, error)) *WatchKV_CompareVersionAndSwap_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// GetPath provides a mock function with given fields: key
|
||||
func (_m *WatchKV) GetPath(key string) string {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 string
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_GetPath_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPath'
|
||||
type WatchKV_GetPath_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// GetPath is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) GetPath(key interface{}) *WatchKV_GetPath_Call {
|
||||
return &WatchKV_GetPath_Call{Call: _e.mock.On("GetPath", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_GetPath_Call) Run(run func(key string)) *WatchKV_GetPath_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_GetPath_Call) Return(_a0 string) *WatchKV_GetPath_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_GetPath_Call) RunAndReturn(run func(string) string) *WatchKV_GetPath_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Load provides a mock function with given fields: key
|
||||
func (_m *WatchKV) Load(key string) (string, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func(string) (string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Get(0).(string)
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) error); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// WatchKV_Load_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Load'
|
||||
type WatchKV_Load_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Load is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) Load(key interface{}) *WatchKV_Load_Call {
|
||||
return &WatchKV_Load_Call{Call: _e.mock.On("Load", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Load_Call) Run(run func(key string)) *WatchKV_Load_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Load_Call) Return(_a0 string, _a1 error) *WatchKV_Load_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Load_Call) RunAndReturn(run func(string) (string, error)) *WatchKV_Load_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// LoadWithPrefix provides a mock function with given fields: key
|
||||
func (_m *WatchKV) LoadWithPrefix(key string) ([]string, []string, error) {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 []string
|
||||
var r1 []string
|
||||
var r2 error
|
||||
if rf, ok := ret.Get(0).(func(string) ([]string, []string, error)); ok {
|
||||
return rf(key)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func(string) []string); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func(string) []string); ok {
|
||||
r1 = rf(key)
|
||||
} else {
|
||||
if ret.Get(1) != nil {
|
||||
r1 = ret.Get(1).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(2).(func(string) error); ok {
|
||||
r2 = rf(key)
|
||||
} else {
|
||||
r2 = ret.Error(2)
|
||||
}
|
||||
|
||||
return r0, r1, r2
|
||||
}
|
||||
|
||||
// WatchKV_LoadWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'LoadWithPrefix'
|
||||
type WatchKV_LoadWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// LoadWithPrefix is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) LoadWithPrefix(key interface{}) *WatchKV_LoadWithPrefix_Call {
|
||||
return &WatchKV_LoadWithPrefix_Call{Call: _e.mock.On("LoadWithPrefix", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_LoadWithPrefix_Call) Run(run func(key string)) *WatchKV_LoadWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_LoadWithPrefix_Call) Return(_a0 []string, _a1 []string, _a2 error) *WatchKV_LoadWithPrefix_Call {
|
||||
_c.Call.Return(_a0, _a1, _a2)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_LoadWithPrefix_Call) RunAndReturn(run func(string) ([]string, []string, error)) *WatchKV_LoadWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiLoad provides a mock function with given fields: keys
|
||||
func (_m *WatchKV) MultiLoad(keys []string) ([]string, error) {
|
||||
ret := _m.Called(keys)
|
||||
|
||||
var r0 []string
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(0).(func([]string) ([]string, error)); ok {
|
||||
return rf(keys)
|
||||
}
|
||||
if rf, ok := ret.Get(0).(func([]string) []string); ok {
|
||||
r0 = rf(keys)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).([]string)
|
||||
}
|
||||
}
|
||||
|
||||
if rf, ok := ret.Get(1).(func([]string) error); ok {
|
||||
r1 = rf(keys)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// WatchKV_MultiLoad_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiLoad'
|
||||
type WatchKV_MultiLoad_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiLoad is a helper method to define mock.On call
|
||||
// - keys []string
|
||||
func (_e *WatchKV_Expecter) MultiLoad(keys interface{}) *WatchKV_MultiLoad_Call {
|
||||
return &WatchKV_MultiLoad_Call{Call: _e.mock.On("MultiLoad", keys)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiLoad_Call) Run(run func(keys []string)) *WatchKV_MultiLoad_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].([]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiLoad_Call) Return(_a0 []string, _a1 error) *WatchKV_MultiLoad_Call {
|
||||
_c.Call.Return(_a0, _a1)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiLoad_Call) RunAndReturn(run func([]string) ([]string, error)) *WatchKV_MultiLoad_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemove provides a mock function with given fields: keys
|
||||
func (_m *WatchKV) MultiRemove(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func([]string) error); ok {
|
||||
r0 = rf(keys)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_MultiRemove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiRemove'
|
||||
type WatchKV_MultiRemove_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiRemove is a helper method to define mock.On call
|
||||
// - keys []string
|
||||
func (_e *WatchKV_Expecter) MultiRemove(keys interface{}) *WatchKV_MultiRemove_Call {
|
||||
return &WatchKV_MultiRemove_Call{Call: _e.mock.On("MultiRemove", keys)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemove_Call) Run(run func(keys []string)) *WatchKV_MultiRemove_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].([]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemove_Call) Return(_a0 error) *WatchKV_MultiRemove_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemove_Call) RunAndReturn(run func([]string) error) *WatchKV_MultiRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiRemoveWithPrefix provides a mock function with given fields: keys
|
||||
func (_m *WatchKV) MultiRemoveWithPrefix(keys []string) error {
|
||||
ret := _m.Called(keys)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func([]string) error); ok {
|
||||
r0 = rf(keys)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_MultiRemoveWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiRemoveWithPrefix'
|
||||
type WatchKV_MultiRemoveWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiRemoveWithPrefix is a helper method to define mock.On call
|
||||
// - keys []string
|
||||
func (_e *WatchKV_Expecter) MultiRemoveWithPrefix(keys interface{}) *WatchKV_MultiRemoveWithPrefix_Call {
|
||||
return &WatchKV_MultiRemoveWithPrefix_Call{Call: _e.mock.On("MultiRemoveWithPrefix", keys)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemoveWithPrefix_Call) Run(run func(keys []string)) *WatchKV_MultiRemoveWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].([]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemoveWithPrefix_Call) Return(_a0 error) *WatchKV_MultiRemoveWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiRemoveWithPrefix_Call) RunAndReturn(run func([]string) error) *WatchKV_MultiRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSave provides a mock function with given fields: kvs
|
||||
func (_m *WatchKV) MultiSave(kvs map[string]string) error {
|
||||
ret := _m.Called(kvs)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(map[string]string) error); ok {
|
||||
r0 = rf(kvs)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_MultiSave_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiSave'
|
||||
type WatchKV_MultiSave_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiSave is a helper method to define mock.On call
|
||||
// - kvs map[string]string
|
||||
func (_e *WatchKV_Expecter) MultiSave(kvs interface{}) *WatchKV_MultiSave_Call {
|
||||
return &WatchKV_MultiSave_Call{Call: _e.mock.On("MultiSave", kvs)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSave_Call) Run(run func(kvs map[string]string)) *WatchKV_MultiSave_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(map[string]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSave_Call) Return(_a0 error) *WatchKV_MultiSave_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSave_Call) RunAndReturn(run func(map[string]string) error) *WatchKV_MultiSave_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemove provides a mock function with given fields: saves, removals
|
||||
func (_m *WatchKV) MultiSaveAndRemove(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(map[string]string, []string) error); ok {
|
||||
r0 = rf(saves, removals)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_MultiSaveAndRemove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiSaveAndRemove'
|
||||
type WatchKV_MultiSaveAndRemove_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiSaveAndRemove is a helper method to define mock.On call
|
||||
// - saves map[string]string
|
||||
// - removals []string
|
||||
func (_e *WatchKV_Expecter) MultiSaveAndRemove(saves interface{}, removals interface{}) *WatchKV_MultiSaveAndRemove_Call {
|
||||
return &WatchKV_MultiSaveAndRemove_Call{Call: _e.mock.On("MultiSaveAndRemove", saves, removals)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemove_Call) Run(run func(saves map[string]string, removals []string)) *WatchKV_MultiSaveAndRemove_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(map[string]string), args[1].([]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemove_Call) Return(_a0 error) *WatchKV_MultiSaveAndRemove_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemove_Call) RunAndReturn(run func(map[string]string, []string) error) *WatchKV_MultiSaveAndRemove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// MultiSaveAndRemoveWithPrefix provides a mock function with given fields: saves, removals
|
||||
func (_m *WatchKV) MultiSaveAndRemoveWithPrefix(saves map[string]string, removals []string) error {
|
||||
ret := _m.Called(saves, removals)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(map[string]string, []string) error); ok {
|
||||
r0 = rf(saves, removals)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_MultiSaveAndRemoveWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'MultiSaveAndRemoveWithPrefix'
|
||||
type WatchKV_MultiSaveAndRemoveWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// MultiSaveAndRemoveWithPrefix is a helper method to define mock.On call
|
||||
// - saves map[string]string
|
||||
// - removals []string
|
||||
func (_e *WatchKV_Expecter) MultiSaveAndRemoveWithPrefix(saves interface{}, removals interface{}) *WatchKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
return &WatchKV_MultiSaveAndRemoveWithPrefix_Call{Call: _e.mock.On("MultiSaveAndRemoveWithPrefix", saves, removals)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemoveWithPrefix_Call) Run(run func(saves map[string]string, removals []string)) *WatchKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(map[string]string), args[1].([]string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemoveWithPrefix_Call) Return(_a0 error) *WatchKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_MultiSaveAndRemoveWithPrefix_Call) RunAndReturn(run func(map[string]string, []string) error) *WatchKV_MultiSaveAndRemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Remove provides a mock function with given fields: key
|
||||
func (_m *WatchKV) Remove(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_Remove_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Remove'
|
||||
type WatchKV_Remove_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Remove is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) Remove(key interface{}) *WatchKV_Remove_Call {
|
||||
return &WatchKV_Remove_Call{Call: _e.mock.On("Remove", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Remove_Call) Run(run func(key string)) *WatchKV_Remove_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Remove_Call) Return(_a0 error) *WatchKV_Remove_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Remove_Call) RunAndReturn(run func(string) error) *WatchKV_Remove_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// RemoveWithPrefix provides a mock function with given fields: key
|
||||
func (_m *WatchKV) RemoveWithPrefix(key string) error {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string) error); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_RemoveWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RemoveWithPrefix'
|
||||
type WatchKV_RemoveWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// RemoveWithPrefix is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) RemoveWithPrefix(key interface{}) *WatchKV_RemoveWithPrefix_Call {
|
||||
return &WatchKV_RemoveWithPrefix_Call{Call: _e.mock.On("RemoveWithPrefix", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_RemoveWithPrefix_Call) Run(run func(key string)) *WatchKV_RemoveWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_RemoveWithPrefix_Call) Return(_a0 error) *WatchKV_RemoveWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_RemoveWithPrefix_Call) RunAndReturn(run func(string) error) *WatchKV_RemoveWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Save provides a mock function with given fields: key, value
|
||||
func (_m *WatchKV) Save(key string, value string) error {
|
||||
ret := _m.Called(key, value)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, string) error); ok {
|
||||
r0 = rf(key, value)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_Save_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Save'
|
||||
type WatchKV_Save_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Save is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - value string
|
||||
func (_e *WatchKV_Expecter) Save(key interface{}, value interface{}) *WatchKV_Save_Call {
|
||||
return &WatchKV_Save_Call{Call: _e.mock.On("Save", key, value)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Save_Call) Run(run func(key string, value string)) *WatchKV_Save_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Save_Call) Return(_a0 error) *WatchKV_Save_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Save_Call) RunAndReturn(run func(string, string) error) *WatchKV_Save_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// WalkWithPrefix provides a mock function with given fields: prefix, paginationSize, fn
|
||||
func (_m *WatchKV) WalkWithPrefix(prefix string, paginationSize int, fn func([]byte, []byte) error) error {
|
||||
ret := _m.Called(prefix, paginationSize, fn)
|
||||
|
||||
var r0 error
|
||||
if rf, ok := ret.Get(0).(func(string, int, func([]byte, []byte) error) error); ok {
|
||||
r0 = rf(prefix, paginationSize, fn)
|
||||
} else {
|
||||
r0 = ret.Error(0)
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_WalkWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WalkWithPrefix'
|
||||
type WatchKV_WalkWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// WalkWithPrefix is a helper method to define mock.On call
|
||||
// - prefix string
|
||||
// - paginationSize int
|
||||
// - fn func([]byte , []byte) error
|
||||
func (_e *WatchKV_Expecter) WalkWithPrefix(prefix interface{}, paginationSize interface{}, fn interface{}) *WatchKV_WalkWithPrefix_Call {
|
||||
return &WatchKV_WalkWithPrefix_Call{Call: _e.mock.On("WalkWithPrefix", prefix, paginationSize, fn)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WalkWithPrefix_Call) Run(run func(prefix string, paginationSize int, fn func([]byte, []byte) error)) *WatchKV_WalkWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(int), args[2].(func([]byte, []byte) error))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WalkWithPrefix_Call) Return(_a0 error) *WatchKV_WalkWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WalkWithPrefix_Call) RunAndReturn(run func(string, int, func([]byte, []byte) error) error) *WatchKV_WalkWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// Watch provides a mock function with given fields: key
|
||||
func (_m *WatchKV) Watch(key string) clientv3.WatchChan {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string) clientv3.WatchChan); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_Watch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Watch'
|
||||
type WatchKV_Watch_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// Watch is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) Watch(key interface{}) *WatchKV_Watch_Call {
|
||||
return &WatchKV_Watch_Call{Call: _e.mock.On("Watch", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Watch_Call) Run(run func(key string)) *WatchKV_Watch_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Watch_Call) Return(_a0 clientv3.WatchChan) *WatchKV_Watch_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_Watch_Call) RunAndReturn(run func(string) clientv3.WatchChan) *WatchKV_Watch_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// WatchWithPrefix provides a mock function with given fields: key
|
||||
func (_m *WatchKV) WatchWithPrefix(key string) clientv3.WatchChan {
|
||||
ret := _m.Called(key)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string) clientv3.WatchChan); ok {
|
||||
r0 = rf(key)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_WatchWithPrefix_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchWithPrefix'
|
||||
type WatchKV_WatchWithPrefix_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// WatchWithPrefix is a helper method to define mock.On call
|
||||
// - key string
|
||||
func (_e *WatchKV_Expecter) WatchWithPrefix(key interface{}) *WatchKV_WatchWithPrefix_Call {
|
||||
return &WatchKV_WatchWithPrefix_Call{Call: _e.mock.On("WatchWithPrefix", key)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithPrefix_Call) Run(run func(key string)) *WatchKV_WatchWithPrefix_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithPrefix_Call) Return(_a0 clientv3.WatchChan) *WatchKV_WatchWithPrefix_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithPrefix_Call) RunAndReturn(run func(string) clientv3.WatchChan) *WatchKV_WatchWithPrefix_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// WatchWithRevision provides a mock function with given fields: key, revision
|
||||
func (_m *WatchKV) WatchWithRevision(key string, revision int64) clientv3.WatchChan {
|
||||
ret := _m.Called(key, revision)
|
||||
|
||||
var r0 clientv3.WatchChan
|
||||
if rf, ok := ret.Get(0).(func(string, int64) clientv3.WatchChan); ok {
|
||||
r0 = rf(key, revision)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
r0 = ret.Get(0).(clientv3.WatchChan)
|
||||
}
|
||||
}
|
||||
|
||||
return r0
|
||||
}
|
||||
|
||||
// WatchKV_WatchWithRevision_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'WatchWithRevision'
|
||||
type WatchKV_WatchWithRevision_Call struct {
|
||||
*mock.Call
|
||||
}
|
||||
|
||||
// WatchWithRevision is a helper method to define mock.On call
|
||||
// - key string
|
||||
// - revision int64
|
||||
func (_e *WatchKV_Expecter) WatchWithRevision(key interface{}, revision interface{}) *WatchKV_WatchWithRevision_Call {
|
||||
return &WatchKV_WatchWithRevision_Call{Call: _e.mock.On("WatchWithRevision", key, revision)}
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithRevision_Call) Run(run func(key string, revision int64)) *WatchKV_WatchWithRevision_Call {
|
||||
_c.Call.Run(func(args mock.Arguments) {
|
||||
run(args[0].(string), args[1].(int64))
|
||||
})
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithRevision_Call) Return(_a0 clientv3.WatchChan) *WatchKV_WatchWithRevision_Call {
|
||||
_c.Call.Return(_a0)
|
||||
return _c
|
||||
}
|
||||
|
||||
func (_c *WatchKV_WatchWithRevision_Call) RunAndReturn(run func(string, int64) clientv3.WatchChan) *WatchKV_WatchWithRevision_Call {
|
||||
_c.Call.Return(run)
|
||||
return _c
|
||||
}
|
||||
|
||||
// NewWatchKV creates a new instance of WatchKV. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
|
||||
// The first argument is typically a *testing.T value.
|
||||
func NewWatchKV(t interface {
|
||||
mock.TestingT
|
||||
Cleanup(func())
|
||||
}) *WatchKV {
|
||||
mock := &WatchKV{}
|
||||
mock.Mock.Test(t)
|
||||
|
||||
t.Cleanup(func() { mock.AssertExpectations(t) })
|
||||
|
||||
return mock
|
||||
}
|
Loading…
Reference in New Issue