milvus/internal/datacoord/channel_manager_test.go
sunby 044b06421a
Use etcd to watch channel on datanode (#7115)
issue: #6578
Signed-off-by: sunby <bingyi.sun@zilliz.com>
2021-10-14 15:44:34 +08:00

32 lines
951 B
Go

package datacoord
import (
"testing"
memkv "github.com/milvus-io/milvus/internal/kv/mem"
"github.com/stretchr/testify/assert"
"stathat.com/c/consistent"
)
func TestReload(t *testing.T) {
t.Run("test reload with data", func(t *testing.T) {
Params.Init()
kv := memkv.NewMemoryKV()
hash := consistent.New()
cm, err := NewChannelManager(kv, &dummyPosProvider{}, withFactory(NewConsistentHashChannelPolicyFactory(hash)))
assert.Nil(t, err)
assert.Nil(t, cm.AddNode(1))
assert.Nil(t, cm.AddNode(2))
assert.Nil(t, cm.Watch(&channel{"channel1", 1}))
assert.Nil(t, cm.Watch(&channel{"channel2", 1}))
hash2 := consistent.New()
cm2, err := NewChannelManager(kv, &dummyPosProvider{}, withFactory(NewConsistentHashChannelPolicyFactory(hash2)))
assert.Nil(t, err)
assert.Nil(t, cm2.Startup([]int64{1, 2}))
assert.Nil(t, cm2.AddNode(3))
assert.True(t, cm2.Match(3, "channel1"))
assert.True(t, cm2.Match(3, "channel2"))
})
}