mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-06 17:18:35 +08:00
Related to #44761 Refactor proxy shard client management by creating a new internal/proxy/shardclient package. This improves code organization and modularity by: - Moving load balancing logic (LookAsideBalancer, RoundRobinBalancer) to shardclient package - Extracting shard client manager and related interfaces into separate package - Relocating shard leader management and client lifecycle code - Adding package documentation (README.md, OWNERS) - Updating proxy code to use the new shardclient package interfaces This change makes the shard client functionality more maintainable and better encapsulated, reducing coupling in the proxy layer. Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
39 lines
1.4 KiB
Go
39 lines
1.4 KiB
Go
package proxy
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/mock"
|
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
|
"github.com/milvus-io/milvus/internal/mocks"
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
|
"github.com/milvus-io/milvus/pkg/v2/util/merr"
|
|
)
|
|
|
|
func TestNewInterceptor(t *testing.T) {
|
|
mixc := &mocks.MockMixCoordClient{}
|
|
mixc.EXPECT().CheckHealth(mock.Anything, mock.Anything).Return(&milvuspb.CheckHealthResponse{IsHealthy: false}, nil)
|
|
node := &Proxy{
|
|
mixCoord: mixc,
|
|
session: &sessionutil.Session{SessionRaw: sessionutil.SessionRaw{ServerID: 1}},
|
|
}
|
|
node.UpdateStateCode(commonpb.StateCode_Healthy)
|
|
mixCoord := mocks.NewMockMixCoordClient(t)
|
|
mixCoord.On("DescribeCollection", mock.Anything, mock.Anything).Return(nil, merr.ErrCollectionNotFound).Maybe()
|
|
var err error
|
|
globalMetaCache, err = NewMetaCache(mixCoord)
|
|
assert.NoError(t, err)
|
|
interceptor, err := NewInterceptor[*milvuspb.DescribeCollectionRequest, *milvuspb.DescribeCollectionResponse](node, "DescribeCollection")
|
|
assert.NoError(t, err)
|
|
resp, err := interceptor.Call(context.Background(), &milvuspb.DescribeCollectionRequest{
|
|
DbName: "test",
|
|
CollectionName: "test",
|
|
})
|
|
assert.NoError(t, err)
|
|
assert.Equal(t, "can't find collection[database=test][collection=test]", resp.Status.Reason)
|
|
}
|