2021-10-20 19:41:37 +08:00
|
|
|
// Licensed to the LF AI & Data foundation under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
2021-09-15 17:29:49 +08:00
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
2021-10-20 19:41:37 +08:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2021-09-15 17:29:49 +08:00
|
|
|
//
|
2021-10-20 19:41:37 +08:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2021-09-15 17:29:49 +08:00
|
|
|
|
|
|
|
package grpcproxy
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-05-25 18:56:00 +08:00
|
|
|
"crypto/tls"
|
|
|
|
"crypto/x509"
|
|
|
|
"encoding/json"
|
2022-03-15 15:05:21 +08:00
|
|
|
"fmt"
|
2023-10-18 16:36:12 +08:00
|
|
|
"net/http/httptest"
|
2022-05-25 18:56:00 +08:00
|
|
|
"os"
|
|
|
|
"strconv"
|
2023-11-27 16:28:34 +08:00
|
|
|
"sync/atomic"
|
2021-09-15 17:29:49 +08:00
|
|
|
"testing"
|
2022-05-25 18:56:00 +08:00
|
|
|
"time"
|
2021-09-15 17:29:49 +08:00
|
|
|
|
2023-02-26 11:31:49 +08:00
|
|
|
"github.com/cockroachdb/errors"
|
2023-10-18 16:36:12 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
2023-01-04 19:37:36 +08:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/mock"
|
2022-05-25 18:56:00 +08:00
|
|
|
"go.uber.org/zap"
|
2023-11-27 16:28:34 +08:00
|
|
|
"golang.org/x/sync/errgroup"
|
2022-05-25 18:56:00 +08:00
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/credentials"
|
2023-08-09 13:37:16 +08:00
|
|
|
"google.golang.org/grpc/credentials/insecure"
|
2023-01-04 19:37:36 +08:00
|
|
|
"google.golang.org/grpc/health/grpc_health_v1"
|
2022-05-25 18:56:00 +08:00
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
|
2023-08-24 09:14:23 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/federpb"
|
2023-06-09 01:28:37 +08:00
|
|
|
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
|
2023-11-27 16:28:34 +08:00
|
|
|
grpcproxyclient "github.com/milvus-io/milvus/internal/distributed/proxy/client"
|
2023-10-18 16:36:12 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/distributed/proxy/httpserver"
|
2023-07-14 10:12:31 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/mocks"
|
2022-03-10 10:35:59 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proxy"
|
2024-07-26 18:07:53 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/hookutil"
|
2023-09-21 09:45:27 +08:00
|
|
|
milvusmock "github.com/milvus-io/milvus/internal/util/mock"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
2023-11-27 16:28:34 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/metricsinfo"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/paramtable"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/uniquegenerator"
|
2021-09-15 17:29:49 +08:00
|
|
|
)
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
func TestMain(m *testing.M) {
|
|
|
|
paramtable.Init()
|
|
|
|
code := m.Run()
|
|
|
|
os.Exit(code)
|
|
|
|
}
|
|
|
|
|
2023-10-20 14:26:09 +08:00
|
|
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2022-05-25 18:56:00 +08:00
|
|
|
type WaitOption struct {
|
|
|
|
Duration time.Duration `json:"duration"`
|
|
|
|
Port int `json:"port"`
|
2022-06-02 18:56:04 +08:00
|
|
|
TLSMode int `json:"tls_mode"`
|
2022-05-25 18:56:00 +08:00
|
|
|
ClientPemPath string `json:"client_pem_path"`
|
|
|
|
ClientKeyPath string `json:"client_key_path"`
|
|
|
|
CaPath string `json:"ca_path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (opt *WaitOption) String() string {
|
|
|
|
s, err := json.Marshal(*opt)
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Sprintf("error: %s", err)
|
|
|
|
}
|
|
|
|
return string(s)
|
|
|
|
}
|
|
|
|
|
2022-06-02 18:56:04 +08:00
|
|
|
func newWaitOption(duration time.Duration, Port int, tlsMode int, clientPemPath, clientKeyPath, clientCaPath string) *WaitOption {
|
2022-05-25 18:56:00 +08:00
|
|
|
return &WaitOption{
|
|
|
|
Duration: duration,
|
|
|
|
Port: Port,
|
2022-06-02 18:56:04 +08:00
|
|
|
TLSMode: tlsMode,
|
2022-05-25 18:56:00 +08:00
|
|
|
ClientPemPath: clientPemPath,
|
|
|
|
ClientKeyPath: clientKeyPath,
|
|
|
|
CaPath: clientCaPath,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func withCredential(clientPemPath, clientKeyPath, clientCaPath string) (credentials.TransportCredentials, error) {
|
|
|
|
cert, err := tls.LoadX509KeyPair(clientPemPath, clientKeyPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
certPool := x509.NewCertPool()
|
|
|
|
ca, err := os.ReadFile(clientCaPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if ok := certPool.AppendCertsFromPEM(ca); !ok {
|
|
|
|
return nil, errors.New("failed to AppendCertsFromPEM")
|
|
|
|
}
|
|
|
|
creds := credentials.NewTLS(&tls.Config{
|
|
|
|
Certificates: []tls.Certificate{cert},
|
|
|
|
ServerName: "localhost",
|
|
|
|
RootCAs: certPool,
|
|
|
|
MinVersion: tls.VersionTLS13,
|
|
|
|
})
|
|
|
|
return creds, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// waitForGrpcReady block until service available or panic after times out.
|
|
|
|
func waitForGrpcReady(opt *WaitOption) {
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-05-25 18:56:00 +08:00
|
|
|
ch := make(chan error, 1)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
// just used in UT to self-check service is available.
|
|
|
|
address := "localhost:" + strconv.Itoa(opt.Port)
|
2022-06-02 18:56:04 +08:00
|
|
|
var err error
|
|
|
|
|
|
|
|
if opt.TLSMode == 1 || opt.TLSMode == 2 {
|
|
|
|
var creds credentials.TransportCredentials
|
|
|
|
if opt.TLSMode == 1 {
|
2022-12-16 15:59:23 +08:00
|
|
|
creds, err = credentials.NewClientTLSFromFile(Params.ServerPemPath.GetValue(), "localhost")
|
2022-06-02 18:56:04 +08:00
|
|
|
} else {
|
|
|
|
creds, err = withCredential(opt.ClientPemPath, opt.ClientKeyPath, opt.CaPath)
|
|
|
|
}
|
2022-05-25 18:56:00 +08:00
|
|
|
if err != nil {
|
|
|
|
ch <- err
|
2022-06-02 18:56:04 +08:00
|
|
|
return
|
2022-05-25 18:56:00 +08:00
|
|
|
}
|
2023-08-08 10:15:07 +08:00
|
|
|
conn, err := grpc.Dial(address, grpc.WithBlock(), grpc.WithTransportCredentials(creds))
|
2022-05-25 18:56:00 +08:00
|
|
|
ch <- err
|
2023-08-08 10:15:07 +08:00
|
|
|
conn.Close()
|
2022-06-02 18:56:04 +08:00
|
|
|
return
|
|
|
|
}
|
2023-08-09 13:37:16 +08:00
|
|
|
if conn, err := grpc.Dial(address, grpc.WithBlock(), grpc.WithTransportCredentials(insecure.NewCredentials())); true {
|
2022-06-02 18:56:04 +08:00
|
|
|
ch <- err
|
2023-08-08 10:15:07 +08:00
|
|
|
conn.Close()
|
2022-05-25 18:56:00 +08:00
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2023-02-23 18:59:45 +08:00
|
|
|
timer := time.NewTimer(opt.Duration)
|
|
|
|
|
2022-05-25 18:56:00 +08:00
|
|
|
select {
|
|
|
|
case err := <-ch:
|
|
|
|
if err != nil {
|
|
|
|
log.Error("grpc service not ready",
|
|
|
|
zap.Error(err),
|
|
|
|
zap.Any("option", opt))
|
|
|
|
panic(err)
|
|
|
|
}
|
2023-02-23 18:59:45 +08:00
|
|
|
case <-timer.C:
|
2022-05-25 18:56:00 +08:00
|
|
|
log.Error("grpc service not ready",
|
|
|
|
zap.Any("option", opt))
|
|
|
|
panic("grpc service not ready")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: should tls-related configurations be hard code here?
|
2023-09-21 09:45:27 +08:00
|
|
|
var (
|
|
|
|
waitDuration = time.Second * 1
|
|
|
|
clientPemPath = "../../../configs/cert/client.pem"
|
|
|
|
clientKeyPath = "../../../configs/cert/client.key"
|
|
|
|
)
|
2022-05-25 18:56:00 +08:00
|
|
|
|
|
|
|
// waitForServerReady wait for internal grpc service and external service to be ready, according to the params.
|
|
|
|
func waitForServerReady() {
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
|
|
|
waitForGrpcReady(newWaitOption(waitDuration, Params.InternalPort.GetAsInt(), 0, "", "", ""))
|
|
|
|
waitForGrpcReady(newWaitOption(waitDuration, Params.Port.GetAsInt(), Params.TLSMode.GetAsInt(), clientPemPath, clientKeyPath, Params.CaPemPath.GetValue()))
|
2022-05-25 18:56:00 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func runAndWaitForServerReady(server *Server) error {
|
2024-09-26 21:23:16 +08:00
|
|
|
if err := server.Prepare(); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2022-05-25 18:56:00 +08:00
|
|
|
err := server.Run()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
waitForServerReady()
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
2021-09-15 17:29:49 +08:00
|
|
|
func Test_NewServer(t *testing.T) {
|
2022-11-04 14:25:38 +08:00
|
|
|
paramtable.Init()
|
2021-10-14 17:48:34 +08:00
|
|
|
ctx := context.Background()
|
|
|
|
|
2023-02-16 15:38:34 +08:00
|
|
|
server := getServer(t)
|
2023-12-13 10:46:44 +08:00
|
|
|
assert.NotNil(t, server)
|
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
t.Run("Run", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
err := runAndWaitForServerReady(server)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
err = server.Stop()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetComponentStates", func(t *testing.T) {
|
|
|
|
_, err := server.GetComponentStates(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetStatisticsChannel", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetStatisticsChannel(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetStatisticsChannel(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("InvalidateCollectionMetaCache", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().InvalidateCollectionMetaCache(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.InvalidateCollectionMetaCache(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
2024-05-08 10:05:29 +08:00
|
|
|
t.Run("InvalidateShardLeaderCache", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().InvalidateShardLeaderCache(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
_, err := server.InvalidateShardLeaderCache(ctx, nil)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
t.Run("CreateCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.CreateCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DropCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("HasCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().HasCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().HasCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.HasCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("LoadCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().LoadCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().LoadCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.LoadCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ReleaseCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ReleaseCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.ReleaseCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DescribeCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DescribeCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DescribeCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetCollectionStatistics", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetCollectionStatistics(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetCollectionStatistics(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ShowCollections", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.ShowCollections(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("CreatePartition", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreatePartition(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.CreatePartition(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropPartition", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropPartition(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DropPartition(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("HasPartition", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().HasPartition(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.HasPartition(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("LoadPartitions", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().LoadPartitions(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.LoadPartitions(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ReleasePartitions", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ReleasePartitions(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.ReleasePartitions(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetPartitionStatistics", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetPartitionStatistics(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetPartitionStatistics(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ShowPartitions", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ShowPartitions(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.ShowPartitions(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
2022-10-01 09:02:55 +08:00
|
|
|
t.Run("GetLoadingProgress", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetLoadingProgress(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-10-01 09:02:55 +08:00
|
|
|
_, err := server.GetLoadingProgress(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-01 09:02:55 +08:00
|
|
|
})
|
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
t.Run("CreateIndex", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateIndex(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.CreateIndex(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropIndex", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropIndex(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DropIndex(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DescribeIndex", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DescribeIndex(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DescribeIndex(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-04-23 14:50:32 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetIndexStatistics", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetIndexStatistics(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-04-23 14:50:32 +08:00
|
|
|
_, err := server.GetIndexStatistics(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetIndexBuildProgress", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetIndexBuildProgress(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetIndexBuildProgress(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetIndexState", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetIndexState(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetIndexState(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Insert", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Insert(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Insert(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Delete", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Delete(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Delete(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
t.Run("Upsert", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Upsert(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-04 17:21:36 +08:00
|
|
|
_, err := server.Upsert(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-04 17:21:36 +08:00
|
|
|
})
|
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
t.Run("Search", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Search(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Search(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Flush", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Flush(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Flush(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Query", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Query(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Query(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("CalcDistance", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CalcDistance(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.CalcDistance(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetDdChannel", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetDdChannel(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetDdChannel(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetPersistentSegmentInfo", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetPersistentSegmentInfo(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetPersistentSegmentInfo(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetQuerySegmentInfo", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetQuerySegmentInfo(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetQuerySegmentInfo(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("Dummy", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Dummy(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.Dummy(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("RegisterLink", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().RegisterLink(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.RegisterLink(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetMetrics", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetMetrics(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.GetMetrics(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
2021-11-06 16:54:59 +08:00
|
|
|
t.Run("LoadBalance", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().LoadBalance(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-11-06 16:54:59 +08:00
|
|
|
_, err := server.LoadBalance(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-06 16:54:59 +08:00
|
|
|
})
|
|
|
|
|
2021-10-14 17:48:34 +08:00
|
|
|
t.Run("CreateAlias", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateAlias(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.CreateAlias(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropAlias", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropAlias(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.DropAlias(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("AlterAlias", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().AlterAlias(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-10-14 17:48:34 +08:00
|
|
|
_, err := server.AlterAlias(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-10-14 17:48:34 +08:00
|
|
|
})
|
|
|
|
|
2024-01-11 19:12:51 +08:00
|
|
|
t.Run("DescribeAlias", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().DescribeAlias(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
_, err := server.DescribeAlias(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ListAliases", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().ListAliases(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
_, err := server.ListAliases(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
2021-11-09 14:47:02 +08:00
|
|
|
t.Run("GetCompactionState", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetCompactionState(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-11-09 14:47:02 +08:00
|
|
|
_, err := server.GetCompactionState(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ManualCompaction", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ManualCompaction(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-11-09 14:47:02 +08:00
|
|
|
_, err := server.ManualCompaction(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetCompactionStateWithPlans", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetCompactionStateWithPlans(mock.Anything, mock.Anything).Return(nil, nil)
|
2021-11-09 14:47:02 +08:00
|
|
|
_, err := server.GetCompactionStateWithPlans(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
t.Run("CreateCredential", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateCredential(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.CreateCredential(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("UpdateCredential", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().UpdateCredential(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.UpdateCredential(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DeleteCredential", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DeleteCredential(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.DeleteCredential(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ListCredUsers", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ListCredUsers(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.ListCredUsers(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("InvalidateCredentialCache", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().InvalidateCredentialCache(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.InvalidateCredentialCache(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("UpdateCredentialCache", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().UpdateCredentialCache(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-04-11 19:49:34 +08:00
|
|
|
_, err := server.UpdateCredentialCache(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-11 19:49:34 +08:00
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
t.Run("CreateRole", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateRole(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.CreateRole(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropRole", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropRole(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.DropRole(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("OperateUserRole", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().OperateUserRole(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.OperateUserRole(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("SelectRole", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().SelectRole(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.SelectRole(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("SelectUser", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().SelectUser(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.SelectUser(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("OperatePrivilege", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().OperatePrivilege(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.OperatePrivilege(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("SelectGrant", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().SelectGrant(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.SelectGrant(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("RefreshPrivilegeInfoCache", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().RefreshPolicyInfoCache(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-08-04 11:04:34 +08:00
|
|
|
_, err := server.RefreshPolicyInfoCache(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
2022-10-18 13:39:26 +08:00
|
|
|
t.Run("CheckHealth", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CheckHealth(mock.Anything, mock.Anything).Return(nil, nil)
|
2022-10-18 13:39:26 +08:00
|
|
|
_, err := server.CheckHealth(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-19 14:13:43 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("RenameCollection", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().RenameCollection(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-19 14:13:43 +08:00
|
|
|
_, err := server.RenameCollection(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("CreateResourceGroup", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateResourceGroup(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.CreateResourceGroup(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropResourceGroup", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropResourceGroup(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.DropResourceGroup(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("TransferNode", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().TransferNode(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.TransferNode(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("TransferReplica", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().TransferReplica(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.TransferReplica(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ListResourceGroups", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ListResourceGroups(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.ListResourceGroups(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-30 10:19:48 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DescribeResourceGroup", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DescribeResourceGroup(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-01-30 10:19:48 +08:00
|
|
|
_, err := server.DescribeResourceGroup(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-18 13:39:26 +08:00
|
|
|
})
|
|
|
|
|
2023-03-30 11:28:25 +08:00
|
|
|
t.Run("FlushAll", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().FlushAll(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-03-30 11:28:25 +08:00
|
|
|
_, err := server.FlushAll(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-03-30 11:28:25 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("GetFlushAllState", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().GetFlushAllState(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-03-30 11:28:25 +08:00
|
|
|
_, err := server.GetFlushAllState(ctx, nil)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2023-03-30 11:28:25 +08:00
|
|
|
})
|
|
|
|
|
2023-06-25 17:20:43 +08:00
|
|
|
t.Run("CreateDatabase", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().CreateDatabase(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-06-25 17:20:43 +08:00
|
|
|
_, err := server.CreateDatabase(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DropDatabase", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().DropDatabase(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-06-25 17:20:43 +08:00
|
|
|
_, err := server.DropDatabase(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("ListDatabase", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().ListDatabases(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-06-25 17:20:43 +08:00
|
|
|
_, err := server.ListDatabases(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
2023-07-25 10:05:00 +08:00
|
|
|
|
2024-04-28 18:15:31 +08:00
|
|
|
t.Run("AlterDatabase", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().AlterDatabase(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
_, err := server.AlterDatabase(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
2024-05-09 22:51:30 +08:00
|
|
|
t.Run("DescribeDatabase", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().DescribeDatabase(mock.Anything, mock.Anything).Return(nil, nil)
|
|
|
|
_, err := server.DescribeDatabase(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
|
|
|
|
2023-07-25 10:05:00 +08:00
|
|
|
t.Run("AllocTimestamp", func(t *testing.T) {
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().AllocTimestamp(mock.Anything, mock.Anything).Return(nil, nil)
|
2023-07-25 10:05:00 +08:00
|
|
|
_, err := server.AllocTimestamp(ctx, nil)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
})
|
2022-03-10 10:35:59 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
t.Run("Run with different config", func(t *testing.T) {
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
// Update config and start server again to test with different config set.
|
|
|
|
// This works as config will be initialized only once
|
|
|
|
paramtable.Get().Save(proxy.Params.ProxyCfg.GinLogging.Key, "false")
|
|
|
|
err := runAndWaitForServerReady(server)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
err = server.Stop()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
2021-09-15 17:29:49 +08:00
|
|
|
}
|
2022-02-23 14:37:52 +08:00
|
|
|
|
2022-03-15 15:05:21 +08:00
|
|
|
func TestServer_Check(t *testing.T) {
|
|
|
|
ctx := context.Background()
|
2023-02-16 15:38:34 +08:00
|
|
|
server := getServer(t)
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
2022-03-15 15:05:21 +08:00
|
|
|
|
|
|
|
req := &grpc_health_v1.HealthCheckRequest{Service: ""}
|
|
|
|
ret, err := server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, ret.Status)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.ExpectedCalls = nil
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(nil, fmt.Errorf("mock grpc unexpected error"))
|
2022-03-15 15:05:21 +08:00
|
|
|
|
|
|
|
ret, err = server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo := &milvuspb.ComponentInfo{
|
2022-03-15 15:05:21 +08:00
|
|
|
NodeID: 0,
|
|
|
|
Role: "proxy",
|
2022-10-10 15:55:22 +08:00
|
|
|
StateCode: commonpb.StateCode_Abnormal,
|
2022-03-15 15:05:21 +08:00
|
|
|
}
|
|
|
|
status := &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError}
|
2022-10-10 15:55:22 +08:00
|
|
|
componentState := &milvuspb.ComponentStates{
|
2022-03-15 15:05:21 +08:00
|
|
|
State: componentInfo,
|
|
|
|
Status: status,
|
|
|
|
}
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.ExpectedCalls = nil
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(componentState, nil)
|
2022-03-15 15:05:21 +08:00
|
|
|
ret, err = server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
|
|
|
status.ErrorCode = commonpb.ErrorCode_Success
|
|
|
|
ret, err = server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo.StateCode = commonpb.StateCode_Initializing
|
2022-03-15 15:05:21 +08:00
|
|
|
ret, err = server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo.StateCode = commonpb.StateCode_Healthy
|
2022-03-15 15:05:21 +08:00
|
|
|
ret, err = server.Check(ctx, req)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, ret.Status)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestServer_Watch(t *testing.T) {
|
2023-02-16 15:38:34 +08:00
|
|
|
server := getServer(t)
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
2022-03-15 15:05:21 +08:00
|
|
|
|
|
|
|
watchServer := milvusmock.NewGrpcHealthWatchServer()
|
|
|
|
resultChan := watchServer.Chan()
|
|
|
|
req := &grpc_health_v1.HealthCheckRequest{Service: ""}
|
2023-09-21 09:45:27 +08:00
|
|
|
// var ret *grpc_health_v1.HealthCheckResponse
|
2023-02-16 15:38:34 +08:00
|
|
|
err := server.Watch(req, watchServer)
|
2022-03-15 15:05:21 +08:00
|
|
|
ret := <-resultChan
|
|
|
|
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, ret.Status)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.ExpectedCalls = nil
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(nil, fmt.Errorf("mock grpc unexpected error"))
|
2022-03-15 15:05:21 +08:00
|
|
|
|
|
|
|
err = server.Watch(req, watchServer)
|
|
|
|
ret = <-resultChan
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo := &milvuspb.ComponentInfo{
|
2022-03-15 15:05:21 +08:00
|
|
|
NodeID: 0,
|
|
|
|
Role: "proxy",
|
2022-10-10 15:55:22 +08:00
|
|
|
StateCode: commonpb.StateCode_Abnormal,
|
2022-03-15 15:05:21 +08:00
|
|
|
}
|
|
|
|
status := &commonpb.Status{ErrorCode: commonpb.ErrorCode_UnexpectedError}
|
2022-10-10 15:55:22 +08:00
|
|
|
componentState := &milvuspb.ComponentStates{
|
2022-03-15 15:05:21 +08:00
|
|
|
State: componentInfo,
|
|
|
|
Status: status,
|
|
|
|
}
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.ExpectedCalls = nil
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(componentState, nil)
|
2022-03-15 15:05:21 +08:00
|
|
|
|
|
|
|
err = server.Watch(req, watchServer)
|
|
|
|
ret = <-resultChan
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
|
|
|
status.ErrorCode = commonpb.ErrorCode_Success
|
|
|
|
err = server.Watch(req, watchServer)
|
|
|
|
ret = <-resultChan
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo.StateCode = commonpb.StateCode_Initializing
|
2022-03-15 15:05:21 +08:00
|
|
|
err = server.Watch(req, watchServer)
|
|
|
|
ret = <-resultChan
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_NOT_SERVING, ret.Status)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
componentInfo.StateCode = commonpb.StateCode_Healthy
|
2022-03-15 15:05:21 +08:00
|
|
|
err = server.Watch(req, watchServer)
|
|
|
|
ret = <-resultChan
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-15 15:05:21 +08:00
|
|
|
assert.Equal(t, grpc_health_v1.HealthCheckResponse_SERVING, ret.Status)
|
|
|
|
}
|
|
|
|
|
2022-06-24 15:34:14 +08:00
|
|
|
func Test_NewServer_HTTPServer_Enabled(t *testing.T) {
|
2023-02-16 15:38:34 +08:00
|
|
|
server := getServer(t)
|
2022-02-23 14:37:52 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "true")
|
2023-02-16 15:38:34 +08:00
|
|
|
err := runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-02-23 14:37:52 +08:00
|
|
|
err = server.Stop()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-06-24 15:34:14 +08:00
|
|
|
|
|
|
|
defer func() {
|
|
|
|
e := recover()
|
|
|
|
if e == nil {
|
|
|
|
t.Fatalf("test should have panicked but did not")
|
|
|
|
}
|
|
|
|
}()
|
2023-08-08 10:15:07 +08:00
|
|
|
// if disable works path not registered, so it shall not panic
|
2022-06-24 15:34:14 +08:00
|
|
|
server.registerHTTPServer()
|
2022-02-23 14:37:52 +08:00
|
|
|
}
|
2022-06-02 18:56:04 +08:00
|
|
|
|
|
|
|
func getServer(t *testing.T) *Server {
|
2022-05-10 20:05:53 +08:00
|
|
|
ctx := context.Background()
|
|
|
|
server, err := NewServer(ctx, nil)
|
|
|
|
assert.NotNil(t, server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-05-10 20:05:53 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := mocks.NewMockProxy(t)
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
|
|
|
|
Role: "MockProxy",
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
|
|
|
}, nil).Maybe()
|
|
|
|
server.proxy = mockProxy
|
2023-02-16 15:38:34 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockRC := mocks.NewMockRootCoordClient(t)
|
|
|
|
mockRC.EXPECT().GetComponentStates(mock.Anything, mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
|
|
|
|
Role: "MockRootCoord",
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
|
|
|
}, nil).Maybe()
|
|
|
|
server.rootCoordClient = mockRC
|
|
|
|
|
|
|
|
mockDC := mocks.NewMockDataCoordClient(t)
|
|
|
|
mockDC.EXPECT().GetComponentStates(mock.Anything, mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
|
|
|
|
Role: "MockDataCoord",
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
|
|
|
}, nil).Maybe()
|
|
|
|
server.dataCoordClient = mockDC
|
|
|
|
|
|
|
|
mockQC := mocks.NewMockQueryCoordClient(t)
|
2023-02-16 15:38:34 +08:00
|
|
|
server.queryCoordClient = mockQC
|
2023-09-26 09:57:25 +08:00
|
|
|
mockQC.EXPECT().GetComponentStates(mock.Anything, mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
2023-02-16 15:38:34 +08:00
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
|
|
|
|
Role: "MockQueryCoord",
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
2023-12-13 10:46:44 +08:00
|
|
|
}, nil).Maybe()
|
2022-06-02 18:56:04 +08:00
|
|
|
return server
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_NewServer_TLS_TwoWay(t *testing.T) {
|
|
|
|
server := getServer(t)
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-05-10 20:05:53 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "2")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../../../configs/cert/ca.pem")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "false")
|
2022-05-10 20:05:53 +08:00
|
|
|
|
2022-06-02 18:56:04 +08:00
|
|
|
err := runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
assert.NotNil(t, server.grpcExternalServer)
|
|
|
|
err = server.Stop()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_NewServer_TLS_OneWay(t *testing.T) {
|
|
|
|
server := getServer(t)
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-05-25 18:56:00 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "1")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "false")
|
2022-06-02 18:56:04 +08:00
|
|
|
|
|
|
|
err := runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
assert.NotNil(t, server.grpcExternalServer)
|
2022-05-10 20:05:53 +08:00
|
|
|
err = server.Stop()
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-05-10 20:05:53 +08:00
|
|
|
}
|
2022-06-02 18:56:04 +08:00
|
|
|
|
|
|
|
func Test_NewServer_TLS_FileNotExisted(t *testing.T) {
|
|
|
|
server := getServer(t)
|
2022-12-16 15:59:23 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
2022-06-02 18:56:04 +08:00
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "1")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../not/existed/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "false")
|
2022-06-02 18:56:04 +08:00
|
|
|
err := runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
server.Stop()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "2")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../not/existed/server.pem")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../../../configs/cert/ca.pem")
|
2022-06-02 18:56:04 +08:00
|
|
|
err = runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
server.Stop()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../not/existed/ca.pem")
|
2022-06-02 18:56:04 +08:00
|
|
|
err = runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
server.Stop()
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "service.go")
|
2022-06-02 18:56:04 +08:00
|
|
|
err = runAndWaitForServerReady(server)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.Error(t, err)
|
2022-06-02 18:56:04 +08:00
|
|
|
server.Stop()
|
|
|
|
}
|
2022-10-14 09:59:24 +08:00
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
func Test_NewHTTPServer_TLS_TwoWay(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "2")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../../../configs/cert/ca.pem")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "true")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "8080")
|
|
|
|
|
|
|
|
err := runAndWaitForServerReady(server)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, server.grpcExternalServer)
|
|
|
|
err = server.Stop()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "19529")
|
|
|
|
err = runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
2024-09-26 21:23:16 +08:00
|
|
|
err = server.Stop()
|
|
|
|
assert.Nil(t, err)
|
2023-08-08 10:15:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func Test_NewHTTPServer_TLS_OneWay(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
|
|
|
|
2023-08-08 10:15:07 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "1")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "true")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "8080")
|
|
|
|
|
|
|
|
err := runAndWaitForServerReady(server)
|
2024-09-26 21:23:16 +08:00
|
|
|
fmt.Printf("err: %v\n", err)
|
2023-08-08 10:15:07 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.NotNil(t, server.grpcExternalServer)
|
|
|
|
err = server.Stop()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "19529")
|
2024-09-26 21:23:16 +08:00
|
|
|
fmt.Printf("err: %v\n", err)
|
2023-08-08 10:15:07 +08:00
|
|
|
err = runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
server.Stop()
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_NewHTTPServer_TLS_FileNotExisted(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
2024-09-26 21:23:16 +08:00
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return().Maybe()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return().Maybe()
|
2023-08-08 10:15:07 +08:00
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "1")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../not/existed/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "true")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "8080")
|
|
|
|
err := runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
server.Stop()
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "2")
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../not/existed/server.pem")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../../../configs/cert/ca.pem")
|
|
|
|
err = runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
server.Stop()
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "../not/existed/ca.pem")
|
|
|
|
err = runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
server.Stop()
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.CaPemPath.Key, "service.go")
|
|
|
|
err = runAndWaitForServerReady(server)
|
|
|
|
assert.NotNil(t, err)
|
|
|
|
server.Stop()
|
|
|
|
}
|
|
|
|
|
2022-10-14 09:59:24 +08:00
|
|
|
func Test_NewServer_GetVersion(t *testing.T) {
|
|
|
|
req := &milvuspb.GetVersionRequest{}
|
|
|
|
t.Run("test get version failed", func(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
resp, err := server.GetVersion(context.TODO(), req)
|
|
|
|
assert.Empty(t, resp.GetVersion())
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-14 09:59:24 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test get version failed", func(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
err := os.Setenv(metricsinfo.GitBuildTagsEnvKey, "v1")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
resp, err := server.GetVersion(context.TODO(), req)
|
|
|
|
assert.Equal(t, "v1", resp.GetVersion())
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-10-14 09:59:24 +08:00
|
|
|
})
|
|
|
|
}
|
2023-08-24 09:14:23 +08:00
|
|
|
|
|
|
|
func TestNotImplementedAPIs(t *testing.T) {
|
|
|
|
server := getServer(t)
|
|
|
|
|
|
|
|
t.Run("ListIndexedSegment", func(t *testing.T) {
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
resp, err := server.ListIndexedSegment(context.TODO(), &federpb.ListIndexedSegmentRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("DescribeSegmentIndexData", func(t *testing.T) {
|
|
|
|
assert.NotPanics(t, func() {
|
|
|
|
resp, err := server.DescribeSegmentIndexData(context.TODO(), &federpb.DescribeSegmentIndexDataRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, resp)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
2023-10-18 16:36:12 +08:00
|
|
|
|
|
|
|
func TestHttpAuthenticate(t *testing.T) {
|
|
|
|
paramtable.Get().Save(proxy.Params.CommonCfg.AuthorizationEnabled.Key, "true")
|
|
|
|
defer paramtable.Get().Reset(proxy.Params.CommonCfg.AuthorizationEnabled.Key)
|
|
|
|
ctx, _ := gin.CreateTestContext(nil)
|
|
|
|
ctx.Request = httptest.NewRequest("GET", "/test", nil)
|
|
|
|
{
|
|
|
|
assert.Panics(t, func() {
|
|
|
|
ctx.Request.Header.Set("Authorization", "Bearer 123456")
|
|
|
|
authenticate(ctx)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2024-07-26 18:07:53 +08:00
|
|
|
hookutil.SetMockAPIHook("foo", nil)
|
|
|
|
defer hookutil.SetMockAPIHook("", nil)
|
2023-10-18 16:36:12 +08:00
|
|
|
ctx.Request.Header.Set("Authorization", "Bearer 123456")
|
|
|
|
authenticate(ctx)
|
|
|
|
ctxName, _ := ctx.Get(httpserver.ContextUsername)
|
|
|
|
assert.Equal(t, "foo", ctxName)
|
|
|
|
}
|
|
|
|
}
|
2023-11-27 16:28:34 +08:00
|
|
|
|
|
|
|
func Test_Service_GracefulStop(t *testing.T) {
|
|
|
|
var count int32
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
server := getServer(t)
|
|
|
|
assert.NotNil(t, server)
|
|
|
|
|
|
|
|
mockProxy := server.proxy.(*mocks.MockProxy)
|
|
|
|
mockProxy.ExpectedCalls = nil
|
|
|
|
mockProxy.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Run(func(_a0 context.Context, _a1 *milvuspb.GetComponentStatesRequest) {
|
2023-11-27 16:28:34 +08:00
|
|
|
fmt.Println("rpc start")
|
|
|
|
time.Sleep(10 * time.Second)
|
|
|
|
atomic.AddInt32(&count, 1)
|
|
|
|
fmt.Println("rpc done")
|
|
|
|
}).Return(&milvuspb.ComponentStates{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}}, nil)
|
|
|
|
|
2023-12-13 10:46:44 +08:00
|
|
|
mockProxy.EXPECT().Init().Return(nil)
|
|
|
|
mockProxy.EXPECT().Start().Return(nil)
|
|
|
|
mockProxy.EXPECT().Stop().Return(nil)
|
|
|
|
mockProxy.EXPECT().Register().Return(nil)
|
|
|
|
mockProxy.EXPECT().SetEtcdClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().GetRateLimiter().Return(nil, nil)
|
|
|
|
mockProxy.EXPECT().SetDataCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetRootCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetQueryCoordClient(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().UpdateStateCode(mock.Anything).Return()
|
|
|
|
mockProxy.EXPECT().SetAddress(mock.Anything).Return()
|
2023-11-27 16:28:34 +08:00
|
|
|
|
|
|
|
Params := ¶mtable.Get().ProxyGrpcServerCfg
|
|
|
|
|
|
|
|
paramtable.Get().Save(Params.TLSMode.Key, "0")
|
|
|
|
paramtable.Get().Save(Params.Port.Key, fmt.Sprintf("%d", funcutil.GetAvailablePort()))
|
|
|
|
paramtable.Get().Save(Params.InternalPort.Key, fmt.Sprintf("%d", funcutil.GetAvailablePort()))
|
|
|
|
paramtable.Get().Save(Params.ServerPemPath.Key, "../../../configs/cert/server.pem")
|
|
|
|
paramtable.Get().Save(Params.ServerKeyPath.Key, "../../../configs/cert/server.key")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Enabled.Key, "true")
|
|
|
|
paramtable.Get().Save(proxy.Params.HTTPCfg.Port.Key, "")
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
enableCustomInterceptor = false
|
|
|
|
enableRegisterProxyServer = true
|
|
|
|
defer func() {
|
|
|
|
enableCustomInterceptor = true
|
|
|
|
enableRegisterProxyServer = false
|
|
|
|
}()
|
|
|
|
|
2024-09-26 21:23:16 +08:00
|
|
|
err := server.Prepare()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
err = server.Run()
|
2023-11-27 16:28:34 +08:00
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
proxyClient, err := grpcproxyclient.NewClient(ctx, fmt.Sprintf("localhost:%s", Params.Port.GetValue()), 0)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
|
|
|
|
group := &errgroup.Group{}
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
group.Go(func() error {
|
|
|
|
_, err := proxyClient.GetComponentStates(context.TODO(), &milvuspb.GetComponentStatesRequest{})
|
|
|
|
return err
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// waiting for all requests have been launched
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
|
|
|
|
server.Stop()
|
|
|
|
|
|
|
|
err = group.Wait()
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.Equal(t, count, int32(3))
|
|
|
|
}
|