mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
issue: #37764 - add a local client to call local server directly for querycoord/rootcoord/datacoord. - enable local client if milvus is running mixcoord or standalone mode. --------- Signed-off-by: chyezh <chyezh@outlook.com>
75 lines
2.5 KiB
Go
75 lines
2.5 KiB
Go
package coordclient
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/datapb"
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
|
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
|
|
"github.com/milvus-io/milvus/pkg/util/typeutil"
|
|
)
|
|
|
|
func TestRegistry(t *testing.T) {
|
|
assert.False(t, enableLocal.EnableQueryCoord)
|
|
assert.False(t, enableLocal.EnableDataCoord)
|
|
assert.False(t, enableLocal.EnableRootCoord)
|
|
|
|
EnableLocalClientRole(&LocalClientRoleConfig{
|
|
ServerType: typeutil.RootCoordRole,
|
|
EnableQueryCoord: true,
|
|
EnableDataCoord: true,
|
|
EnableRootCoord: true,
|
|
})
|
|
assert.False(t, enableLocal.EnableQueryCoord)
|
|
assert.False(t, enableLocal.EnableDataCoord)
|
|
assert.False(t, enableLocal.EnableRootCoord)
|
|
|
|
RegisterRootCoordServer(&rootcoordpb.UnimplementedRootCoordServer{})
|
|
RegisterDataCoordServer(&datapb.UnimplementedDataCoordServer{})
|
|
RegisterQueryCoordServer(&querypb.UnimplementedQueryCoordServer{})
|
|
assert.False(t, glocalClient.dataCoordClient.Ready())
|
|
assert.False(t, glocalClient.queryCoordClient.Ready())
|
|
assert.False(t, glocalClient.rootCoordClient.Ready())
|
|
|
|
enableLocal = &LocalClientRoleConfig{}
|
|
|
|
EnableLocalClientRole(&LocalClientRoleConfig{
|
|
ServerType: typeutil.StandaloneRole,
|
|
EnableQueryCoord: true,
|
|
EnableDataCoord: true,
|
|
EnableRootCoord: true,
|
|
})
|
|
assert.True(t, enableLocal.EnableDataCoord)
|
|
assert.True(t, enableLocal.EnableQueryCoord)
|
|
assert.True(t, enableLocal.EnableRootCoord)
|
|
|
|
RegisterRootCoordServer(&rootcoordpb.UnimplementedRootCoordServer{})
|
|
RegisterDataCoordServer(&datapb.UnimplementedDataCoordServer{})
|
|
RegisterQueryCoordServer(&querypb.UnimplementedQueryCoordServer{})
|
|
assert.True(t, glocalClient.dataCoordClient.Ready())
|
|
assert.True(t, glocalClient.queryCoordClient.Ready())
|
|
assert.True(t, glocalClient.rootCoordClient.Ready())
|
|
|
|
enableLocal = &LocalClientRoleConfig{}
|
|
|
|
EnableLocalClientRole(&LocalClientRoleConfig{
|
|
ServerType: typeutil.MixtureRole,
|
|
EnableQueryCoord: true,
|
|
EnableDataCoord: true,
|
|
EnableRootCoord: true,
|
|
})
|
|
assert.True(t, enableLocal.EnableDataCoord)
|
|
assert.True(t, enableLocal.EnableQueryCoord)
|
|
assert.True(t, enableLocal.EnableRootCoord)
|
|
|
|
assert.NotNil(t, GetQueryCoordClient(context.Background()))
|
|
assert.NotNil(t, GetDataCoordClient(context.Background()))
|
|
assert.NotNil(t, GetRootCoordClient(context.Background()))
|
|
GetQueryCoordClient(context.Background()).Close()
|
|
GetDataCoordClient(context.Background()).Close()
|
|
GetRootCoordClient(context.Background()).Close()
|
|
}
|