2021-11-10 23:56:01 +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
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// 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-09 10:06:29 +08:00
|
|
|
package proxy
|
|
|
|
|
|
|
|
import (
|
2023-10-16 15:34:08 +08:00
|
|
|
"bytes"
|
2021-09-09 10:06:29 +08:00
|
|
|
"context"
|
2023-10-16 15:34:08 +08:00
|
|
|
"encoding/binary"
|
|
|
|
"encoding/json"
|
2022-08-04 11:04:34 +08:00
|
|
|
"fmt"
|
2023-08-04 18:37:08 +08:00
|
|
|
"math/rand"
|
2022-01-17 14:41:35 +08:00
|
|
|
"net"
|
2021-09-09 10:06:29 +08:00
|
|
|
"os"
|
|
|
|
"strconv"
|
|
|
|
"sync"
|
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
|
2023-02-26 11:31:49 +08:00
|
|
|
"github.com/cockroachdb/errors"
|
2022-04-20 16:15:41 +08:00
|
|
|
"github.com/golang/protobuf/proto"
|
2022-09-16 09:56:47 +08:00
|
|
|
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
|
2023-06-25 17:20:43 +08:00
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/mock"
|
2023-01-12 16:09:39 +08:00
|
|
|
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
|
2023-06-25 17:20:43 +08:00
|
|
|
"go.uber.org/zap"
|
|
|
|
"google.golang.org/grpc"
|
|
|
|
"google.golang.org/grpc/keepalive"
|
2023-01-12 16:09:39 +08:00
|
|
|
|
2023-06-09 01:28:37 +08:00
|
|
|
"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-proto/go-api/v2/schemapb"
|
2021-09-09 10:06:29 +08:00
|
|
|
grpcdatacoordclient "github.com/milvus-io/milvus/internal/distributed/datacoord"
|
2022-04-20 16:15:41 +08:00
|
|
|
grpcdatacoordclient2 "github.com/milvus-io/milvus/internal/distributed/datacoord/client"
|
2021-09-09 10:06:29 +08:00
|
|
|
grpcdatanode "github.com/milvus-io/milvus/internal/distributed/datanode"
|
2022-04-20 16:15:41 +08:00
|
|
|
grpcindexnode "github.com/milvus-io/milvus/internal/distributed/indexnode"
|
2021-09-09 10:06:29 +08:00
|
|
|
grpcquerycoord "github.com/milvus-io/milvus/internal/distributed/querycoord"
|
2022-04-20 16:15:41 +08:00
|
|
|
grpcquerycoordclient "github.com/milvus-io/milvus/internal/distributed/querycoord/client"
|
|
|
|
grpcquerynode "github.com/milvus-io/milvus/internal/distributed/querynode"
|
2021-09-09 10:06:29 +08:00
|
|
|
grpcrootcoord "github.com/milvus-io/milvus/internal/distributed/rootcoord"
|
2022-04-20 16:15:41 +08:00
|
|
|
rcc "github.com/milvus-io/milvus/internal/distributed/rootcoord/client"
|
2022-12-16 14:39:24 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/proxypb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/rootcoordpb"
|
2023-06-25 17:20:43 +08:00
|
|
|
"github.com/milvus-io/milvus/internal/util/componentutil"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/dependency"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/importutil"
|
|
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/common"
|
|
|
|
"github.com/milvus-io/milvus/pkg/log"
|
|
|
|
"github.com/milvus-io/milvus/pkg/metrics"
|
2023-06-25 17:20:43 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/tracer"
|
2023-04-06 19:14:32 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/crypto"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/etcd"
|
|
|
|
"github.com/milvus-io/milvus/pkg/util/funcutil"
|
2023-09-15 10:09:21 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/merr"
|
2023-07-18 14:23:20 +08:00
|
|
|
"github.com/milvus-io/milvus/pkg/util/metric"
|
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/typeutil"
|
2021-09-09 10:06:29 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
attempts = 1000000
|
|
|
|
sleepDuration = time.Millisecond * 200
|
|
|
|
)
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
var Registry *prometheus.Registry
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
Registry = prometheus.NewRegistry()
|
|
|
|
Registry.MustRegister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
|
|
|
|
Registry.MustRegister(prometheus.NewGoCollector())
|
|
|
|
}
|
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
func runRootCoord(ctx context.Context, localMsg bool) *grpcrootcoord.Server {
|
|
|
|
var rc *grpcrootcoord.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2022-04-07 22:05:32 +08:00
|
|
|
factory := dependency.NewDefaultFactory(localMsg)
|
2021-10-24 16:13:11 +08:00
|
|
|
var err error
|
|
|
|
rc, err = grpcrootcoord.NewServer(ctx, factory)
|
2021-09-09 10:06:29 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
wg.Done()
|
|
|
|
err = rc.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterRootCoord(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return rc
|
|
|
|
}
|
|
|
|
|
|
|
|
func runQueryCoord(ctx context.Context, localMsg bool) *grpcquerycoord.Server {
|
|
|
|
var qs *grpcquerycoord.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2022-04-07 22:05:32 +08:00
|
|
|
factory := dependency.NewDefaultFactory(localMsg)
|
2021-09-09 10:06:29 +08:00
|
|
|
var err error
|
|
|
|
qs, err = grpcquerycoord.NewServer(ctx, factory)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
wg.Done()
|
|
|
|
err = qs.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterQueryCoord(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return qs
|
|
|
|
}
|
|
|
|
|
|
|
|
func runQueryNode(ctx context.Context, localMsg bool, alias string) *grpcquerynode.Server {
|
|
|
|
var qn *grpcquerynode.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2023-06-25 14:38:44 +08:00
|
|
|
factory := dependency.MockDefaultFactory(localMsg, Params)
|
2021-09-09 10:06:29 +08:00
|
|
|
var err error
|
|
|
|
qn, err = grpcquerynode.NewServer(ctx, factory)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
wg.Done()
|
|
|
|
err = qn.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterQueryNode(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return qn
|
|
|
|
}
|
|
|
|
|
|
|
|
func runDataCoord(ctx context.Context, localMsg bool) *grpcdatacoordclient.Server {
|
|
|
|
var ds *grpcdatacoordclient.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2022-04-07 22:05:32 +08:00
|
|
|
factory := dependency.NewDefaultFactory(localMsg)
|
2021-12-29 14:35:21 +08:00
|
|
|
ds = grpcdatacoordclient.NewServer(ctx, factory)
|
2021-09-09 10:06:29 +08:00
|
|
|
wg.Done()
|
2021-12-29 14:35:21 +08:00
|
|
|
err := ds.Run()
|
2021-09-09 10:06:29 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterDataCoord(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return ds
|
|
|
|
}
|
|
|
|
|
|
|
|
func runDataNode(ctx context.Context, localMsg bool, alias string) *grpcdatanode.Server {
|
|
|
|
var dn *grpcdatanode.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2023-06-25 14:38:44 +08:00
|
|
|
factory := dependency.MockDefaultFactory(localMsg, Params)
|
2021-09-09 10:06:29 +08:00
|
|
|
var err error
|
|
|
|
dn, err = grpcdatanode.NewServer(ctx, factory)
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
wg.Done()
|
|
|
|
err = dn.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterDataNode(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return dn
|
|
|
|
}
|
|
|
|
|
|
|
|
func runIndexNode(ctx context.Context, localMsg bool, alias string) *grpcindexnode.Server {
|
|
|
|
var in *grpcindexnode.Server
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
go func() {
|
2023-06-25 14:38:44 +08:00
|
|
|
factory := dependency.MockDefaultFactory(localMsg, Params)
|
2021-09-09 10:06:29 +08:00
|
|
|
var err error
|
2022-04-07 22:05:32 +08:00
|
|
|
in, err = grpcindexnode.NewServer(ctx, factory)
|
2021-09-09 10:06:29 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
wg.Done()
|
2022-11-30 18:23:15 +08:00
|
|
|
etcd, err := etcd.GetEtcdClient(
|
|
|
|
Params.EtcdCfg.UseEmbedEtcd.GetAsBool(),
|
|
|
|
Params.EtcdCfg.EtcdUseSSL.GetAsBool(),
|
|
|
|
Params.EtcdCfg.Endpoints.GetAsStrings(),
|
|
|
|
Params.EtcdCfg.EtcdTLSCert.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSKey.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSCACert.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSMinVersion.GetValue())
|
2021-12-29 14:35:21 +08:00
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
in.SetEtcdClient(etcd)
|
2021-09-09 10:06:29 +08:00
|
|
|
err = in.Run()
|
|
|
|
if err != nil {
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
wg.Wait()
|
|
|
|
|
2022-03-18 15:51:22 +08:00
|
|
|
metrics.RegisterIndexNode(Registry)
|
2021-09-09 10:06:29 +08:00
|
|
|
return in
|
|
|
|
}
|
|
|
|
|
2022-01-17 14:41:35 +08:00
|
|
|
type proxyTestServer struct {
|
|
|
|
*Proxy
|
|
|
|
grpcServer *grpc.Server
|
|
|
|
ch chan error
|
|
|
|
}
|
|
|
|
|
|
|
|
func newProxyTestServer(node *Proxy) *proxyTestServer {
|
|
|
|
return &proxyTestServer{
|
|
|
|
Proxy: node,
|
|
|
|
grpcServer: nil,
|
|
|
|
ch: make(chan error, 1),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-14 09:59:24 +08:00
|
|
|
func (s *proxyTestServer) GetVersion(ctx context.Context, request *milvuspb.GetVersionRequest) (*milvuspb.GetVersionResponse, error) {
|
|
|
|
return &milvuspb.GetVersionResponse{
|
|
|
|
Version: "vx.x.x",
|
|
|
|
}, nil
|
|
|
|
}
|
|
|
|
|
2023-01-19 14:13:43 +08:00
|
|
|
func (s *proxyTestServer) RenameCollection(ctx context.Context, request *milvuspb.RenameCollectionRequest) (*commonpb.Status, error) {
|
|
|
|
return s.Proxy.RenameCollection(ctx, request)
|
|
|
|
}
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
func (s *proxyTestServer) GetComponentStates(ctx context.Context, request *milvuspb.GetComponentStatesRequest) (*milvuspb.ComponentStates, error) {
|
2023-09-26 09:57:25 +08:00
|
|
|
return s.Proxy.GetComponentStates(ctx, request)
|
2022-01-17 14:41:35 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func (s *proxyTestServer) GetStatisticsChannel(ctx context.Context, request *internalpb.GetStatisticsChannelRequest) (*milvuspb.StringResponse, error) {
|
2023-09-26 09:57:25 +08:00
|
|
|
return s.Proxy.GetStatisticsChannel(ctx, request)
|
2022-01-17 14:41:35 +08:00
|
|
|
}
|
|
|
|
|
2022-12-07 10:07:18 +08:00
|
|
|
func (s *proxyTestServer) startGrpc(ctx context.Context, wg *sync.WaitGroup, p *paramtable.GrpcServerConfig) {
|
2022-01-17 14:41:35 +08:00
|
|
|
defer wg.Done()
|
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
kaep := keepalive.EnforcementPolicy{
|
2022-01-17 14:41:35 +08:00
|
|
|
MinTime: 5 * time.Second, // If a client pings more than once every 5 seconds, terminate the connection
|
|
|
|
PermitWithoutStream: true, // Allow pings even when there are no active streams
|
|
|
|
}
|
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
kasp := keepalive.ServerParameters{
|
2022-01-17 14:41:35 +08:00
|
|
|
Time: 60 * time.Second, // Ping the client if it is idle for 60 seconds to ensure the connection is still active
|
|
|
|
Timeout: 10 * time.Second, // Wait 10 second for the ping ack before assuming the connection is dead
|
|
|
|
}
|
|
|
|
|
2022-12-16 15:59:23 +08:00
|
|
|
log.Debug("Proxy server listen on tcp", zap.Int("port", p.Port.GetAsInt()))
|
|
|
|
lis, err := net.Listen("tcp", ":"+p.Port.GetValue())
|
2022-01-17 14:41:35 +08:00
|
|
|
if err != nil {
|
2022-12-16 15:59:23 +08:00
|
|
|
log.Warn("Proxy server failed to listen on", zap.Error(err), zap.Int("port", p.Port.GetAsInt()))
|
2022-01-17 14:41:35 +08:00
|
|
|
s.ch <- err
|
|
|
|
return
|
|
|
|
}
|
2022-12-16 15:59:23 +08:00
|
|
|
log.Debug("Proxy server already listen on tcp", zap.Int("port", p.Port.GetAsInt()))
|
2022-01-17 14:41:35 +08:00
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(ctx)
|
|
|
|
defer cancel()
|
|
|
|
|
2022-09-16 09:56:47 +08:00
|
|
|
multiLimiter := NewMultiRateLimiter()
|
|
|
|
s.multiRateLimiter = multiLimiter
|
|
|
|
|
2023-01-12 16:09:39 +08:00
|
|
|
opts := tracer.GetInterceptorOpts()
|
2022-01-17 14:41:35 +08:00
|
|
|
s.grpcServer = grpc.NewServer(
|
|
|
|
grpc.KeepaliveEnforcementPolicy(kaep),
|
|
|
|
grpc.KeepaliveParams(kasp),
|
2022-12-16 15:59:23 +08:00
|
|
|
grpc.MaxRecvMsgSize(p.ServerMaxRecvSize.GetAsInt()),
|
|
|
|
grpc.MaxSendMsgSize(p.ServerMaxSendSize.GetAsInt()),
|
2022-09-16 09:56:47 +08:00
|
|
|
grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(
|
2023-01-12 16:09:39 +08:00
|
|
|
otelgrpc.UnaryServerInterceptor(opts...),
|
2022-09-16 09:56:47 +08:00
|
|
|
RateLimitInterceptor(multiLimiter),
|
|
|
|
)),
|
2023-01-12 16:09:39 +08:00
|
|
|
grpc.StreamInterceptor(otelgrpc.StreamServerInterceptor(opts...)))
|
2022-01-17 14:41:35 +08:00
|
|
|
proxypb.RegisterProxyServer(s.grpcServer, s)
|
|
|
|
milvuspb.RegisterMilvusServiceServer(s.grpcServer, s)
|
|
|
|
|
|
|
|
log.Debug("create Proxy grpc server",
|
|
|
|
zap.Any("enforcement policy", kaep),
|
|
|
|
zap.Any("server parameters", kasp))
|
|
|
|
|
|
|
|
log.Debug("waiting for Proxy grpc server to be ready")
|
|
|
|
go funcutil.CheckGrpcReady(ctx, s.ch)
|
|
|
|
|
|
|
|
log.Debug("Proxy grpc server has been ready, serve grpc requests on listen")
|
|
|
|
if err := s.grpcServer.Serve(lis); err != nil {
|
|
|
|
log.Warn("failed to serve on Proxy's listener", zap.Error(err))
|
|
|
|
s.ch <- err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *proxyTestServer) waitForGrpcReady() error {
|
|
|
|
return <-s.ch
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *proxyTestServer) gracefulStop() {
|
|
|
|
if s.grpcServer != nil {
|
|
|
|
s.grpcServer.GracefulStop()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
func TestProxy(t *testing.T) {
|
|
|
|
var err error
|
2022-01-17 14:41:35 +08:00
|
|
|
var wg sync.WaitGroup
|
2022-11-04 14:25:38 +08:00
|
|
|
paramtable.Init()
|
2021-09-09 10:06:29 +08:00
|
|
|
|
2021-10-21 15:30:36 +08:00
|
|
|
path := "/tmp/milvus/rocksmq" + funcutil.GenRandomStr()
|
2022-10-11 18:43:23 +08:00
|
|
|
t.Setenv("ROCKSMQ_PATH", path)
|
2021-09-29 11:07:59 +08:00
|
|
|
defer os.RemoveAll(path)
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
ctx, cancel := context.WithCancel(context.Background())
|
2022-08-04 11:04:34 +08:00
|
|
|
ctx = GetContext(ctx, "root:123456")
|
2021-09-09 10:06:29 +08:00
|
|
|
localMsg := true
|
2023-06-25 14:38:44 +08:00
|
|
|
factory := dependency.MockDefaultFactory(localMsg, Params)
|
2021-09-09 10:06:29 +08:00
|
|
|
alias := "TestProxy"
|
|
|
|
|
2022-06-20 15:22:13 +08:00
|
|
|
log.Info("Initialize parameter table of Proxy")
|
|
|
|
|
2021-09-09 10:06:29 +08:00
|
|
|
rc := runRootCoord(ctx, localMsg)
|
2021-12-30 16:47:01 +08:00
|
|
|
log.Info("running RootCoord ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if rc != nil {
|
|
|
|
defer func() {
|
|
|
|
err := rc.Stop()
|
|
|
|
assert.NoError(t, err)
|
2021-12-30 16:44:09 +08:00
|
|
|
log.Info("stop RootCoord")
|
2021-09-09 10:06:29 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
dc := runDataCoord(ctx, localMsg)
|
2021-12-30 16:41:22 +08:00
|
|
|
log.Info("running DataCoord ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if dc != nil {
|
|
|
|
defer func() {
|
|
|
|
err := dc.Stop()
|
|
|
|
assert.NoError(t, err)
|
2021-12-29 14:09:21 +08:00
|
|
|
log.Info("stop DataCoord")
|
2021-09-09 10:06:29 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
dn := runDataNode(ctx, localMsg, alias)
|
2021-12-31 11:31:22 +08:00
|
|
|
log.Info("running DataNode ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if dn != nil {
|
|
|
|
defer func() {
|
|
|
|
err := dn.Stop()
|
|
|
|
assert.NoError(t, err)
|
2021-12-27 15:06:43 +08:00
|
|
|
log.Info("stop DataNode")
|
2021-09-09 10:06:29 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
qc := runQueryCoord(ctx, localMsg)
|
2021-12-31 11:33:41 +08:00
|
|
|
log.Info("running QueryCoord ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if qc != nil {
|
|
|
|
defer func() {
|
|
|
|
err := qc.Stop()
|
|
|
|
assert.NoError(t, err)
|
2021-12-27 15:10:49 +08:00
|
|
|
log.Info("stop QueryCoord")
|
2021-09-09 10:06:29 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
qn := runQueryNode(ctx, localMsg, alias)
|
2022-11-17 18:59:09 +08:00
|
|
|
log.Info("running QueryNode ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if qn != nil {
|
|
|
|
defer func() {
|
|
|
|
err := qn.Stop()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
log.Info("stop query node")
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
|
|
|
in := runIndexNode(ctx, localMsg, alias)
|
2021-12-31 11:39:31 +08:00
|
|
|
log.Info("running IndexNode ...")
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
if in != nil {
|
|
|
|
defer func() {
|
|
|
|
err := in.Stop()
|
|
|
|
assert.NoError(t, err)
|
2021-12-27 15:21:13 +08:00
|
|
|
log.Info("stop IndexNode")
|
2021-09-09 10:06:29 +08:00
|
|
|
}()
|
|
|
|
}
|
|
|
|
|
2021-09-26 12:48:32 +08:00
|
|
|
time.Sleep(10 * time.Millisecond)
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
proxy, err := NewProxy(ctx, factory)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, proxy)
|
2022-01-17 14:41:35 +08:00
|
|
|
|
2022-11-30 18:23:15 +08:00
|
|
|
etcdcli, err := etcd.GetEtcdClient(
|
|
|
|
Params.EtcdCfg.UseEmbedEtcd.GetAsBool(),
|
|
|
|
Params.EtcdCfg.EtcdUseSSL.GetAsBool(),
|
|
|
|
Params.EtcdCfg.Endpoints.GetAsStrings(),
|
|
|
|
Params.EtcdCfg.EtcdTLSCert.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSKey.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSCACert.GetValue(),
|
|
|
|
Params.EtcdCfg.EtcdTLSMinVersion.GetValue())
|
2021-12-29 14:35:21 +08:00
|
|
|
defer etcdcli.Close()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
proxy.SetEtcdClient(etcdcli)
|
2022-01-17 14:41:35 +08:00
|
|
|
|
|
|
|
testServer := newProxyTestServer(proxy)
|
|
|
|
wg.Add(1)
|
2022-12-07 10:07:18 +08:00
|
|
|
|
2023-09-05 10:31:48 +08:00
|
|
|
bt := paramtable.NewBaseTable(paramtable.SkipRemote(true))
|
2023-01-19 14:53:44 +08:00
|
|
|
base := ¶mtable.ComponentParam{}
|
2023-09-05 10:31:48 +08:00
|
|
|
base.Init(bt)
|
2022-12-07 10:07:18 +08:00
|
|
|
var p paramtable.GrpcServerConfig
|
2023-09-05 10:31:48 +08:00
|
|
|
p.Init(typeutil.ProxyRole, bt)
|
2022-12-07 10:07:18 +08:00
|
|
|
testServer.Proxy.SetAddress(p.GetAddress())
|
2023-01-12 19:49:40 +08:00
|
|
|
assert.Equal(t, p.GetAddress(), testServer.Proxy.GetAddress())
|
2022-12-07 10:07:18 +08:00
|
|
|
|
|
|
|
go testServer.startGrpc(ctx, &wg, &p)
|
2022-01-17 14:41:35 +08:00
|
|
|
assert.NoError(t, testServer.waitForGrpcReady())
|
|
|
|
|
2023-10-27 07:36:12 +08:00
|
|
|
rootCoordClient, err := rcc.NewClient(ctx)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-12 19:49:40 +08:00
|
|
|
err = componentutil.WaitForComponentHealthy(ctx, rootCoordClient, typeutil.RootCoordRole, attempts, sleepDuration)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
proxy.SetRootCoordClient(rootCoordClient)
|
|
|
|
log.Info("Proxy set root coordinator client")
|
|
|
|
|
2023-10-27 07:36:12 +08:00
|
|
|
dataCoordClient, err := grpcdatacoordclient2.NewClient(ctx)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-12 19:49:40 +08:00
|
|
|
err = componentutil.WaitForComponentHealthy(ctx, dataCoordClient, typeutil.DataCoordRole, attempts, sleepDuration)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
proxy.SetDataCoordClient(dataCoordClient)
|
|
|
|
log.Info("Proxy set data coordinator client")
|
|
|
|
|
2023-10-27 07:36:12 +08:00
|
|
|
queryCoordClient, err := grpcquerycoordclient.NewClient(ctx)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
2023-01-12 19:49:40 +08:00
|
|
|
err = componentutil.WaitForComponentHealthy(ctx, queryCoordClient, typeutil.QueryCoordRole, attempts, sleepDuration)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
proxy.SetQueryCoordClient(queryCoordClient)
|
2023-01-12 19:49:40 +08:00
|
|
|
proxy.SetQueryNodeCreator(defaultQueryNodeClientCreator)
|
2021-09-09 10:06:29 +08:00
|
|
|
log.Info("Proxy set query coordinator client")
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Initializing)
|
2021-09-09 10:06:29 +08:00
|
|
|
err = proxy.Init()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
err = proxy.Start()
|
|
|
|
assert.NoError(t, err)
|
2023-10-09 10:09:33 +08:00
|
|
|
assert.Equal(t, commonpb.StateCode_Healthy, proxy.GetStateCode())
|
2021-12-15 11:47:10 +08:00
|
|
|
|
|
|
|
// register proxy
|
|
|
|
err = proxy.Register()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
log.Info("Register proxy done")
|
2021-09-09 10:06:29 +08:00
|
|
|
defer func() {
|
|
|
|
err := proxy.Stop()
|
|
|
|
assert.NoError(t, err)
|
|
|
|
}()
|
|
|
|
|
|
|
|
t.Run("get component states", func(t *testing.T) {
|
2023-09-26 09:57:25 +08:00
|
|
|
states, err := proxy.GetComponentStates(ctx, nil)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, states.GetStatus().GetErrorCode())
|
2022-11-04 14:25:38 +08:00
|
|
|
assert.Equal(t, paramtable.GetNodeID(), states.State.NodeID)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.Equal(t, typeutil.ProxyRole, states.State.Role)
|
2023-10-09 10:09:33 +08:00
|
|
|
assert.Equal(t, proxy.GetStateCode(), states.State.StateCode)
|
2021-09-09 10:06:29 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("get statistics channel", func(t *testing.T) {
|
2023-09-26 09:57:25 +08:00
|
|
|
resp, err := proxy.GetStatisticsChannel(ctx, nil)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.Equal(t, "", resp.Value)
|
|
|
|
})
|
|
|
|
|
|
|
|
prefix := "test_proxy_"
|
2021-10-24 16:13:11 +08:00
|
|
|
partitionPrefix := "test_proxy_partition_"
|
2023-06-25 17:20:43 +08:00
|
|
|
dbName := GetCurDBNameFromContextOrDefault(ctx)
|
2021-09-09 10:06:29 +08:00
|
|
|
collectionName := prefix + funcutil.GenRandomStr()
|
2021-10-24 16:13:11 +08:00
|
|
|
otherCollectionName := collectionName + "_other_" + funcutil.GenRandomStr()
|
|
|
|
partitionName := partitionPrefix + funcutil.GenRandomStr()
|
|
|
|
otherPartitionName := partitionPrefix + "_other_" + funcutil.GenRandomStr()
|
2023-04-21 07:08:32 +08:00
|
|
|
shardsNum := common.DefaultShardsNum
|
2021-09-09 10:06:29 +08:00
|
|
|
int64Field := "int64"
|
|
|
|
floatVecField := "fVec"
|
|
|
|
dim := 128
|
2021-09-11 11:36:22 +08:00
|
|
|
rowNum := 3000
|
|
|
|
indexName := "_default"
|
|
|
|
nlist := 10
|
2022-04-20 16:15:41 +08:00
|
|
|
// nprobe := 10
|
|
|
|
// topk := 10
|
2021-10-08 17:39:55 +08:00
|
|
|
// add a test parameter
|
2022-04-20 16:15:41 +08:00
|
|
|
// roundDecimal := 6
|
2021-09-11 11:36:22 +08:00
|
|
|
nq := 10
|
2022-04-20 16:15:41 +08:00
|
|
|
// expr := fmt.Sprintf("%s > 0", int64Field)
|
2021-09-11 11:36:22 +08:00
|
|
|
var segmentIDs []int64
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
// an int64 field (pk) & a float vector field
|
|
|
|
constructCollectionSchema := func() *schemapb.CollectionSchema {
|
|
|
|
pk := &schemapb.FieldSchema{
|
|
|
|
FieldID: 0,
|
|
|
|
Name: int64Field,
|
|
|
|
IsPrimaryKey: true,
|
|
|
|
Description: "",
|
|
|
|
DataType: schemapb.DataType_Int64,
|
|
|
|
TypeParams: nil,
|
|
|
|
IndexParams: nil,
|
|
|
|
AutoID: true,
|
|
|
|
}
|
|
|
|
fVec := &schemapb.FieldSchema{
|
|
|
|
FieldID: 0,
|
|
|
|
Name: floatVecField,
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
Description: "",
|
|
|
|
DataType: schemapb.DataType_FloatVector,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
2023-05-16 17:41:22 +08:00
|
|
|
Key: common.DimKey,
|
2021-09-09 10:06:29 +08:00
|
|
|
Value: strconv.Itoa(dim),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
IndexParams: nil,
|
|
|
|
AutoID: false,
|
|
|
|
}
|
|
|
|
return &schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
Description: "",
|
|
|
|
AutoID: false,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
pk,
|
|
|
|
fVec,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 19:02:08 +08:00
|
|
|
schema := constructCollectionSchema()
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
constructCreateCollectionRequest := func() *milvuspb.CreateCollectionRequest {
|
|
|
|
bs, err := proto.Marshal(schema)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
return &milvuspb.CreateCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
Schema: bs,
|
|
|
|
ShardsNum: shardsNum,
|
|
|
|
}
|
|
|
|
}
|
2021-09-09 19:02:08 +08:00
|
|
|
createCollectionReq := constructCreateCollectionRequest()
|
2021-09-09 10:06:29 +08:00
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
constructCollectionInsertRequest := func() *milvuspb.InsertRequest {
|
2021-09-11 11:36:22 +08:00
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.InsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: "",
|
|
|
|
FieldsData: []*schemapb.FieldData{fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
constructPartitionInsertRequest := func() *milvuspb.InsertRequest {
|
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.InsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
FieldsData: []*schemapb.FieldData{fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
constructCollectionUpsertRequest := func() *milvuspb.UpsertRequest {
|
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.UpsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
FieldsData: []*schemapb.FieldData{fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
constructCreateIndexRequest := func() *milvuspb.CreateIndexRequest {
|
|
|
|
return &milvuspb.CreateIndexRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
FieldName: floatVecField,
|
2022-08-25 15:48:54 +08:00
|
|
|
IndexName: indexName,
|
2021-09-11 11:36:22 +08:00
|
|
|
ExtraParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
2023-05-16 17:41:22 +08:00
|
|
|
Key: common.DimKey,
|
2021-09-11 11:36:22 +08:00
|
|
|
Value: strconv.Itoa(dim),
|
|
|
|
},
|
|
|
|
{
|
2022-10-08 15:38:58 +08:00
|
|
|
Key: common.MetricTypeKey,
|
2023-07-18 14:23:20 +08:00
|
|
|
Value: metric.L2,
|
2021-09-11 11:36:22 +08:00
|
|
|
},
|
|
|
|
{
|
2023-05-16 17:41:22 +08:00
|
|
|
Key: common.IndexTypeKey,
|
2021-09-11 11:36:22 +08:00
|
|
|
Value: "IVF_FLAT",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: "nlist",
|
|
|
|
Value: strconv.Itoa(nlist),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 10:06:29 +08:00
|
|
|
t.Run("create collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
req := createCollectionReq
|
2021-09-09 10:06:29 +08:00
|
|
|
resp, err := proxy.CreateCollection(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2022-03-03 16:57:56 +08:00
|
|
|
reqInvalidField := constructCreateCollectionRequest()
|
|
|
|
schema := constructCollectionSchema()
|
|
|
|
schema.Fields = append(schema.Fields, &schemapb.FieldSchema{
|
|
|
|
Name: "StringField",
|
|
|
|
DataType: schemapb.DataType_String,
|
|
|
|
})
|
|
|
|
bs, err := proto.Marshal(schema)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
reqInvalidField.CollectionName = "invalid_field_coll"
|
|
|
|
reqInvalidField.Schema = bs
|
|
|
|
|
|
|
|
resp, err = proxy.CreateCollection(ctx, reqInvalidField)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-28 21:30:03 +08:00
|
|
|
t.Run("create alias", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-28 21:30:03 +08:00
|
|
|
// create alias
|
|
|
|
aliasReq := &milvuspb.CreateAliasRequest{
|
|
|
|
Base: nil,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
Alias: "alias",
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2021-09-28 21:30:03 +08:00
|
|
|
}
|
|
|
|
resp, err := proxy.CreateAlias(ctx, aliasReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
_, _ = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: 0,
|
|
|
|
MsgID: 0,
|
|
|
|
Timestamp: 0,
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-28 21:30:03 +08:00
|
|
|
t.Run("alter alias", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-28 21:30:03 +08:00
|
|
|
// alter alias
|
|
|
|
alterReq := &milvuspb.AlterAliasRequest{
|
|
|
|
Base: nil,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
Alias: "alias",
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2021-09-28 21:30:03 +08:00
|
|
|
}
|
|
|
|
resp, err := proxy.AlterAlias(ctx, alterReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
_, _ = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: 0,
|
|
|
|
MsgID: 0,
|
|
|
|
Timestamp: 0,
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
|
|
|
|
nonExistingCollName := "coll_name_random_zarathustra"
|
|
|
|
faultyAlterReq := &milvuspb.AlterAliasRequest{
|
|
|
|
Base: nil,
|
|
|
|
CollectionName: nonExistingCollName,
|
|
|
|
Alias: "alias",
|
|
|
|
}
|
|
|
|
resp, err = proxy.AlterAlias(ctx, faultyAlterReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-28 21:30:03 +08:00
|
|
|
t.Run("drop alias", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-28 21:30:03 +08:00
|
|
|
// drop alias
|
|
|
|
resp, err := proxy.DropAlias(ctx, &milvuspb.DropAliasRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
Base: nil,
|
|
|
|
Alias: "alias",
|
|
|
|
DbName: dbName,
|
2021-09-28 21:30:03 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
_, _ = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: &commonpb.MsgBase{
|
|
|
|
MsgType: 0,
|
|
|
|
MsgID: 0,
|
|
|
|
Timestamp: 0,
|
|
|
|
SourceID: 0,
|
|
|
|
},
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("has collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.HasCollection(ctx, &milvuspb.HasCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.True(t, resp.Value)
|
|
|
|
|
|
|
|
// has other collection: false
|
|
|
|
resp, err = proxy.HasCollection(ctx, &milvuspb.HasCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.False(t, resp.Value)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("describe collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.DescribeCollection(ctx, &milvuspb.DescribeCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
TimeStamp: 0,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.Equal(t, collectionID, resp.CollectionID)
|
|
|
|
// TODO(dragondriver): shards num
|
|
|
|
assert.Equal(t, len(schema.Fields), len(resp.Schema.Fields))
|
|
|
|
// TODO(dragondriver): compare fields schema, not sure the order of fields
|
|
|
|
|
|
|
|
// describe other collection -> fail
|
|
|
|
resp, err = proxy.DescribeCollection(ctx, &milvuspb.DescribeCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
TimeStamp: 0,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("get collection statistics", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.GetCollectionStatistics(ctx, &milvuspb.GetCollectionStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
// TODO(dragondriver): check num rows
|
|
|
|
|
|
|
|
// get statistics of other collection -> fail
|
|
|
|
resp, err = proxy.GetCollectionStatistics(ctx, &milvuspb.GetCollectionStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("show collections", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_All,
|
|
|
|
CollectionNames: nil,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-11-01 10:26:03 +08:00
|
|
|
assert.Equal(t, 1, len(resp.CollectionNames), resp.CollectionNames)
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2022-10-10 20:31:22 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("alter collection", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterCollection(ctx, &milvuspb.AlterCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
2023-06-25 17:20:43 +08:00
|
|
|
CollectionName: collectionName,
|
2022-10-10 20:31:22 +08:00
|
|
|
Properties: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: common.CollectionTTLConfigKey,
|
|
|
|
Value: "3600",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-06-25 17:20:43 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-10-10 20:31:22 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("create partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// create partition with non-exist collection -> fail
|
|
|
|
resp, err = proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("has partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.True(t, resp.Value)
|
|
|
|
|
|
|
|
resp, err = proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: otherPartitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.False(t, resp.Value)
|
|
|
|
|
|
|
|
// non-exist collection -> fail
|
|
|
|
resp, err = proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("get partition statistics", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.GetPartitionStatistics(ctx, &milvuspb.GetPartitionStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
|
|
|
|
// non-exist partition -> fail
|
|
|
|
resp, err = proxy.GetPartitionStatistics(ctx, &milvuspb.GetPartitionStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: otherPartitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
|
|
|
|
// non-exist collection -> fail
|
|
|
|
resp, err = proxy.GetPartitionStatistics(ctx, &milvuspb.GetPartitionStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("show partitions", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Type: milvuspb.ShowType_All,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
// default partition
|
|
|
|
assert.Equal(t, 2, len(resp.PartitionNames))
|
|
|
|
|
2022-12-16 14:39:24 +08:00
|
|
|
{
|
|
|
|
stateResp, err := proxy.GetLoadState(ctx, &milvuspb.GetLoadStateRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-12-16 14:39:24 +08:00
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: resp.PartitionNames,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateNotLoad, stateResp.State)
|
|
|
|
}
|
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
// non-exist collection -> fail
|
|
|
|
resp, err = proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
CollectionID: collectionID + 1,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Type: milvuspb.ShowType_All,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2023-10-16 15:34:08 +08:00
|
|
|
var insertedIds []int64
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("insert", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2022-07-18 09:58:28 +08:00
|
|
|
req := constructCollectionInsertRequest()
|
2021-09-11 11:36:22 +08:00
|
|
|
|
|
|
|
resp, err := proxy.Insert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.Equal(t, rowNum, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, 0, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(rowNum), resp.InsertCnt)
|
2023-10-16 15:34:08 +08:00
|
|
|
|
|
|
|
switch field := resp.GetIDs().GetIdField().(type) {
|
|
|
|
case *schemapb.IDs_IntId:
|
|
|
|
insertedIds = field.IntId.GetData()
|
|
|
|
default:
|
|
|
|
t.Fatalf("Unexpected ID type")
|
|
|
|
}
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
// TODO(dragondriver): proxy.Delete()
|
2021-09-11 11:36:22 +08:00
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
flushed := true
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("flush", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.Flush(ctx, &milvuspb.FlushRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionNames: []string{collectionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
segmentIDs = resp.CollSegIDs[collectionName].Data
|
2022-04-29 13:35:49 +08:00
|
|
|
log.Info("flush collection", zap.Int64s("segments to be flushed", segmentIDs))
|
2021-09-11 11:36:22 +08:00
|
|
|
|
|
|
|
f := func() bool {
|
2022-04-29 13:35:49 +08:00
|
|
|
resp, err := proxy.GetFlushState(ctx, &milvuspb.GetFlushStateRequest{
|
|
|
|
SegmentIDs: segmentIDs,
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
2022-04-29 13:35:49 +08:00
|
|
|
if err != nil {
|
|
|
|
return false
|
2021-09-11 11:36:22 +08:00
|
|
|
}
|
2022-04-29 13:35:49 +08:00
|
|
|
return resp.GetFlushed()
|
2021-09-11 11:36:22 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// waiting for flush operation to be done
|
2021-09-17 19:45:42 +08:00
|
|
|
counter := 0
|
|
|
|
for !f() {
|
2022-07-18 09:58:28 +08:00
|
|
|
if counter > 100 {
|
2021-09-17 19:45:42 +08:00
|
|
|
flushed = false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
// avoid too frequent rpc call
|
2021-09-26 12:48:32 +08:00
|
|
|
time.Sleep(100 * time.Millisecond)
|
2021-09-17 19:45:42 +08:00
|
|
|
counter++
|
2021-09-11 11:36:22 +08:00
|
|
|
}
|
|
|
|
})
|
2021-09-17 19:45:42 +08:00
|
|
|
if !flushed {
|
|
|
|
log.Warn("flush operation was not sure to be done")
|
|
|
|
}
|
2021-09-11 11:36:22 +08:00
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get statistics after flush", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
if !flushed {
|
|
|
|
t.Skip("flush operation was not done")
|
|
|
|
}
|
|
|
|
resp, err := proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
rowNumStr := funcutil.KeyValuePair2Map(resp.Stats)["row_count"]
|
|
|
|
assert.Equal(t, strconv.Itoa(rowNum), rowNumStr)
|
|
|
|
|
|
|
|
// get statistics of other collection -> fail
|
|
|
|
resp, err = proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("create index", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
req := constructCreateIndexRequest()
|
|
|
|
|
|
|
|
resp, err := proxy.CreateIndex(ctx, req)
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("describe index", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
resp, err := proxy.DescribeIndex(ctx, &milvuspb.DescribeIndexRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
2021-09-17 19:45:42 +08:00
|
|
|
FieldName: floatVecField,
|
|
|
|
IndexName: "",
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-17 19:45:42 +08:00
|
|
|
indexName = resp.IndexDescriptions[0].IndexName
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2023-05-06 10:34:39 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get index statistics", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetIndexStatistics(ctx, &milvuspb.GetIndexStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
IndexName: "",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-05-06 10:34:39 +08:00
|
|
|
indexName = resp.IndexDescriptions[0].IndexName
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("get index build progress", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
resp, err := proxy.GetIndexBuildProgress(ctx, &milvuspb.GetIndexBuildProgressRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
2021-09-17 19:45:42 +08:00
|
|
|
FieldName: floatVecField,
|
|
|
|
IndexName: indexName,
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("get index state", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
resp, err := proxy.GetIndexState(ctx, &milvuspb.GetIndexStateRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
2021-09-17 19:45:42 +08:00
|
|
|
FieldName: floatVecField,
|
|
|
|
IndexName: indexName,
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-17 19:45:42 +08:00
|
|
|
loaded := true
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("load collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2022-12-16 14:39:24 +08:00
|
|
|
{
|
|
|
|
stateResp, err := proxy.GetLoadState(ctx, &milvuspb.GetLoadStateRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-12-16 14:39:24 +08:00
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateNotLoad, stateResp.State)
|
|
|
|
}
|
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
// load other collection -> fail
|
|
|
|
resp, err = proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
2021-09-11 11:36:22 +08:00
|
|
|
CollectionName: otherCollectionName,
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
f := func() bool {
|
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
CollectionNames: []string{collectionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
|
|
|
|
for idx, name := range resp.CollectionNames {
|
|
|
|
if name == collectionName && resp.InMemoryPercentages[idx] == 100 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// waiting for collection to be loaded
|
2021-09-17 19:45:42 +08:00
|
|
|
counter := 0
|
2021-09-15 17:34:02 +08:00
|
|
|
for !f() {
|
2021-10-21 15:30:36 +08:00
|
|
|
if counter > 100 {
|
2021-09-17 19:45:42 +08:00
|
|
|
loaded = false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
// avoid too frequent rpc call
|
2021-09-26 12:48:32 +08:00
|
|
|
time.Sleep(100 * time.Millisecond)
|
2021-09-17 19:45:42 +08:00
|
|
|
counter++
|
2021-09-11 11:36:22 +08:00
|
|
|
}
|
2023-06-25 17:20:43 +08:00
|
|
|
assert.True(t, loaded)
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("show in-memory collections", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
CollectionNames: nil,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.Equal(t, 1, len(resp.CollectionNames))
|
|
|
|
|
|
|
|
// get in-memory percentage
|
|
|
|
resp, err = proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
CollectionNames: []string{collectionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
assert.Equal(t, 1, len(resp.CollectionNames))
|
|
|
|
assert.Equal(t, 1, len(resp.InMemoryPercentages))
|
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
// get in-memory percentage of not loaded collection -> fail
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err = proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
CollectionNames: []string{otherCollectionName},
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(ctx, &milvuspb.GetLoadingProgressRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-10-01 09:02:55 +08:00
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, progressResp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
assert.NotEqual(t, int64(0), progressResp.Progress)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(ctx, &milvuspb.GetLoadingProgressRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-10-01 09:02:55 +08:00
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, progressResp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
assert.Equal(t, int64(0), progressResp.Progress)
|
|
|
|
}
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
stateResp, err := proxy.GetLoadState(ctx, &milvuspb.GetLoadStateRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-12-16 14:39:24 +08:00
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateNotExist, stateResp.State)
|
|
|
|
}
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2022-04-22 14:47:42 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get replicas", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2022-04-22 14:47:42 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.GetReplicas(ctx, &milvuspb.GetReplicasRequest{
|
|
|
|
CollectionID: collectionID,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, 1, len(resp.Replicas))
|
|
|
|
})
|
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get collection statistics from shard", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
if !loaded {
|
|
|
|
t.Skip("collection not loaded")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
resp, err := proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
rowNumStr := funcutil.KeyValuePair2Map(resp.Stats)["row_count"]
|
|
|
|
assert.Equal(t, strconv.Itoa(rowNum), rowNumStr)
|
|
|
|
|
|
|
|
// get statistics of other collection -> fail
|
|
|
|
resp, err = proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
})
|
|
|
|
|
2023-10-16 15:34:08 +08:00
|
|
|
nprobe := 10
|
|
|
|
topk := 10
|
|
|
|
roundDecimal := 6
|
|
|
|
expr := fmt.Sprintf("%s > 0", int64Field)
|
|
|
|
constructVectorsPlaceholderGroup := func() *commonpb.PlaceholderGroup {
|
|
|
|
values := make([][]byte, 0, nq)
|
|
|
|
for i := 0; i < nq; i++ {
|
|
|
|
bs := make([]byte, 0, dim*4)
|
|
|
|
for j := 0; j < dim; j++ {
|
|
|
|
var buffer bytes.Buffer
|
|
|
|
f := rand.Float32()
|
|
|
|
err := binary.Write(&buffer, common.Endian, f)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
bs = append(bs, buffer.Bytes()...)
|
|
|
|
}
|
|
|
|
values = append(values, bs)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &commonpb.PlaceholderGroup{
|
|
|
|
Placeholders: []*commonpb.PlaceholderValue{
|
|
|
|
{
|
|
|
|
Tag: "$0",
|
|
|
|
Type: commonpb.PlaceholderType_FloatVector,
|
|
|
|
Values: values,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
constructSearchRequest := func() *milvuspb.SearchRequest {
|
|
|
|
plg := constructVectorsPlaceholderGroup()
|
|
|
|
plgBs, err := proto.Marshal(plg)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
params := make(map[string]string)
|
|
|
|
params["nprobe"] = strconv.Itoa(nprobe)
|
|
|
|
b, err := json.Marshal(params)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
searchParams := []*commonpb.KeyValuePair{
|
|
|
|
{Key: MetricTypeKey, Value: metric.L2},
|
|
|
|
{Key: SearchParamsKey, Value: string(b)},
|
|
|
|
{Key: AnnsFieldKey, Value: floatVecField},
|
|
|
|
{Key: TopKKey, Value: strconv.Itoa(topk)},
|
|
|
|
{Key: RoundDecimalKey, Value: strconv.Itoa(roundDecimal)},
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.SearchRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Dsl: expr,
|
|
|
|
PlaceholderGroup: plgBs,
|
|
|
|
DslType: commonpb.DslType_BoolExprV1,
|
|
|
|
OutputFields: nil,
|
|
|
|
SearchParams: searchParams,
|
|
|
|
TravelTimestamp: 0,
|
|
|
|
GuaranteeTimestamp: 0,
|
|
|
|
SearchByPrimaryKeys: false,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("search", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructSearchRequest()
|
|
|
|
|
|
|
|
resp, err := proxy.Search(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
constructPrimaryKeysPlaceholderGroup := func() *commonpb.PlaceholderGroup {
|
|
|
|
expr := fmt.Sprintf("%v in [%v]", int64Field, insertedIds[0])
|
|
|
|
exprBytes := []byte(expr)
|
|
|
|
|
|
|
|
return &commonpb.PlaceholderGroup{
|
|
|
|
Placeholders: []*commonpb.PlaceholderValue{
|
|
|
|
{
|
|
|
|
Tag: "$0",
|
|
|
|
Type: commonpb.PlaceholderType_None,
|
|
|
|
Values: [][]byte{exprBytes},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
constructSearchByPksRequest := func() *milvuspb.SearchRequest {
|
|
|
|
plg := constructPrimaryKeysPlaceholderGroup()
|
|
|
|
plgBs, err := proto.Marshal(plg)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
params := make(map[string]string)
|
|
|
|
params["nprobe"] = strconv.Itoa(nprobe)
|
|
|
|
b, err := json.Marshal(params)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
searchParams := []*commonpb.KeyValuePair{
|
|
|
|
{Key: MetricTypeKey, Value: metric.L2},
|
|
|
|
{Key: SearchParamsKey, Value: string(b)},
|
|
|
|
{Key: AnnsFieldKey, Value: floatVecField},
|
|
|
|
{Key: TopKKey, Value: strconv.Itoa(topk)},
|
|
|
|
{Key: RoundDecimalKey, Value: strconv.Itoa(roundDecimal)},
|
|
|
|
}
|
|
|
|
|
|
|
|
return &milvuspb.SearchRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Dsl: "",
|
|
|
|
PlaceholderGroup: plgBs,
|
|
|
|
DslType: commonpb.DslType_BoolExprV1,
|
|
|
|
OutputFields: nil,
|
|
|
|
SearchParams: searchParams,
|
|
|
|
TravelTimestamp: 0,
|
|
|
|
GuaranteeTimestamp: 0,
|
|
|
|
SearchByPrimaryKeys: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("search by primary keys", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructSearchByPksRequest()
|
|
|
|
resp, err := proxy.Search(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-04-20 16:15:41 +08:00
|
|
|
// nprobe := 10
|
|
|
|
// topk := 10
|
|
|
|
// roundDecimal := 6
|
|
|
|
// expr := fmt.Sprintf("%s > 0", int64Field)
|
|
|
|
// constructPlaceholderGroup := func() *milvuspb.PlaceholderGroup {
|
|
|
|
// values := make([][]byte, 0, nq)
|
|
|
|
// for i := 0; i < nq; i++ {
|
|
|
|
// bs := make([]byte, 0, dim*4)
|
|
|
|
// for j := 0; j < dim; j++ {
|
|
|
|
// var buffer bytes.Buffer
|
|
|
|
// f := rand.Float32()
|
|
|
|
// err := binary.Write(&buffer, common.Endian, f)
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// bs = append(bs, buffer.Bytes()...)
|
|
|
|
// }
|
|
|
|
// values = append(values, bs)
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// return &milvuspb.PlaceholderGroup{
|
|
|
|
// Placeholders: []*milvuspb.PlaceholderValue{
|
|
|
|
// {
|
|
|
|
// Tag: "$0",
|
|
|
|
// Type: milvuspb.PlaceholderType_FloatVector,
|
|
|
|
// Values: values,
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
//
|
|
|
|
// constructSearchRequest := func() *milvuspb.SearchRequest {
|
|
|
|
// params := make(map[string]string)
|
|
|
|
// params["nprobe"] = strconv.Itoa(nprobe)
|
|
|
|
// b, err := json.Marshal(params)
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// plg := constructPlaceholderGroup()
|
|
|
|
// plgBs, err := proto.Marshal(plg)
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
//
|
|
|
|
// return &milvuspb.SearchRequest{
|
|
|
|
// Base: nil,
|
|
|
|
// DbName: dbName,
|
|
|
|
// CollectionName: collectionName,
|
|
|
|
// PartitionNames: nil,
|
|
|
|
// Dsl: expr,
|
|
|
|
// PlaceholderGroup: plgBs,
|
|
|
|
// DslType: commonpb.DslType_BoolExprV1,
|
|
|
|
// OutputFields: nil,
|
|
|
|
// SearchParams: []*commonpb.KeyValuePair{
|
|
|
|
// {
|
|
|
|
// Key: MetricTypeKey,
|
|
|
|
// Value: distance.L2,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// Key: SearchParamsKey,
|
|
|
|
// Value: string(b),
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// Key: AnnsFieldKey,
|
|
|
|
// Value: floatVecField,
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// Key: TopKKey,
|
|
|
|
// Value: strconv.Itoa(topk),
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// Key: RoundDecimalKey,
|
|
|
|
// Value: strconv.Itoa(roundDecimal),
|
|
|
|
// },
|
|
|
|
// },
|
|
|
|
// TravelTimestamp: 0,
|
|
|
|
// GuaranteeTimestamp: 0,
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
// TODO(Goose): reopen after joint-tests
|
|
|
|
// if loaded {
|
|
|
|
// wg.Add(1)
|
|
|
|
// t.Run("search", func(t *testing.T) {
|
|
|
|
// defer wg.Done()
|
|
|
|
// req := constructSearchRequest()
|
|
|
|
//
|
|
|
|
// resp, err := proxy.Search(ctx, req)
|
|
|
|
// assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
// assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-04-20 16:15:41 +08:00
|
|
|
// })
|
|
|
|
//
|
|
|
|
// wg.Add(1)
|
|
|
|
// t.Run("query", func(t *testing.T) {
|
|
|
|
// defer wg.Done()
|
|
|
|
// //resp, err := proxy.Query(ctx, &milvuspb.QueryRequest{
|
|
|
|
// _, err := proxy.Query(ctx, &milvuspb.QueryRequest{
|
|
|
|
// Base: nil,
|
|
|
|
// DbName: dbName,
|
|
|
|
// CollectionName: collectionName,
|
|
|
|
// Expr: expr,
|
|
|
|
// OutputFields: nil,
|
|
|
|
// PartitionNames: nil,
|
|
|
|
// TravelTimestamp: 0,
|
|
|
|
// GuaranteeTimestamp: 0,
|
|
|
|
// })
|
|
|
|
// assert.NoError(t, err)
|
|
|
|
// // FIXME(dragondriver)
|
2023-09-15 10:09:21 +08:00
|
|
|
// // assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-04-20 16:15:41 +08:00
|
|
|
// // TODO(dragondriver): compare query result
|
|
|
|
// })
|
2021-09-11 11:36:22 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("calculate distance", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
opLeft := &milvuspb.VectorsArray{
|
|
|
|
Array: &milvuspb.VectorsArray_DataArray{
|
|
|
|
DataArray: &schemapb.VectorField{
|
|
|
|
Dim: int64(dim),
|
|
|
|
Data: &schemapb.VectorField_FloatVector{
|
|
|
|
FloatVector: &schemapb.FloatArray{
|
|
|
|
Data: generateFloatVectors(nq, dim),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
opRight := &milvuspb.VectorsArray{
|
|
|
|
Array: &milvuspb.VectorsArray_DataArray{
|
|
|
|
DataArray: &schemapb.VectorField{
|
|
|
|
Dim: int64(dim),
|
|
|
|
Data: &schemapb.VectorField_FloatVector{
|
|
|
|
FloatVector: &schemapb.FloatArray{
|
|
|
|
Data: generateFloatVectors(nq, dim),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2023-09-21 09:45:27 +08:00
|
|
|
// resp, err := proxy.CalcDistance(ctx, &milvuspb.CalcDistanceRequest{
|
2021-09-11 11:36:22 +08:00
|
|
|
_, err := proxy.CalcDistance(ctx, &milvuspb.CalcDistanceRequest{
|
|
|
|
Base: nil,
|
|
|
|
OpLeft: opLeft,
|
|
|
|
OpRight: opRight,
|
|
|
|
Params: []*commonpb.KeyValuePair{
|
|
|
|
{
|
2022-10-08 15:38:58 +08:00
|
|
|
Key: common.MetricTypeKey,
|
2023-07-18 14:23:20 +08:00
|
|
|
Value: metric.L2,
|
2021-09-11 11:36:22 +08:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
// assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
// TODO(dragondriver): compare distance
|
|
|
|
|
|
|
|
// TODO(dragondriver): use primary key to calculate distance
|
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("get dd channel", func(t *testing.T) {
|
2023-05-31 20:24:31 +08:00
|
|
|
resp, _ := proxy.GetDdChannel(ctx, &internalpb.GetDdChannelRequest{})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("get persistent segment info", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.GetPersistentSegmentInfo(ctx, &milvuspb.GetPersistentSegmentInfoRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
2021-09-09 19:02:08 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("get query segment info", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.GetQuerySegmentInfo(ctx, &milvuspb.GetQuerySegmentInfoRequest{
|
2021-09-09 19:02:08 +08:00
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
2021-09-11 11:36:22 +08:00
|
|
|
CollectionName: collectionName,
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2021-11-06 16:54:59 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("loadBalance", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.LoadBalance(ctx, &milvuspb.LoadBalanceRequest{
|
|
|
|
Base: nil,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-26 17:15:27 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp), merr.ErrCollectionNotFound)
|
2021-11-06 16:54:59 +08:00
|
|
|
})
|
|
|
|
|
2021-09-11 11:36:22 +08:00
|
|
|
// TODO(dragondriver): dummy
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("register link", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.RegisterLink(ctx, &milvuspb.RegisterLinkRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-11 11:36:22 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("get metrics", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
resp, err := proxy.GetMetrics(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
|
|
|
|
// get from cache
|
|
|
|
resp, err = proxy.GetMetrics(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
|
|
|
|
// failed to parse metric type
|
|
|
|
resp, err = proxy.GetMetrics(ctx, &milvuspb.GetMetricsRequest{
|
|
|
|
Base: &commonpb.MsgBase{},
|
|
|
|
Request: "not in json format",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
|
|
|
|
// not implemented metric
|
|
|
|
notImplemented, err := metricsinfo.ConstructRequestByMetricType("not implemented")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
resp, err = proxy.GetMetrics(ctx, notImplemented)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2022-09-16 09:56:47 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get proxy metrics", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req, err := metricsinfo.ConstructRequestByMetricType(metricsinfo.SystemInfoMetrics)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
resp, err := proxy.GetProxyMetrics(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-09-16 09:56:47 +08:00
|
|
|
|
|
|
|
// failed to parse metric type
|
|
|
|
resp, err = proxy.GetProxyMetrics(ctx, &milvuspb.GetMetricsRequest{
|
|
|
|
Base: &commonpb.MsgBase{},
|
|
|
|
Request: "not in json format",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-09-16 09:56:47 +08:00
|
|
|
|
|
|
|
// not implemented metric
|
|
|
|
notImplemented, err := metricsinfo.ConstructRequestByMetricType("not implemented")
|
|
|
|
assert.NoError(t, err)
|
|
|
|
resp, err = proxy.GetProxyMetrics(ctx, notImplemented)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-09-16 09:56:47 +08:00
|
|
|
|
|
|
|
// unhealthy
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2022-09-16 09:56:47 +08:00
|
|
|
resp, err = proxy.GetProxyMetrics(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-09-16 09:56:47 +08:00
|
|
|
|
|
|
|
// getProxyMetric failed
|
|
|
|
rateCol.Deregister(internalpb.RateType_DMLInsert.String())
|
|
|
|
resp, err = proxy.GetProxyMetrics(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-09-16 09:56:47 +08:00
|
|
|
rateCol.Register(internalpb.RateType_DMLInsert.String())
|
|
|
|
})
|
|
|
|
|
2022-04-12 13:25:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("test import", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := &milvuspb.ImportRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-04-12 13:25:34 +08:00
|
|
|
CollectionName: collectionName,
|
2022-11-02 10:23:35 +08:00
|
|
|
Files: []string{"f1.json"},
|
2022-04-12 13:25:34 +08:00
|
|
|
}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-04-12 13:25:34 +08:00
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.EqualValues(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-09-26 18:06:54 +08:00
|
|
|
// Wait a bit for complete import to start.
|
|
|
|
time.Sleep(2 * time.Second)
|
2022-04-12 13:25:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("test import collection ID not found", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "bad_collection_name",
|
2022-11-02 10:23:35 +08:00
|
|
|
Files: []string{"f1.json"},
|
2022-04-12 13:25:34 +08:00
|
|
|
}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-04-12 13:25:34 +08:00
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
2022-06-02 15:34:04 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.EqualValues(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
2022-04-12 13:25:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("test import get vChannel fail", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "bad_collection_name",
|
2022-11-02 10:23:35 +08:00
|
|
|
Files: []string{"f1.json"},
|
2022-04-12 13:25:34 +08:00
|
|
|
}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-04-12 13:25:34 +08:00
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
2022-06-02 15:34:04 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.EqualValues(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
2022-04-12 13:25:34 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("release collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
_, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-17 19:45:42 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.ReleaseCollection(ctx, &milvuspb.ReleaseCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-04-12 13:25:34 +08:00
|
|
|
assert.Equal(t, "", resp.Reason)
|
2021-09-17 19:45:42 +08:00
|
|
|
|
2022-05-19 10:13:56 +08:00
|
|
|
// release collection cache
|
|
|
|
resp, err = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: nil,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
assert.Equal(t, "", resp.Reason)
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("show in-memory collections after release", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
CollectionNames: nil,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-17 19:45:42 +08:00
|
|
|
assert.Equal(t, 0, len(resp.CollectionNames))
|
|
|
|
})
|
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
pLoaded := true
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("load partitions", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2022-07-18 09:58:28 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
2021-09-17 19:45:42 +08:00
|
|
|
resp, err := proxy.LoadPartitions(ctx, &milvuspb.LoadPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
2022-04-20 16:15:41 +08:00
|
|
|
ReplicaNumber: 1,
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// non-exist partition -> fail
|
|
|
|
resp, err = proxy.LoadPartitions(ctx, &milvuspb.LoadPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{otherPartitionName},
|
2022-04-20 16:15:41 +08:00
|
|
|
ReplicaNumber: 1,
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// non-exist collection-> fail
|
|
|
|
resp, err = proxy.LoadPartitions(ctx, &milvuspb.LoadPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
2022-04-20 16:15:41 +08:00
|
|
|
ReplicaNumber: 1,
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-07-18 09:58:28 +08:00
|
|
|
|
|
|
|
f := func() bool {
|
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
|
|
|
|
for idx, name := range resp.PartitionNames {
|
|
|
|
if name == partitionName && resp.InMemoryPercentages[idx] == 100 {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
// waiting for collection to be loaded
|
|
|
|
counter := 0
|
|
|
|
for !f() {
|
|
|
|
if counter > 100 {
|
|
|
|
pLoaded = false
|
|
|
|
break
|
|
|
|
}
|
|
|
|
// avoid too frequent rpc call
|
|
|
|
time.Sleep(100 * time.Millisecond)
|
|
|
|
counter++
|
|
|
|
}
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
2022-07-18 09:58:28 +08:00
|
|
|
assert.True(t, pLoaded)
|
2021-09-17 19:45:42 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-17 19:45:42 +08:00
|
|
|
t.Run("show in-memory partitions", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-17 19:45:42 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-17 19:45:42 +08:00
|
|
|
// default partition?
|
|
|
|
assert.Equal(t, 1, len(resp.PartitionNames))
|
|
|
|
|
|
|
|
// show partition not in-memory -> fail
|
|
|
|
resp, err = proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: []string{otherPartitionName},
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-17 19:45:42 +08:00
|
|
|
|
|
|
|
// non-exist collection -> fail
|
|
|
|
resp, err = proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
|
|
|
|
{
|
|
|
|
resp, err := proxy.GetLoadingProgress(ctx, &milvuspb.GetLoadingProgressRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-10-01 09:02:55 +08:00
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
assert.NotEqual(t, int64(0), resp.Progress)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
resp, err := proxy.GetLoadingProgress(ctx, &milvuspb.GetLoadingProgressRequest{
|
2023-06-25 17:20:43 +08:00
|
|
|
DbName: dbName,
|
2022-10-01 09:02:55 +08:00
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{otherPartitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
assert.Equal(t, int64(0), resp.Progress)
|
|
|
|
}
|
2021-09-17 19:45:42 +08:00
|
|
|
})
|
|
|
|
|
2022-07-18 09:58:28 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("insert partition", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructPartitionInsertRequest()
|
|
|
|
|
|
|
|
resp, err := proxy.Insert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
assert.Equal(t, rowNum, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, 0, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(rowNum), resp.InsertCnt)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get partition statistics from shard", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
if !pLoaded {
|
|
|
|
t.Skip("partition not loaded")
|
|
|
|
}
|
|
|
|
resp, err := proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
rowNumStr := funcutil.KeyValuePair2Map(resp.Stats)["row_count"]
|
|
|
|
assert.Equal(t, strconv.Itoa(rowNum), rowNumStr)
|
|
|
|
|
|
|
|
// non-exist partition -> fail
|
|
|
|
resp, err = proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{otherPartitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
|
|
|
|
// non-exist collection -> fail
|
|
|
|
resp, err = proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("get collection statistics from hybrid", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
if !flushed {
|
|
|
|
t.Skip("flush operation was not done")
|
|
|
|
}
|
|
|
|
if !pLoaded {
|
|
|
|
t.Skip("partition not loaded")
|
|
|
|
}
|
|
|
|
resp, err := proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
rowNumStr := funcutil.KeyValuePair2Map(resp.Stats)["row_count"]
|
|
|
|
assert.Equal(t, strconv.Itoa(rowNum*2), rowNumStr)
|
|
|
|
|
|
|
|
// get statistics of other collection -> fail
|
|
|
|
resp, err = proxy.GetStatistics(ctx, &milvuspb.GetStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-07-18 09:58:28 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("release partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.ReleasePartitions(ctx, &milvuspb.ReleasePartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionNames: []string{partitionName},
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("show in-memory partitions after release partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
// default partition
|
2021-09-17 19:45:42 +08:00
|
|
|
assert.Equal(t, 0, len(resp.PartitionNames))
|
2021-09-09 19:02:08 +08:00
|
|
|
|
|
|
|
resp, err = proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: []string{partitionName}, // released
|
|
|
|
Type: milvuspb.ShowType_InMemory,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("drop partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.DropPartition(ctx, &milvuspb.DropPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// invalidate meta cache
|
|
|
|
resp, err = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// drop non-exist partition -> fail
|
|
|
|
|
|
|
|
resp, err = proxy.DropPartition(ctx, &milvuspb.DropPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("has partition after drop partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.False(t, resp.Value)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("show partitions after drop partition", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
collectionID, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
CollectionID: collectionID,
|
|
|
|
PartitionNames: nil,
|
|
|
|
Type: milvuspb.ShowType_All,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
// default partition
|
|
|
|
assert.Equal(t, 1, len(resp.PartitionNames))
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-11 11:36:22 +08:00
|
|
|
t.Run("drop index", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-11 11:36:22 +08:00
|
|
|
resp, err := proxy.DropIndex(ctx, &milvuspb.DropIndexRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
FieldName: floatVecField,
|
|
|
|
IndexName: indexName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Delete", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
_, err := proxy.Delete(ctx, &milvuspb.DeleteRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
Expr: "",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("upsert when autoID == true", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructCollectionUpsertRequest()
|
|
|
|
|
|
|
|
resp, err := proxy.Upsert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-26 17:15:27 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrParameterInvalid)
|
2023-01-04 17:21:36 +08:00
|
|
|
assert.Equal(t, 0, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, rowNum, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(0), resp.UpsertCnt)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 10:06:29 +08:00
|
|
|
t.Run("drop collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-06-25 17:20:43 +08:00
|
|
|
_, err := globalMetaCache.GetCollectionID(ctx, dbName, collectionName)
|
2021-09-09 10:06:29 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
|
|
|
|
resp, err := proxy.DropCollection(ctx, &milvuspb.DropCollectionRequest{
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-04-12 13:25:34 +08:00
|
|
|
assert.Equal(t, "", resp.Reason)
|
2021-09-09 10:06:29 +08:00
|
|
|
|
|
|
|
// invalidate meta cache
|
|
|
|
resp, err = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
2022-05-19 10:13:56 +08:00
|
|
|
// release collection load cache
|
|
|
|
resp, err = proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{
|
|
|
|
Base: nil,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-09-09 10:06:29 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("has collection after drop collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.HasCollection(ctx, &milvuspb.HasCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.False(t, resp.Value)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-09 19:02:08 +08:00
|
|
|
t.Run("show all collections after drop collection", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-09 19:02:08 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
TimeStamp: 0,
|
|
|
|
Type: milvuspb.ShowType_All,
|
|
|
|
CollectionNames: nil,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-09 19:02:08 +08:00
|
|
|
assert.Equal(t, 0, len(resp.CollectionNames))
|
|
|
|
})
|
|
|
|
|
2022-04-19 16:35:39 +08:00
|
|
|
username := "test_username_" + funcutil.RandomString(15)
|
2022-04-20 13:03:40 +08:00
|
|
|
password := "password"
|
2022-04-19 16:35:39 +08:00
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
wg.Add(1)
|
2022-04-19 16:35:39 +08:00
|
|
|
t.Run("credential CREATE api", func(t *testing.T) {
|
2022-04-11 19:49:34 +08:00
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
// 1. create credential
|
2022-04-19 16:35:39 +08:00
|
|
|
constructCreateCredentialRequest := func() *milvuspb.CreateCredentialRequest {
|
2022-04-11 19:49:34 +08:00
|
|
|
return &milvuspb.CreateCredentialRequest{
|
|
|
|
Base: nil,
|
2022-04-19 16:35:39 +08:00
|
|
|
Username: username,
|
2022-04-11 19:49:34 +08:00
|
|
|
Password: crypto.Base64Encode(password),
|
|
|
|
}
|
|
|
|
}
|
2022-04-19 16:35:39 +08:00
|
|
|
createCredentialReq := constructCreateCredentialRequest()
|
2022-08-04 11:04:34 +08:00
|
|
|
// success
|
2022-04-11 19:49:34 +08:00
|
|
|
resp, err := proxy.CreateCredential(ctx, createCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// recreate -> fail (user already exists)
|
|
|
|
resp, err = proxy.CreateCredential(ctx, createCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// invalid username
|
2022-04-19 16:35:39 +08:00
|
|
|
createCredentialReq.Username = "11_invalid_username"
|
|
|
|
resp, err = proxy.CreateCredential(ctx, createCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// invalid password (not decode)
|
2022-04-19 16:35:39 +08:00
|
|
|
createCredentialReq.Password = "not_decoded_password"
|
|
|
|
resp, err = proxy.CreateCredential(ctx, createCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// invalid password (length gt 256)
|
2022-04-19 16:35:39 +08:00
|
|
|
createCredentialReq.Password = "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmnnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssstttttttttttuuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwwxxxxxxxxxxyyyyyyyyyzzzzzzzzzzz"
|
|
|
|
resp, err = proxy.CreateCredential(ctx, createCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-04-19 16:35:39 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("credential UPDATE api", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
2022-12-09 16:13:20 +08:00
|
|
|
rootCtx := ctx
|
|
|
|
fooCtx := GetContext(context.Background(), "foo:123456")
|
|
|
|
ctx = fooCtx
|
|
|
|
defer func() {
|
|
|
|
ctx = rootCtx
|
|
|
|
}()
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
// 2. update credential
|
2022-04-20 13:03:40 +08:00
|
|
|
newPassword := "new_password"
|
2022-04-19 16:35:39 +08:00
|
|
|
constructUpdateCredentialRequest := func() *milvuspb.UpdateCredentialRequest {
|
|
|
|
return &milvuspb.UpdateCredentialRequest{
|
|
|
|
Base: nil,
|
|
|
|
Username: username,
|
|
|
|
OldPassword: crypto.Base64Encode(password),
|
|
|
|
NewPassword: crypto.Base64Encode(newPassword),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// cannot update non-existing user's password
|
|
|
|
updateCredentialReq := constructUpdateCredentialRequest()
|
|
|
|
updateCredentialReq.Username = "test_username_" + funcutil.RandomString(15)
|
|
|
|
updateResp, err := proxy.UpdateCredential(ctx, updateCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
|
|
|
|
|
|
|
// success
|
|
|
|
updateCredentialReq.Username = username
|
|
|
|
updateCredentialReq.NewPassword = crypto.Base64Encode(newPassword)
|
|
|
|
updateResp, err = proxy.UpdateCredential(ctx, updateCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
|
|
|
|
2022-04-19 16:35:39 +08:00
|
|
|
// invalid old password (not decode)
|
|
|
|
updateCredentialReq.OldPassword = password
|
|
|
|
updateCredentialReq.NewPassword = crypto.Base64Encode(newPassword)
|
|
|
|
updateResp, err = proxy.UpdateCredential(ctx, updateCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
|
|
|
|
|
|
|
// invalid new password (not decode)
|
|
|
|
updateCredentialReq.OldPassword = crypto.Base64Encode(password)
|
|
|
|
updateCredentialReq.NewPassword = newPassword
|
|
|
|
updateResp, err = proxy.UpdateCredential(ctx, updateCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
|
|
|
|
|
|
|
// invalid password (length gt 256)
|
2022-04-19 16:35:39 +08:00
|
|
|
updateCredentialReq.NewPassword = "aaaaaaaaaabbbbbbbbbbccccccccccddddddddddeeeeeeeeeeffffffffffgggggggggghhhhhhhhhhiiiiiiiiiijjjjjjjjjjkkkkkkkkkkllllllllllmmmmmmmmmnnnnnnnnnnnooooooooooppppppppppqqqqqqqqqqrrrrrrrrrrsssssssssstttttttttttuuuuuuuuuuuvvvvvvvvvvwwwwwwwwwwwxxxxxxxxxxyyyyyyyyyzzzzzzzzzzz"
|
|
|
|
updateResp, err = proxy.UpdateCredential(ctx, updateCredentialReq)
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
|
|
|
|
2022-04-19 16:35:39 +08:00
|
|
|
// wrong password
|
|
|
|
updateCredentialReq.OldPassword = crypto.Base64Encode("wrong_password")
|
|
|
|
updateCredentialReq.NewPassword = crypto.Base64Encode(newPassword)
|
|
|
|
updateResp, err = proxy.UpdateCredential(ctx, updateCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
2022-12-09 16:13:20 +08:00
|
|
|
|
|
|
|
// super user
|
2023-04-26 21:16:34 +08:00
|
|
|
paramtable.Get().Save(Params.CommonCfg.SuperUsers.Key, "root")
|
|
|
|
defer paramtable.Get().Reset(Params.CommonCfg.SuperUsers.Key)
|
2022-12-09 16:13:20 +08:00
|
|
|
updateCredentialReq.OldPassword = crypto.Base64Encode("wrong_password")
|
|
|
|
updateCredentialReq.NewPassword = crypto.Base64Encode(newPassword)
|
|
|
|
updateResp, err = proxy.UpdateCredential(rootCtx, updateCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, updateResp.ErrorCode)
|
2022-04-19 16:35:39 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("credential GET api", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
// 3. get credential
|
2022-04-20 13:03:40 +08:00
|
|
|
newPassword := "new_password"
|
2022-04-11 19:49:34 +08:00
|
|
|
constructGetCredentialRequest := func() *rootcoordpb.GetCredentialRequest {
|
|
|
|
return &rootcoordpb.GetCredentialRequest{
|
|
|
|
Base: nil,
|
2022-04-19 16:35:39 +08:00
|
|
|
Username: username,
|
2022-04-11 19:49:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
getCredentialReq := constructGetCredentialRequest()
|
|
|
|
getResp, err := rootCoordClient.GetCredential(ctx, getCredentialReq)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, getResp.GetStatus().GetErrorCode())
|
2022-08-19 19:42:50 +08:00
|
|
|
assert.True(t, passwordVerify(ctx, username, newPassword, globalMetaCache))
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
getCredentialReq.Username = "("
|
|
|
|
getResp, err = rootCoordClient.GetCredential(ctx, getCredentialReq)
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, getResp.GetStatus().GetErrorCode())
|
2022-04-19 16:35:39 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("credential LIST api", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
// 4. list credential usernames
|
|
|
|
constructListCredUsersRequest := func() *milvuspb.ListCredUsersRequest {
|
|
|
|
return &milvuspb.ListCredUsersRequest{
|
|
|
|
Base: nil,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
listCredUsersReq := constructListCredUsersRequest()
|
|
|
|
listUsersResp, err := proxy.ListCredUsers(ctx, listCredUsersReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.True(t, len(listUsersResp.Usernames) > 0)
|
2022-04-19 16:35:39 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("credential DELETE api", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
2022-04-11 19:49:34 +08:00
|
|
|
|
|
|
|
// 5. delete credential
|
|
|
|
constructDelCredRequest := func() *milvuspb.DeleteCredentialRequest {
|
|
|
|
return &milvuspb.DeleteCredentialRequest{
|
|
|
|
Base: nil,
|
2022-04-19 16:35:39 +08:00
|
|
|
Username: username,
|
2022-04-11 19:49:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
delCredReq := constructDelCredRequest()
|
2022-08-04 11:04:34 +08:00
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
deleteResp, err := proxy.DeleteCredential(ctx, delCredReq)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, deleteResp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
testProxyRole(ctx, t, proxy)
|
|
|
|
testProxyPrivilege(ctx, t, proxy)
|
|
|
|
testProxyRefreshPolicyInfoCache(ctx, t, proxy)
|
|
|
|
|
2021-09-15 15:46:06 +08:00
|
|
|
// proxy unhealthy
|
|
|
|
//
|
|
|
|
//notStateCode := "not state code"
|
2023-10-09 10:09:33 +08:00
|
|
|
//proxy.UpdateStateCode(notStateCode)
|
2021-09-15 15:46:06 +08:00
|
|
|
//
|
|
|
|
//t.Run("GetComponentStates fail", func(t *testing.T) {
|
|
|
|
// _, err := proxy.GetComponentStates(ctx)
|
|
|
|
// assert.Error(t, err)
|
|
|
|
//})
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2021-09-15 15:46:06 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("CreateCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.CreateCollection(ctx, &milvuspb.CreateCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("DropCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.DropCollection(ctx, &milvuspb.DropCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("HasCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.HasCollection(ctx, &milvuspb.HasCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("LoadCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("ReleaseCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.ReleaseCollection(ctx, &milvuspb.ReleaseCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("DescribeCollection fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.DescribeCollection(ctx, &milvuspb.DescribeCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetCollectionStatistics fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetCollectionStatistics(ctx, &milvuspb.GetCollectionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("ShowCollections fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2022-10-10 20:31:22 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("alter collection fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterCollection(ctx, &milvuspb.AlterCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: "cn",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("CreatePartition fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("DropPartition fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.DropPartition(ctx, &milvuspb.DropPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("HasPartition fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("LoadPartitions fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.LoadPartitions(ctx, &milvuspb.LoadPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("ReleasePartitions fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.ReleasePartitions(ctx, &milvuspb.ReleasePartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetPartitionStatistics fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetPartitionStatistics(ctx, &milvuspb.GetPartitionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("ShowPartitions fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2022-10-01 09:02:55 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetLoadingProgress fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetLoadingProgress(ctx, &milvuspb.GetLoadingProgressRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
})
|
|
|
|
|
2022-12-16 14:39:24 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetLoadState fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetLoadState(ctx, &milvuspb.GetLoadStateRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("CreateIndex fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.CreateIndex(ctx, &milvuspb.CreateIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("DescribeIndex fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.DescribeIndex(ctx, &milvuspb.DescribeIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2023-05-06 10:34:39 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetIndexStatistics fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetIndexStatistics(ctx, &milvuspb.GetIndexStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-05-06 10:34:39 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("DropIndex fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.DropIndex(ctx, &milvuspb.DropIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetIndexBuildProgress fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetIndexBuildProgress(ctx, &milvuspb.GetIndexBuildProgressRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetIndexState fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetIndexState(ctx, &milvuspb.GetIndexStateRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Insert fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.Insert(ctx, &milvuspb.InsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Delete fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.Delete(ctx, &milvuspb.DeleteRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Upsert fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.Upsert(ctx, &milvuspb.UpsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-01-04 17:21:36 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Search fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.Search(ctx, &milvuspb.SearchRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Flush fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.Flush(ctx, &milvuspb.FlushRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("Query fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.Query(ctx, &milvuspb.QueryRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-11-30 20:07:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("CreateAlias fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreateAlias(ctx, &milvuspb.CreateAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-12-01 15:41:51 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DropAlias fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DropAlias(ctx, &milvuspb.DropAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2021-11-30 20:07:34 +08:00
|
|
|
})
|
|
|
|
|
2021-12-08 14:53:32 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("AlterAlias fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterAlias(ctx, &milvuspb.AlterAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetPersistentSegmentInfo fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetPersistentSegmentInfo(ctx, &milvuspb.GetPersistentSegmentInfoRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetQuerySegmentInfo fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetQuerySegmentInfo(ctx, &milvuspb.GetQuerySegmentInfoRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-11-06 16:54:59 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("LoadBalance fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.LoadBalance(ctx, &milvuspb.LoadBalanceRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("RegisterLink fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.RegisterLink(ctx, &milvuspb.RegisterLinkRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-15 15:46:06 +08:00
|
|
|
t.Run("GetMetrics fail, unhealthy", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.GetMetrics(ctx, &milvuspb.GetMetricsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-15 15:46:06 +08:00
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("InvalidateCredCache fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.InvalidateCredentialCache(ctx, &proxypb.InvalidateCredCacheRequest{Username: "xxx"})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("UpdateCredentialCache fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.UpdateCredentialCache(ctx, &proxypb.UpdateCredCacheRequest{Username: "xxx", Password: "xxx"})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("CreateCredential fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreateCredential(ctx, &milvuspb.CreateCredentialRequest{Username: "xxx"})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("UpdateCredential fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.UpdateCredential(ctx, &milvuspb.UpdateCredentialRequest{Username: "xxx"})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DeleteCredential fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DeleteCredential(ctx, &milvuspb.DeleteCredentialRequest{Username: "xxx"})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("ListCredUsers fail, unhealthy", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.ListCredUsers(ctx, &milvuspb.ListCredUsersRequest{})
|
2022-09-02 21:12:59 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
2022-11-07 16:55:01 +08:00
|
|
|
t.Run("InvalidateCollectionMetaCache failed", func(t *testing.T) {
|
|
|
|
resp, err := proxy.InvalidateCollectionMetaCache(ctx, &proxypb.InvalidateCollMetaCacheRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetErrorCode())
|
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
testProxyRoleUnhealthy(ctx, t, proxy)
|
|
|
|
testProxyPrivilegeUnhealthy(ctx, t, proxy)
|
|
|
|
testProxyRefreshPolicyInfoCacheUnhealthy(ctx, t, proxy)
|
|
|
|
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2021-09-15 15:46:06 +08:00
|
|
|
|
|
|
|
// queue full
|
|
|
|
|
2021-09-15 19:09:50 +08:00
|
|
|
ddParallel := proxy.sched.ddQueue.getMaxTaskNum()
|
|
|
|
proxy.sched.ddQueue.setMaxTaskNum(0)
|
2021-09-15 15:46:06 +08:00
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("CreateCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.CreateCollection(ctx, &milvuspb.CreateCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("DropCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.DropCollection(ctx, &milvuspb.DropCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("HasCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.HasCollection(ctx, &milvuspb.HasCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("LoadCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.LoadCollection(ctx, &milvuspb.LoadCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("ReleaseCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.ReleaseCollection(ctx, &milvuspb.ReleaseCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("DescribeCollection fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.DescribeCollection(ctx, &milvuspb.DescribeCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("GetCollectionStatistics fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.GetCollectionStatistics(ctx, &milvuspb.GetCollectionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("ShowCollections fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.ShowCollections(ctx, &milvuspb.ShowCollectionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2022-10-10 20:31:22 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("alter collection fail, dd queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterCollection(ctx, &milvuspb.AlterCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: "cn",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("CreatePartition fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("DropPartition fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.DropPartition(ctx, &milvuspb.DropPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("HasPartition fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.HasPartition(ctx, &milvuspb.HasPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("LoadPartitions fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.LoadPartitions(ctx, &milvuspb.LoadPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("ReleasePartitions fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.ReleasePartitions(ctx, &milvuspb.ReleasePartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("GetPartitionStatistics fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.GetPartitionStatistics(ctx, &milvuspb.GetPartitionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("ShowPartitions fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.ShowPartitions(ctx, &milvuspb.ShowPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("CreateIndex fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.CreateIndex(ctx, &milvuspb.CreateIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("DescribeIndex fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.DescribeIndex(ctx, &milvuspb.DescribeIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2023-05-06 10:34:39 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetIndexStatistics fail, dd queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetIndexStatistics(ctx, &milvuspb.GetIndexStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-05-06 10:34:39 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("DropIndex fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.DropIndex(ctx, &milvuspb.DropIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("GetIndexBuildProgress fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.GetIndexBuildProgress(ctx, &milvuspb.GetIndexBuildProgressRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("GetIndexState fail, dd queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.GetIndexState(ctx, &milvuspb.GetIndexStateRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2023-10-13 18:33:36 +08:00
|
|
|
t.Run("Flush fail, dc queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2023-10-13 18:33:36 +08:00
|
|
|
proxy.sched.dcQueue.setMaxTaskNum(0)
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.Flush(ctx, &milvuspb.FlushRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
2021-09-15 15:46:06 +08:00
|
|
|
|
2021-12-01 15:36:03 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("CreateAlias fail, dd queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreateAlias(ctx, &milvuspb.CreateAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-12-08 14:47:04 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DropAlias fail, dd queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DropAlias(ctx, &milvuspb.DropAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-12-15 10:28:15 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("AlterAlias fail, dd queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterAlias(ctx, &milvuspb.AlterAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-15 19:09:50 +08:00
|
|
|
proxy.sched.ddQueue.setMaxTaskNum(ddParallel)
|
2021-09-15 15:46:06 +08:00
|
|
|
|
2021-09-16 11:29:49 +08:00
|
|
|
dmParallelism := proxy.sched.dmQueue.getMaxTaskNum()
|
|
|
|
proxy.sched.dmQueue.setMaxTaskNum(0)
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("Insert fail, dm queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.Insert(ctx, &milvuspb.InsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("Delete fail, dm queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.Delete(ctx, &milvuspb.DeleteRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Upsert fail, dm queue full", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.Upsert(ctx, &milvuspb.UpsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-01-04 17:21:36 +08:00
|
|
|
})
|
|
|
|
|
2021-09-16 11:29:49 +08:00
|
|
|
proxy.sched.dmQueue.setMaxTaskNum(dmParallelism)
|
|
|
|
|
|
|
|
dqParallelism := proxy.sched.dqQueue.getMaxTaskNum()
|
|
|
|
proxy.sched.dqQueue.setMaxTaskNum(0)
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("Search fail, dq queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.Search(ctx, &milvuspb.SearchRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 11:29:49 +08:00
|
|
|
t.Run("Query fail, dq queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 11:29:49 +08:00
|
|
|
resp, err := proxy.Query(ctx, &milvuspb.QueryRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 11:29:49 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
proxy.sched.dqQueue.setMaxTaskNum(dqParallelism)
|
|
|
|
|
2021-09-15 15:46:06 +08:00
|
|
|
// timeout
|
|
|
|
|
|
|
|
timeout := time.Nanosecond
|
|
|
|
shortCtx, shortCancel := context.WithTimeout(ctx, timeout)
|
|
|
|
defer shortCancel()
|
|
|
|
time.Sleep(timeout)
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("CreateCollection, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-15 15:46:06 +08:00
|
|
|
resp, err := proxy.CreateCollection(shortCtx, &milvuspb.CreateCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("DropCollection fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.DropCollection(shortCtx, &milvuspb.DropCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("HasCollection fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.HasCollection(shortCtx, &milvuspb.HasCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("LoadCollection fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.LoadCollection(shortCtx, &milvuspb.LoadCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("ReleaseCollection fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.ReleaseCollection(shortCtx, &milvuspb.ReleaseCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("DescribeCollection fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.DescribeCollection(shortCtx, &milvuspb.DescribeCollectionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("GetCollectionStatistics fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.GetCollectionStatistics(shortCtx, &milvuspb.GetCollectionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("ShowCollections fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.ShowCollections(shortCtx, &milvuspb.ShowCollectionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2022-10-10 20:31:22 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("alter collection fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterCollection(shortCtx, &milvuspb.AlterCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: "cn",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("CreatePartition fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.CreatePartition(shortCtx, &milvuspb.CreatePartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("DropPartition fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.DropPartition(shortCtx, &milvuspb.DropPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("HasPartition fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.HasPartition(shortCtx, &milvuspb.HasPartitionRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("LoadPartitions fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.LoadPartitions(shortCtx, &milvuspb.LoadPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("ReleasePartitions fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.ReleasePartitions(shortCtx, &milvuspb.ReleasePartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("GetPartitionStatistics fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.GetPartitionStatistics(shortCtx, &milvuspb.GetPartitionStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("ShowPartitions fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.ShowPartitions(shortCtx, &milvuspb.ShowPartitionsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2022-10-01 09:02:55 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetLoadingProgress fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetLoadingProgress(shortCtx, &milvuspb.GetLoadingProgressRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-10-01 09:02:55 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("CreateIndex fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.CreateIndex(shortCtx, &milvuspb.CreateIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("DescribeIndex fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.DescribeIndex(shortCtx, &milvuspb.DescribeIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2023-05-06 10:34:39 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("GetIndexStatistics fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.GetIndexStatistics(shortCtx, &milvuspb.GetIndexStatisticsRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-05-06 10:34:39 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("DropIndex fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.DropIndex(shortCtx, &milvuspb.DropIndexRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("GetIndexBuildProgress fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.GetIndexBuildProgress(shortCtx, &milvuspb.GetIndexBuildProgressRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("GetIndexState fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.GetIndexState(shortCtx, &milvuspb.GetIndexStateRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("Flush fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-17 19:45:42 +08:00
|
|
|
_, err := proxy.Flush(shortCtx, &milvuspb.FlushRequest{})
|
2021-09-16 14:09:49 +08:00
|
|
|
assert.NoError(t, err)
|
2021-09-17 19:45:42 +08:00
|
|
|
// FIXME(dragondriver)
|
2023-09-15 10:09:21 +08:00
|
|
|
// assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("Insert fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.Insert(shortCtx, &milvuspb.InsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("Delete fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.Delete(shortCtx, &milvuspb.DeleteRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Update fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.Upsert(shortCtx, &milvuspb.UpsertRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-01-04 17:21:36 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("Search fail, timeout", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.Search(shortCtx, &milvuspb.SearchRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Add(1)
|
2021-09-16 14:09:49 +08:00
|
|
|
t.Run("Query fail, dq queue full", func(t *testing.T) {
|
2021-09-29 11:07:59 +08:00
|
|
|
defer wg.Done()
|
2021-09-16 14:09:49 +08:00
|
|
|
resp, err := proxy.Query(shortCtx, &milvuspb.QueryRequest{})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-09-16 14:09:49 +08:00
|
|
|
})
|
2021-09-15 15:46:06 +08:00
|
|
|
|
2021-12-01 10:13:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("CreateAlias fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreateAlias(shortCtx, &milvuspb.CreateAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-12-08 14:51:18 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DropAlias fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DropAlias(shortCtx, &milvuspb.DropAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2021-12-15 10:29:57 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("AlterAlias fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.AlterAlias(shortCtx, &milvuspb.AlterAliasRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("CreateCredential fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreateCredential(shortCtx, &milvuspb.CreateCredentialRequest{Username: "xxx"})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("UpdateCredential fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
2022-04-19 16:35:39 +08:00
|
|
|
resp, err := proxy.UpdateCredential(shortCtx, &milvuspb.UpdateCredentialRequest{Username: "xxx"})
|
2022-04-11 19:49:34 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-04-20 13:03:40 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DeleteCredential fail, user root cannot be deleted", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DeleteCredential(shortCtx, &milvuspb.DeleteCredentialRequest{Username: "root"})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-04-11 19:49:34 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("DeleteCredential fail, timeout", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.DeleteCredential(shortCtx, &milvuspb.DeleteCredentialRequest{Username: "xxx"})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
testProxyRoleTimeout(shortCtx, t, proxy)
|
|
|
|
testProxyPrivilegeTimeout(shortCtx, t, proxy)
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
constructCollectionSchema = func() *schemapb.CollectionSchema {
|
|
|
|
pk := &schemapb.FieldSchema{
|
|
|
|
FieldID: 0,
|
|
|
|
Name: int64Field,
|
|
|
|
IsPrimaryKey: true,
|
|
|
|
Description: "",
|
|
|
|
DataType: schemapb.DataType_Int64,
|
|
|
|
TypeParams: nil,
|
|
|
|
IndexParams: nil,
|
|
|
|
AutoID: false,
|
|
|
|
}
|
|
|
|
fVec := &schemapb.FieldSchema{
|
|
|
|
FieldID: 0,
|
|
|
|
Name: floatVecField,
|
|
|
|
IsPrimaryKey: false,
|
|
|
|
Description: "",
|
|
|
|
DataType: schemapb.DataType_FloatVector,
|
|
|
|
TypeParams: []*commonpb.KeyValuePair{
|
|
|
|
{
|
2023-05-16 17:41:22 +08:00
|
|
|
Key: common.DimKey,
|
2023-01-04 17:21:36 +08:00
|
|
|
Value: strconv.Itoa(dim),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
IndexParams: nil,
|
|
|
|
AutoID: false,
|
|
|
|
}
|
|
|
|
return &schemapb.CollectionSchema{
|
|
|
|
Name: collectionName,
|
|
|
|
Description: "",
|
|
|
|
AutoID: false,
|
|
|
|
Fields: []*schemapb.FieldSchema{
|
|
|
|
pk,
|
|
|
|
fVec,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
schema = constructCollectionSchema()
|
|
|
|
|
|
|
|
constructCreateCollectionRequest = func() *milvuspb.CreateCollectionRequest {
|
|
|
|
bs, err := proto.Marshal(schema)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
return &milvuspb.CreateCollectionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
Schema: bs,
|
|
|
|
ShardsNum: shardsNum,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
createCollectionReq = constructCreateCollectionRequest()
|
|
|
|
|
|
|
|
constructPartitionReqUpsertRequestValid := func() *milvuspb.UpsertRequest {
|
|
|
|
pkFieldData := newScalarFieldData(schema.Fields[0], int64Field, rowNum)
|
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.UpsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
FieldsData: []*schemapb.FieldData{pkFieldData, fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-06 14:29:51 +08:00
|
|
|
constructPartitionReqUpsertRequestInvalid := func() *milvuspb.UpsertRequest {
|
|
|
|
pkFieldData := newScalarFieldData(schema.Fields[0], int64Field, rowNum)
|
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.UpsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: "%$@",
|
|
|
|
FieldsData: []*schemapb.FieldData{pkFieldData, fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
constructCollectionUpsertRequestValid := func() *milvuspb.UpsertRequest {
|
|
|
|
pkFieldData := newScalarFieldData(schema.Fields[0], int64Field, rowNum)
|
|
|
|
fVecColumn := newFloatVectorFieldData(floatVecField, rowNum, dim)
|
|
|
|
hashKeys := generateHashKeys(rowNum)
|
|
|
|
return &milvuspb.UpsertRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
FieldsData: []*schemapb.FieldData{pkFieldData, fVecColumn},
|
|
|
|
HashKeys: hashKeys,
|
|
|
|
NumRows: uint32(rowNum),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("create collection upsert valid", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := createCollectionReq
|
|
|
|
resp, err := proxy.CreateCollection(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
reqInvalidField := constructCreateCollectionRequest()
|
|
|
|
schema := constructCollectionSchema()
|
|
|
|
schema.Fields = append(schema.Fields, &schemapb.FieldSchema{
|
|
|
|
Name: "StringField",
|
|
|
|
DataType: schemapb.DataType_String,
|
|
|
|
})
|
|
|
|
bs, err := proto.Marshal(schema)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
reqInvalidField.CollectionName = "invalid_field_coll_upsert_valid"
|
|
|
|
reqInvalidField.Schema = bs
|
|
|
|
|
|
|
|
resp, err = proxy.CreateCollection(ctx, reqInvalidField)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("create partition", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, err := proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: collectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// create partition with non-exist collection -> fail
|
|
|
|
resp, err = proxy.CreatePartition(ctx, &milvuspb.CreatePartitionRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: dbName,
|
|
|
|
CollectionName: otherCollectionName,
|
|
|
|
PartitionName: partitionName,
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("upsert partition", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructPartitionReqUpsertRequestValid()
|
|
|
|
|
|
|
|
resp, err := proxy.Upsert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-01-04 17:21:36 +08:00
|
|
|
assert.Equal(t, rowNum, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, 0, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(rowNum), resp.UpsertCnt)
|
|
|
|
})
|
|
|
|
|
2023-03-06 14:29:51 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("upsert when occurs unexpected error like illegal partition name", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructPartitionReqUpsertRequestInvalid()
|
|
|
|
|
|
|
|
resp, err := proxy.Upsert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
2023-03-06 14:29:51 +08:00
|
|
|
assert.Equal(t, 0, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, rowNum, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(0), resp.UpsertCnt)
|
|
|
|
})
|
|
|
|
|
2023-01-04 17:21:36 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("upsert when autoID == false", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
req := constructCollectionUpsertRequestValid()
|
|
|
|
|
|
|
|
resp, err := proxy.Upsert(ctx, req)
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-01-04 17:21:36 +08:00
|
|
|
assert.Equal(t, rowNum, len(resp.SuccIndex))
|
|
|
|
assert.Equal(t, 0, len(resp.ErrIndex))
|
|
|
|
assert.Equal(t, int64(rowNum), resp.UpsertCnt)
|
|
|
|
})
|
|
|
|
|
2022-01-17 14:41:35 +08:00
|
|
|
testServer.gracefulStop()
|
|
|
|
|
2021-09-29 11:07:59 +08:00
|
|
|
wg.Wait()
|
2021-09-09 10:06:29 +08:00
|
|
|
cancel()
|
|
|
|
}
|
2021-11-09 14:47:02 +08:00
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
func testProxyRole(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Create Role", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
entity := &milvuspb.RoleEntity{Name: " "}
|
|
|
|
resp, _ := proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: entity})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
entity.Name = "unit_test"
|
|
|
|
resp, _ = proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: entity})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: entity})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: entity.Name})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Drop Role", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
resp, _ := proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: " "})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
2022-08-15 16:40:48 +08:00
|
|
|
resp, _ = proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: "public"})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
username := "root"
|
|
|
|
roleName := "unit_test"
|
|
|
|
|
|
|
|
roleEntity := &milvuspb.RoleEntity{Name: roleName}
|
|
|
|
roleResp, _ := proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: roleEntity})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, roleResp.ErrorCode)
|
|
|
|
|
|
|
|
privilegeRequest := &milvuspb.OperatePrivilegeRequest{
|
|
|
|
Type: milvuspb.OperatePrivilegeType_Grant,
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
ObjectName: "col1",
|
|
|
|
Object: &milvuspb.ObjectEntity{Name: commonpb.ObjectType_Collection.String()},
|
|
|
|
Role: &milvuspb.RoleEntity{Name: roleName},
|
2022-08-05 16:28:35 +08:00
|
|
|
Grantor: &milvuspb.GrantorEntity{Privilege: &milvuspb.PrivilegeEntity{Name: util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeLoad.String())}},
|
2022-08-04 11:04:34 +08:00
|
|
|
},
|
|
|
|
}
|
|
|
|
privilegeResp, _ := proxy.OperatePrivilege(ctx, privilegeRequest)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, privilegeResp.ErrorCode)
|
|
|
|
|
|
|
|
userResp, _ := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: &milvuspb.UserEntity{Name: username}, IncludeRoleInfo: true})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, userResp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
roleNumOfUser := len(userResp.Results[0].Roles)
|
|
|
|
|
|
|
|
roleResp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{
|
|
|
|
Username: username,
|
|
|
|
RoleName: roleName,
|
|
|
|
Type: milvuspb.OperateUserRoleType_AddUserToRole,
|
|
|
|
})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, roleResp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: roleName})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
privilegeRequest.Type = milvuspb.OperatePrivilegeType_Revoke
|
|
|
|
privilegeResp, _ = proxy.OperatePrivilege(ctx, privilegeRequest)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, privilegeResp.ErrorCode)
|
|
|
|
|
|
|
|
roleResp, _ = proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: roleName})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, roleResp.ErrorCode)
|
|
|
|
|
|
|
|
userResp, _ = proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: &milvuspb.UserEntity{Name: username}, IncludeRoleInfo: true})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, userResp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.Equal(t, roleNumOfUser, len(userResp.Results[0].Roles))
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Operate User Role", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
username := "root"
|
|
|
|
roleName := "public"
|
|
|
|
// AddUserToRole
|
|
|
|
resp, _ := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: " "})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: " "})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "not_existed", RoleName: roleName})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: "not_existed"})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: roleName})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: roleName, Type: milvuspb.OperateUserRoleType_RemoveUserFromRole})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2023-05-16 10:15:22 +08:00
|
|
|
|
|
|
|
resp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "NotExisted", RoleName: roleName, Type: milvuspb.OperateUserRoleType_RemoveUserFromRole})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Select Role", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
2022-09-02 21:12:59 +08:00
|
|
|
resp, _ := proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{Role: &milvuspb.RoleEntity{Name: " "}})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
2022-09-02 21:12:59 +08:00
|
|
|
resp, _ = proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
roleNum := len(resp.Results)
|
|
|
|
|
2022-08-10 17:20:41 +08:00
|
|
|
resp, _ = proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{Role: &milvuspb.RoleEntity{Name: "not_existed"}})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-10 17:20:41 +08:00
|
|
|
assert.Equal(t, 0, len(resp.Results))
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
roleName := "unit_test"
|
|
|
|
roleResp, _ := proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: &milvuspb.RoleEntity{Name: roleName}})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, roleResp.ErrorCode)
|
|
|
|
|
|
|
|
resp, _ = proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.Equal(t, roleNum+1, len(resp.Results))
|
|
|
|
|
|
|
|
roleResp, _ = proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: roleName})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, roleResp.ErrorCode)
|
|
|
|
|
2022-08-15 16:40:48 +08:00
|
|
|
opResp, _ := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "root", RoleName: "admin"})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, opResp.ErrorCode)
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
resp, _ = proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{Role: &milvuspb.RoleEntity{Name: "admin"}, IncludeUserInfo: true})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, 0, len(resp.Results))
|
|
|
|
assert.NotEqual(t, 0, len(resp.Results[0].Users))
|
2022-08-15 16:40:48 +08:00
|
|
|
|
|
|
|
opResp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "root", RoleName: "admin", Type: milvuspb.OperateUserRoleType_RemoveUserFromRole})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, opResp.ErrorCode)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Select User", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
entity := &milvuspb.UserEntity{Name: " "}
|
|
|
|
resp, _ := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: entity})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
entity.Name = "not_existed"
|
|
|
|
resp, _ = proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: entity})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-10 17:20:41 +08:00
|
|
|
assert.Equal(t, 0, len(resp.Results))
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
entity.Name = "root"
|
|
|
|
resp, _ = proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: entity})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, 0, len(resp.Results))
|
|
|
|
|
2022-08-15 16:40:48 +08:00
|
|
|
opResp, _ := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "root", RoleName: "admin"})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, opResp.ErrorCode)
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
resp, _ = proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: entity, IncludeRoleInfo: true})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, 0, len(resp.Results))
|
|
|
|
assert.NotEqual(t, 0, len(resp.Results[0].Roles))
|
2022-08-15 16:40:48 +08:00
|
|
|
|
|
|
|
opResp, _ = proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "root", RoleName: "admin", Type: milvuspb.OperateUserRoleType_RemoveUserFromRole})
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, opResp.ErrorCode)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
2023-08-04 18:37:08 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("User Role mapping info", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
ctx := context.Background()
|
|
|
|
username := fmt.Sprintf("user%d", rand.Int31())
|
|
|
|
roleName := fmt.Sprintf("role%d", rand.Int31())
|
|
|
|
{
|
|
|
|
createCredentialResp, err := proxy.CreateCredential(ctx, &milvuspb.CreateCredentialRequest{Username: username, Password: crypto.Base64Encode("userpwd")})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, createCredentialResp.ErrorCode)
|
|
|
|
createRoleResp, err := proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: &milvuspb.RoleEntity{Name: roleName}})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, createRoleResp.ErrorCode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
resp, err := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: roleName})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
resp, err := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: username, RoleName: "admin"})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
selectUserResp, err := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: &milvuspb.UserEntity{Name: username}, IncludeRoleInfo: true})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, selectUserResp.GetStatus().GetErrorCode())
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.Equal(t, 2, len(selectUserResp.Results[0].Roles))
|
|
|
|
|
|
|
|
selectRoleResp, err := proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{Role: &milvuspb.RoleEntity{Name: roleName}, IncludeUserInfo: true})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, selectRoleResp.GetStatus().GetErrorCode())
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.Equal(t, 1, len(selectRoleResp.Results[0].Users))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
resp, err := proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: roleName})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
selectUserResp, err := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: &milvuspb.UserEntity{Name: username}, IncludeRoleInfo: true})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, selectUserResp.GetStatus().GetErrorCode())
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.Equal(t, 1, len(selectUserResp.Results[0].Roles))
|
|
|
|
|
|
|
|
selectRoleResp, err := proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{Role: &milvuspb.RoleEntity{Name: roleName}, IncludeUserInfo: true})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, selectRoleResp.GetStatus().GetErrorCode())
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.Equal(t, 0, len(selectRoleResp.Results))
|
|
|
|
}
|
|
|
|
{
|
|
|
|
resp, err := proxy.DeleteCredential(ctx, &milvuspb.DeleteCredentialRequest{Username: username})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
}
|
|
|
|
{
|
|
|
|
selectUserResp, err := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{User: &milvuspb.UserEntity{Name: username}, IncludeRoleInfo: true})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, selectUserResp.GetStatus().GetErrorCode())
|
2023-08-04 18:37:08 +08:00
|
|
|
assert.Equal(t, 0, len(selectUserResp.Results))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRoleUnhealthy(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
testProxyRoleFail(ctx, t, proxy, "unhealthy")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRoleTimeout(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
testProxyRoleFail(ctx, t, proxy, "timeout")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRoleFail(ctx context.Context, t *testing.T, proxy *Proxy, reason string) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
roleName := "xxx"
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("CreateRole fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.CreateRole(ctx, &milvuspb.CreateRoleRequest{Entity: &milvuspb.RoleEntity{Name: roleName}})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("DropRole fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.DropRole(ctx, &milvuspb.DropRoleRequest{RoleName: roleName})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("OperateUserRole fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.OperateUserRole(ctx, &milvuspb.OperateUserRoleRequest{Username: "root", RoleName: "public"})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("SelectRole fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.SelectRole(ctx, &milvuspb.SelectRoleRequest{})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("SelectUser fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.SelectUser(ctx, &milvuspb.SelectUserRequest{})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyPrivilege(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("Operate Privilege, Select Grant", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
// GrantPrivilege
|
|
|
|
req := &milvuspb.OperatePrivilegeRequest{}
|
|
|
|
resp, _ := proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity = &milvuspb.GrantEntity{}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Grantor = &milvuspb.GrantorEntity{}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Grantor.Privilege = &milvuspb.PrivilegeEntity{}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
2022-08-05 16:28:35 +08:00
|
|
|
req.Entity.Grantor.Privilege.Name = util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeAll.String())
|
|
|
|
|
2022-08-04 11:04:34 +08:00
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Object = &milvuspb.ObjectEntity{}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Object.Name = commonpb.ObjectType_Global.String()
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.ObjectName = "col1"
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Role = &milvuspb.RoleEntity{}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Role = &milvuspb.RoleEntity{Name: "admin"}
|
2022-09-02 21:12:59 +08:00
|
|
|
resp, _ = proxy.OperatePrivilege(context.Background(), req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
req.Entity.Grantor.Privilege.Name = "not existed"
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-08-05 16:28:35 +08:00
|
|
|
req.Entity.Grantor.Privilege.Name = util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeAll.String())
|
2022-08-04 11:04:34 +08:00
|
|
|
req.Entity.Object.Name = "not existed"
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
req.Entity.Object.Name = commonpb.ObjectType_Global.String()
|
|
|
|
|
|
|
|
req.Entity.Role.Name = "not existed"
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
req.Entity.Role = &milvuspb.RoleEntity{Name: "admin"}
|
|
|
|
|
|
|
|
roleReq := &milvuspb.OperatePrivilegeRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "public"},
|
|
|
|
Object: &milvuspb.ObjectEntity{Name: commonpb.ObjectType_Collection.String()},
|
|
|
|
ObjectName: "col1",
|
2022-08-05 16:28:35 +08:00
|
|
|
Grantor: &milvuspb.GrantorEntity{Privilege: &milvuspb.PrivilegeEntity{Name: util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeLoad.String())}},
|
2022-08-04 11:04:34 +08:00
|
|
|
},
|
|
|
|
Type: milvuspb.OperatePrivilegeType_Grant,
|
|
|
|
}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
// select grant
|
|
|
|
selectReq := &milvuspb.SelectGrantRequest{}
|
|
|
|
results, _ := proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity = &milvuspb.GrantEntity{}
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity.Object = &milvuspb.ObjectEntity{}
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity.Object.Name = commonpb.ObjectType_Collection.String()
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity.ObjectName = "col1"
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity.Role = &milvuspb.RoleEntity{}
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
selectReq.Entity.Role = &milvuspb.RoleEntity{Name: "public"}
|
|
|
|
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, 0, len(results.Entities))
|
|
|
|
|
|
|
|
selectReq.Entity.Object.Name = "not existed"
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
selectReq.Entity.Object.Name = commonpb.ObjectType_Collection.String()
|
|
|
|
|
|
|
|
selectReq.Entity.Role = &milvuspb.RoleEntity{Name: "not existed"}
|
|
|
|
results, _ = proxy.SelectGrant(ctx, selectReq)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
|
|
|
|
results, _ = proxy.SelectGrant(ctx, &milvuspb.SelectGrantRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "public"},
|
|
|
|
},
|
|
|
|
})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, results.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
assert.NotEqual(t, 0, len(results.Entities))
|
|
|
|
|
|
|
|
req.Type = milvuspb.OperatePrivilegeType_Revoke
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, req)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
roleReq.Type = milvuspb.OperatePrivilegeType_Revoke
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-08-15 16:40:48 +08:00
|
|
|
|
|
|
|
roleReq = &milvuspb.OperatePrivilegeRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "public"},
|
|
|
|
Object: &milvuspb.ObjectEntity{Name: commonpb.ObjectType_Collection.String()},
|
|
|
|
ObjectName: "col1",
|
|
|
|
Grantor: &milvuspb.GrantorEntity{Privilege: &milvuspb.PrivilegeEntity{Name: util.AnyWord}},
|
|
|
|
},
|
|
|
|
Type: milvuspb.OperatePrivilegeType_Grant,
|
|
|
|
}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
roleReq.Type = milvuspb.OperatePrivilegeType_Revoke
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
roleReq = &milvuspb.OperatePrivilegeRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "public"},
|
|
|
|
Object: &milvuspb.ObjectEntity{Name: commonpb.ObjectType_Global.String()},
|
|
|
|
ObjectName: "col1",
|
|
|
|
Grantor: &milvuspb.GrantorEntity{Privilege: &milvuspb.PrivilegeEntity{Name: util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeManageOwnership.String())}},
|
|
|
|
},
|
|
|
|
Type: milvuspb.OperatePrivilegeType_Grant,
|
|
|
|
}
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
|
|
|
|
roleReq.Type = milvuspb.OperatePrivilegeType_Revoke
|
|
|
|
resp, _ = proxy.OperatePrivilege(ctx, roleReq)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyPrivilegeUnhealthy(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
testProxyPrivilegeFail(ctx, t, proxy, "unhealthy")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyPrivilegeTimeout(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
testProxyPrivilegeFail(ctx, t, proxy, "timeout")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyPrivilegeFail(ctx context.Context, t *testing.T, proxy *Proxy, reason string) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("Operate Grant fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.OperatePrivilege(ctx, &milvuspb.OperatePrivilegeRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "admin"},
|
|
|
|
ObjectName: "col1",
|
|
|
|
Object: &milvuspb.ObjectEntity{Name: commonpb.ObjectType_Collection.String()},
|
2022-08-05 16:28:35 +08:00
|
|
|
Grantor: &milvuspb.GrantorEntity{Privilege: &milvuspb.PrivilegeEntity{Name: util.MetaStore2API(commonpb.ObjectPrivilege_PrivilegeAll.String())}},
|
2022-08-04 11:04:34 +08:00
|
|
|
},
|
|
|
|
})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("SelectGrant fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
resp, _ := proxy.SelectGrant(ctx, &milvuspb.SelectGrantRequest{
|
|
|
|
Entity: &milvuspb.GrantEntity{
|
|
|
|
Role: &milvuspb.RoleEntity{Name: "admin"},
|
|
|
|
},
|
|
|
|
})
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRefreshPolicyInfoCache(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("RefreshPolicyInfoCache", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
|
|
|
|
resp, err := proxy.RefreshPolicyInfoCache(ctx, &proxypb.RefreshPolicyInfoCacheRequest{
|
|
|
|
OpType: int32(typeutil.CacheAddUserToRole),
|
|
|
|
OpKey: funcutil.EncodeUserRoleCache("foo", "public"),
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
2023-10-09 10:09:33 +08:00
|
|
|
resp, err = proxy.RefreshPolicyInfoCache(ctx, &proxypb.RefreshPolicyInfoCacheRequest{})
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Error(t, merr.Error(resp))
|
2022-08-04 11:04:34 +08:00
|
|
|
|
2023-10-09 10:09:33 +08:00
|
|
|
resp, err = proxy.RefreshPolicyInfoCache(ctx, &proxypb.RefreshPolicyInfoCacheRequest{
|
2022-08-04 11:04:34 +08:00
|
|
|
OpType: 100,
|
|
|
|
OpKey: funcutil.EncodeUserRoleCache("foo", "public"),
|
|
|
|
})
|
2023-10-09 10:09:33 +08:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Error(t, merr.Error(resp))
|
2022-08-04 11:04:34 +08:00
|
|
|
})
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRefreshPolicyInfoCacheUnhealthy(ctx context.Context, t *testing.T, proxy *Proxy) {
|
|
|
|
testProxyRefreshPolicyInfoCacheFail(ctx, t, proxy, "unhealthy")
|
|
|
|
}
|
|
|
|
|
|
|
|
func testProxyRefreshPolicyInfoCacheFail(ctx context.Context, t *testing.T, proxy *Proxy, reason string) {
|
|
|
|
var wg sync.WaitGroup
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run(fmt.Sprintf("RefreshPolicyInfoCache fail, %s", reason), func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
resp, _ := proxy.RefreshPolicyInfoCache(ctx, &proxypb.RefreshPolicyInfoCacheRequest{
|
|
|
|
OpType: int32(typeutil.CacheAddUserToRole),
|
|
|
|
OpKey: funcutil.EncodeUserRoleCache("foo", "public"),
|
|
|
|
})
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
|
|
})
|
|
|
|
wg.Wait()
|
|
|
|
}
|
|
|
|
|
2021-11-09 14:47:02 +08:00
|
|
|
func Test_GetCompactionState(t *testing.T) {
|
|
|
|
t.Run("get compaction state", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.GetCompactionState(context.TODO(), nil)
|
|
|
|
assert.EqualValues(t, &milvuspb.GetCompactionStateResponse{}, resp)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("get compaction state with unhealthy proxy", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.GetCompactionState(context.TODO(), nil)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_ManualCompaction(t *testing.T) {
|
|
|
|
t.Run("test manual compaction", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.ManualCompaction(context.TODO(), nil)
|
|
|
|
assert.EqualValues(t, &milvuspb.ManualCompactionResponse{}, resp)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
t.Run("test manual compaction with unhealthy", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.ManualCompaction(context.TODO(), nil)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func Test_GetCompactionStateWithPlans(t *testing.T) {
|
|
|
|
t.Run("test get compaction state with plans", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.GetCompactionStateWithPlans(context.TODO(), nil)
|
|
|
|
assert.EqualValues(t, &milvuspb.GetCompactionPlansResponse{}, resp)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
t.Run("test get compaction state with plans with unhealthy proxy", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2021-11-09 14:47:02 +08:00
|
|
|
resp, err := proxy.GetCompactionStateWithPlans(context.TODO(), nil)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-09 14:47:02 +08:00
|
|
|
})
|
|
|
|
}
|
2021-11-19 13:57:12 +08:00
|
|
|
|
2021-11-23 10:55:14 +08:00
|
|
|
func Test_GetFlushState(t *testing.T) {
|
|
|
|
t.Run("normal test", func(t *testing.T) {
|
2023-09-12 21:07:19 +08:00
|
|
|
originCache := globalMetaCache
|
|
|
|
m := NewMockCache(t)
|
|
|
|
m.On("GetCollectionID",
|
|
|
|
mock.Anything,
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
).Return(UniqueID(1), nil)
|
|
|
|
globalMetaCache = m
|
|
|
|
defer func() {
|
|
|
|
globalMetaCache = originCache
|
|
|
|
}()
|
|
|
|
|
2021-11-23 10:55:14 +08:00
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-09-12 21:07:19 +08:00
|
|
|
resp, err := proxy.GetFlushState(context.TODO(), &milvuspb.GetFlushStateRequest{
|
|
|
|
CollectionName: "coll",
|
|
|
|
})
|
2021-11-23 10:55:14 +08:00
|
|
|
assert.EqualValues(t, &milvuspb.GetFlushStateResponse{}, resp)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-23 10:55:14 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
t.Run("test get flush state with unhealthy proxy", func(t *testing.T) {
|
|
|
|
datacoord := &DataCoordMock{}
|
|
|
|
proxy := &Proxy{dataCoord: datacoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2021-11-23 10:55:14 +08:00
|
|
|
resp, err := proxy.GetFlushState(context.TODO(), nil)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2021-11-23 10:55:14 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-11-19 13:57:12 +08:00
|
|
|
func TestProxy_GetComponentStates(t *testing.T) {
|
|
|
|
n := &Proxy{}
|
2023-10-09 10:09:33 +08:00
|
|
|
n.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-09-26 09:57:25 +08:00
|
|
|
resp, err := n.GetComponentStates(context.Background(), nil)
|
2021-11-19 13:57:12 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-11-19 13:57:12 +08:00
|
|
|
assert.Equal(t, common.NotRegisteredID, resp.State.NodeID)
|
|
|
|
n.session = &sessionutil.Session{}
|
|
|
|
n.session.UpdateRegistered(true)
|
2023-09-26 09:57:25 +08:00
|
|
|
resp, err = n.GetComponentStates(context.Background(), nil)
|
2021-11-19 13:57:12 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2021-11-19 13:57:12 +08:00
|
|
|
}
|
2021-12-08 15:17:31 +08:00
|
|
|
|
2022-04-12 13:25:34 +08:00
|
|
|
func TestProxy_Import(t *testing.T) {
|
|
|
|
var wg sync.WaitGroup
|
2022-06-02 15:34:04 +08:00
|
|
|
|
2022-04-12 13:25:34 +08:00
|
|
|
wg.Add(1)
|
2022-06-02 15:34:04 +08:00
|
|
|
t.Run("test import with unhealthy", func(t *testing.T) {
|
2022-04-12 13:25:34 +08:00
|
|
|
defer wg.Done()
|
2022-06-02 15:34:04 +08:00
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "dummy",
|
|
|
|
}
|
|
|
|
proxy := &Proxy{}
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2022-06-02 15:34:04 +08:00
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
2022-04-20 14:03:40 +08:00
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2022-06-02 15:34:04 +08:00
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("rootcoord fail", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
proxy := &Proxy{}
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-09-25 10:31:26 +08:00
|
|
|
chMgr := NewMockChannelsMgr(t)
|
2022-06-02 15:34:04 +08:00
|
|
|
proxy.chMgr = chMgr
|
|
|
|
rc := newMockRootCoord()
|
2023-09-26 09:57:25 +08:00
|
|
|
rc.ImportFunc = func(ctx context.Context, req *milvuspb.ImportRequest, opts ...grpc.CallOption) (*milvuspb.ImportResponse, error) {
|
2022-06-02 15:34:04 +08:00
|
|
|
return nil, errors.New("mock")
|
|
|
|
}
|
|
|
|
proxy.rootCoord = rc
|
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "dummy",
|
|
|
|
}
|
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotEqual(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
|
|
|
})
|
|
|
|
|
|
|
|
wg.Add(1)
|
|
|
|
t.Run("normal case", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
proxy := &Proxy{}
|
2022-10-10 15:55:22 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-09-25 10:31:26 +08:00
|
|
|
chMgr := NewMockChannelsMgr(t)
|
2022-06-02 15:34:04 +08:00
|
|
|
proxy.chMgr = chMgr
|
|
|
|
rc := newMockRootCoord()
|
2023-09-26 09:57:25 +08:00
|
|
|
rc.ImportFunc = func(ctx context.Context, req *milvuspb.ImportRequest, opts ...grpc.CallOption) (*milvuspb.ImportResponse, error) {
|
2022-06-02 15:34:04 +08:00
|
|
|
return &milvuspb.ImportResponse{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}}, nil
|
|
|
|
}
|
|
|
|
proxy.rootCoord = rc
|
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "dummy",
|
|
|
|
}
|
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2022-03-21 15:47:23 +08:00
|
|
|
})
|
2022-06-02 15:34:04 +08:00
|
|
|
|
2022-10-20 12:15:27 +08:00
|
|
|
wg.Add(1)
|
|
|
|
t.Run("illegal import options", func(t *testing.T) {
|
|
|
|
defer wg.Done()
|
|
|
|
proxy := &Proxy{}
|
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-09-25 10:31:26 +08:00
|
|
|
chMgr := NewMockChannelsMgr(t)
|
2022-10-20 12:15:27 +08:00
|
|
|
proxy.chMgr = chMgr
|
|
|
|
rc := newMockRootCoord()
|
2023-09-26 09:57:25 +08:00
|
|
|
rc.ImportFunc = func(ctx context.Context, req *milvuspb.ImportRequest, opts ...grpc.CallOption) (*milvuspb.ImportResponse, error) {
|
2022-10-20 12:15:27 +08:00
|
|
|
return &milvuspb.ImportResponse{Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success}}, nil
|
|
|
|
}
|
|
|
|
proxy.rootCoord = rc
|
|
|
|
req := &milvuspb.ImportRequest{
|
|
|
|
CollectionName: "dummy",
|
|
|
|
Options: []*commonpb.KeyValuePair{
|
|
|
|
{
|
|
|
|
Key: importutil.StartTs,
|
|
|
|
Value: "0",
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Key: importutil.EndTs,
|
|
|
|
Value: "not a number",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
resp, err := proxy.Import(context.TODO(), req)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
|
|
|
|
})
|
2022-04-12 13:25:34 +08:00
|
|
|
wg.Wait()
|
2022-03-21 15:47:23 +08:00
|
|
|
}
|
|
|
|
|
2022-04-12 13:25:34 +08:00
|
|
|
func TestProxy_GetImportState(t *testing.T) {
|
2022-03-21 15:47:23 +08:00
|
|
|
req := &milvuspb.GetImportStateRequest{
|
|
|
|
Task: 1,
|
|
|
|
}
|
|
|
|
rootCoord := &RootCoordMock{}
|
2022-10-10 15:55:22 +08:00
|
|
|
rootCoord.state.Store(commonpb.StateCode_Healthy)
|
2022-03-21 15:47:23 +08:00
|
|
|
t.Run("test get import state", func(t *testing.T) {
|
|
|
|
proxy := &Proxy{rootCoord: rootCoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-03-21 15:47:23 +08:00
|
|
|
|
|
|
|
resp, err := proxy.GetImportState(context.TODO(), req)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.EqualValues(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-21 15:47:23 +08:00
|
|
|
})
|
|
|
|
t.Run("test get import state with unhealthy", func(t *testing.T) {
|
|
|
|
proxy := &Proxy{rootCoord: rootCoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2022-03-21 15:47:23 +08:00
|
|
|
resp, err := proxy.GetImportState(context.TODO(), req)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-03-21 15:47:23 +08:00
|
|
|
})
|
|
|
|
}
|
2022-04-25 17:37:46 +08:00
|
|
|
|
|
|
|
func TestProxy_ListImportTasks(t *testing.T) {
|
|
|
|
req := &milvuspb.ListImportTasksRequest{}
|
|
|
|
rootCoord := &RootCoordMock{}
|
2022-10-10 15:55:22 +08:00
|
|
|
rootCoord.state.Store(commonpb.StateCode_Healthy)
|
2022-04-25 17:37:46 +08:00
|
|
|
t.Run("test list import tasks", func(t *testing.T) {
|
|
|
|
proxy := &Proxy{rootCoord: rootCoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-04-25 17:37:46 +08:00
|
|
|
|
|
|
|
resp, err := proxy.ListImportTasks(context.TODO(), req)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.EqualValues(t, commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-25 17:37:46 +08:00
|
|
|
})
|
|
|
|
t.Run("test list import tasks with unhealthy", func(t *testing.T) {
|
|
|
|
proxy := &Proxy{rootCoord: rootCoord}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Abnormal)
|
2022-04-25 17:37:46 +08:00
|
|
|
resp, err := proxy.ListImportTasks(context.TODO(), req)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(resp.GetStatus()), merr.ErrServiceNotReady)
|
2023-06-08 15:36:36 +08:00
|
|
|
assert.NoError(t, err)
|
2022-04-25 17:37:46 +08:00
|
|
|
})
|
|
|
|
}
|
2022-07-18 09:58:28 +08:00
|
|
|
|
|
|
|
func TestProxy_GetStatistics(t *testing.T) {
|
|
|
|
}
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
func TestProxy_GetLoadState(t *testing.T) {
|
|
|
|
originCache := globalMetaCache
|
2023-06-25 17:20:43 +08:00
|
|
|
m := NewMockCache(t)
|
|
|
|
m.On("GetCollectionID",
|
|
|
|
mock.Anything, // context.Context
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
).Return(UniqueID(1), nil)
|
|
|
|
m.On("GetPartitionID",
|
|
|
|
mock.Anything, // context.Context
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
mock.AnythingOfType("string"),
|
|
|
|
).Return(UniqueID(2), nil)
|
2022-12-16 14:39:24 +08:00
|
|
|
globalMetaCache = m
|
|
|
|
defer func() {
|
|
|
|
globalMetaCache = originCache
|
|
|
|
}()
|
|
|
|
|
|
|
|
{
|
2023-09-26 09:57:25 +08:00
|
|
|
qc := getQueryCoordClient()
|
2023-02-16 15:38:34 +08:00
|
|
|
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(&querypb.ShowCollectionsResponse{
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Status(merr.WrapErrServiceNotReady(paramtable.GetRole(), paramtable.GetNodeID(), "initialization")),
|
2023-02-16 15:38:34 +08:00
|
|
|
CollectionIDs: nil,
|
|
|
|
InMemoryPercentages: []int64{},
|
|
|
|
}, nil)
|
|
|
|
proxy := &Proxy{queryCoord: qc}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-12-16 14:39:24 +08:00
|
|
|
stateResp, err := proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-30 10:31:28 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(stateResp.GetStatus()), merr.ErrServiceNotReady)
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-30 10:31:28 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(progressResp.GetStatus()), merr.ErrServiceNotReady)
|
2022-12-16 14:39:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-09-26 09:57:25 +08:00
|
|
|
qc := getQueryCoordClient()
|
2023-09-30 10:31:28 +08:00
|
|
|
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(nil, merr.WrapErrCollectionNotLoaded("foo"))
|
|
|
|
qc.EXPECT().ShowPartitions(mock.Anything, mock.Anything).Return(nil, merr.WrapErrPartitionNotLoaded("p1"))
|
2023-02-16 15:38:34 +08:00
|
|
|
proxy := &Proxy{queryCoord: qc}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
stateResp, err := proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateNotLoad, stateResp.State)
|
|
|
|
|
|
|
|
stateResp, err = proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo", PartitionNames: []string{"p1"}})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateNotLoad, stateResp.State)
|
|
|
|
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, progressResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, int64(0), progressResp.Progress)
|
|
|
|
|
|
|
|
progressResp, err = proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo", PartitionNames: []string{"p1"}})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, progressResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, int64(0), progressResp.Progress)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-09-26 09:57:25 +08:00
|
|
|
qc := getQueryCoordClient()
|
|
|
|
qc.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
2023-02-16 15:38:34 +08:00
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: 0,
|
|
|
|
Role: typeutil.QueryCoordRole,
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-02-16 15:38:34 +08:00
|
|
|
}, nil)
|
|
|
|
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(&querypb.ShowCollectionsResponse{
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
|
|
|
CollectionIDs: nil,
|
|
|
|
InMemoryPercentages: []int64{100},
|
|
|
|
}, nil)
|
|
|
|
proxy := &Proxy{queryCoord: qc}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
stateResp, err := proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo", Base: &commonpb.MsgBase{}})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateLoaded, stateResp.State)
|
|
|
|
|
|
|
|
stateResp, err = proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: ""})
|
|
|
|
assert.NoError(t, err)
|
2023-10-09 10:09:33 +08:00
|
|
|
assert.ErrorIs(t, merr.Error(stateResp.GetStatus()), merr.ErrParameterInvalid)
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, progressResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, int64(100), progressResp.Progress)
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2023-09-26 09:57:25 +08:00
|
|
|
qc := getQueryCoordClient()
|
|
|
|
qc.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
2023-02-16 15:38:34 +08:00
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: 0,
|
|
|
|
Role: typeutil.QueryCoordRole,
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-02-16 15:38:34 +08:00
|
|
|
}, nil)
|
|
|
|
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(&querypb.ShowCollectionsResponse{
|
|
|
|
Status: &commonpb.Status{ErrorCode: commonpb.ErrorCode_Success},
|
|
|
|
CollectionIDs: nil,
|
|
|
|
InMemoryPercentages: []int64{50},
|
|
|
|
}, nil)
|
|
|
|
proxy := &Proxy{queryCoord: qc}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2022-12-16 14:39:24 +08:00
|
|
|
|
|
|
|
stateResp, err := proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, stateResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, commonpb.LoadState_LoadStateLoading, stateResp.State)
|
|
|
|
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_Success, progressResp.GetStatus().GetErrorCode())
|
2022-12-16 14:39:24 +08:00
|
|
|
assert.Equal(t, int64(50), progressResp.Progress)
|
|
|
|
}
|
2023-01-10 20:35:39 +08:00
|
|
|
|
|
|
|
t.Run("test insufficient memory", func(t *testing.T) {
|
2023-09-26 09:57:25 +08:00
|
|
|
qc := getQueryCoordClient()
|
|
|
|
qc.EXPECT().GetComponentStates(mock.Anything, mock.Anything).Return(&milvuspb.ComponentStates{
|
2023-02-16 15:38:34 +08:00
|
|
|
State: &milvuspb.ComponentInfo{
|
|
|
|
NodeID: 0,
|
|
|
|
Role: typeutil.QueryCoordRole,
|
|
|
|
StateCode: commonpb.StateCode_Healthy,
|
|
|
|
ExtraInfo: nil,
|
|
|
|
},
|
|
|
|
SubcomponentStates: nil,
|
2023-10-11 21:01:35 +08:00
|
|
|
Status: merr.Success(),
|
2023-02-16 15:38:34 +08:00
|
|
|
}, nil)
|
2023-09-30 10:31:28 +08:00
|
|
|
|
|
|
|
mockErr := merr.WrapErrServiceMemoryLimitExceeded(110, 100)
|
2023-02-16 15:38:34 +08:00
|
|
|
qc.EXPECT().ShowCollections(mock.Anything, mock.Anything).Return(&querypb.ShowCollectionsResponse{
|
2023-09-30 10:31:28 +08:00
|
|
|
Status: merr.Status(mockErr),
|
2023-02-16 15:38:34 +08:00
|
|
|
}, nil)
|
|
|
|
qc.EXPECT().ShowPartitions(mock.Anything, mock.Anything).Return(&querypb.ShowPartitionsResponse{
|
2023-09-30 10:31:28 +08:00
|
|
|
Status: merr.Status(mockErr),
|
2023-02-16 15:38:34 +08:00
|
|
|
}, nil)
|
|
|
|
proxy := &Proxy{queryCoord: qc}
|
2023-10-09 10:09:33 +08:00
|
|
|
proxy.UpdateStateCode(commonpb.StateCode_Healthy)
|
2023-01-10 20:35:39 +08:00
|
|
|
|
|
|
|
stateResp, err := proxy.GetLoadState(context.Background(), &milvuspb.GetLoadStateRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_InsufficientMemoryToLoad, stateResp.GetStatus().GetErrorCode())
|
2023-01-10 20:35:39 +08:00
|
|
|
|
|
|
|
progressResp, err := proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo"})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_InsufficientMemoryToLoad, progressResp.GetStatus().GetErrorCode())
|
2023-01-10 20:35:39 +08:00
|
|
|
|
|
|
|
progressResp, err = proxy.GetLoadingProgress(context.Background(), &milvuspb.GetLoadingProgressRequest{CollectionName: "foo", PartitionNames: []string{"p1"}})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_InsufficientMemoryToLoad, progressResp.GetStatus().GetErrorCode())
|
2023-01-10 20:35:39 +08:00
|
|
|
})
|
2022-12-16 14:39:24 +08:00
|
|
|
}
|
2023-04-23 14:50:32 +08:00
|
|
|
|
2023-05-10 09:31:19 +08:00
|
|
|
func TestUnhealthProxy_GetIndexStatistics(t *testing.T) {
|
|
|
|
// check GetIndexStatistics when proxy is unhealthy
|
2023-04-23 14:50:32 +08:00
|
|
|
factory := dependency.NewDefaultFactory(true)
|
|
|
|
ctx := context.Background()
|
|
|
|
proxy, err := NewProxy(ctx, factory)
|
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.NotNil(t, proxy)
|
|
|
|
t.Run("TestProxy_GetIndexStatistics", func(t *testing.T) {
|
|
|
|
resp, err := proxy.GetIndexStatistics(ctx, &milvuspb.GetIndexStatisticsRequest{
|
|
|
|
Base: nil,
|
|
|
|
DbName: "",
|
|
|
|
CollectionName: "hello_milvus",
|
|
|
|
IndexName: "",
|
|
|
|
})
|
|
|
|
assert.NoError(t, err)
|
2023-09-15 10:09:21 +08:00
|
|
|
assert.Equal(t, commonpb.ErrorCode_NotReadyServe, resp.GetStatus().GetErrorCode())
|
2023-04-23 14:50:32 +08:00
|
|
|
})
|
|
|
|
}
|