mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-04 04:49:08 +08:00
c924f73105
Co-authored-by: Zach41 <zongmei.zhang@zilliz.com> Signed-off-by: cai.zhang <cai.zhang@zilliz.com> Signed-off-by: cai.zhang <cai.zhang@zilliz.com> Co-authored-by: Zach41 <zongmei.zhang@zilliz.com>
45 lines
806 B
Go
45 lines
806 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, err := NewIndexNode(ctx, factory)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
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
|
|
}
|