milvus/internal/indexnode/indexnode_component_mock.go
wayblink 6a722396bd
Integration test framework (#21283)
Signed-off-by: wayblink <anyang.wang@zilliz.com>
2023-01-12 19:49:40 +08:00

42 lines
763 B
Go

package indexnode
import (
"context"
"github.com/milvus-io/milvus/internal/types"
)
type mockIndexNodeComponent struct {
IndexNode
}
var _ types.IndexNodeComponent = &mockIndexNodeComponent{}
func NewMockIndexNodeComponent(ctx context.Context) (types.IndexNodeComponent, error) {
Params.Init()
factory := &mockFactory{
chunkMgr: &mockChunkmgr{},
}
node := NewIndexNode(ctx, factory)
startEmbedEtcd()
etcdCli := getEtcdClient()
node.SetEtcdClient(etcdCli)
node.storageFactory = &mockStorageFactory{}
if err := node.Init(); err != nil {
return nil, err
}
if err := node.Start(); err != nil {
return nil, err
}
if err := node.Register(); err != nil {
return nil, err
}
return &mockIndexNodeComponent{
IndexNode: *node,
}, nil
}