2022-08-25 15:48:54 +08:00
|
|
|
package indexnode
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/milvus-io/milvus/internal/types"
|
2023-09-05 10:31:48 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
2022-08-25 15:48:54 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type mockIndexNodeComponent struct {
|
2023-03-24 11:17:58 +08:00
|
|
|
*IndexNode
|
2022-08-25 15:48:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
var _ types.IndexNodeComponent = &mockIndexNodeComponent{}
|
|
|
|
|
|
|
|
func NewMockIndexNodeComponent(ctx context.Context) (types.IndexNodeComponent, error) {
|
2023-09-05 10:31:48 +08:00
|
|
|
paramtable.Init()
|
2022-08-25 15:48:54 +08:00
|
|
|
factory := &mockFactory{
|
|
|
|
chunkMgr: &mockChunkmgr{},
|
|
|
|
}
|
|
|
|
|
2023-01-12 19:49:40 +08:00
|
|
|
node := NewIndexNode(ctx, factory)
|
2022-08-25 15:48:54 +08:00
|
|
|
|
|
|
|
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{
|
2023-03-24 11:17:58 +08:00
|
|
|
IndexNode: node,
|
2022-08-25 15:48:54 +08:00
|
|
|
}, nil
|
|
|
|
}
|