Return error response instead of panicking for unimplemented APIs (#26589)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/26604/head
congqixia 2023-08-24 09:14:23 +08:00 committed by GitHub
parent 8d3398c1fa
commit c2b53bb9fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 2 deletions

View File

@ -1099,11 +1099,21 @@ func (s *Server) ListResourceGroups(ctx context.Context, req *milvuspb.ListResou
}
func (s *Server) ListIndexedSegment(ctx context.Context, req *federpb.ListIndexedSegmentRequest) (*federpb.ListIndexedSegmentResponse, error) {
panic("TODO: implement me")
return &federpb.ListIndexedSegmentResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: "not implemented",
},
}, nil
}
func (s *Server) DescribeSegmentIndexData(ctx context.Context, req *federpb.DescribeSegmentIndexDataRequest) (*federpb.DescribeSegmentIndexDataResponse, error) {
panic("TODO: implement me")
return &federpb.DescribeSegmentIndexDataResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: "not implemented",
},
}, nil
}
func (s *Server) Connect(ctx context.Context, req *milvuspb.ConnectRequest) (*milvuspb.ConnectResponse, error) {

View File

@ -42,6 +42,7 @@ import (
"google.golang.org/grpc/health/grpc_health_v1"
"github.com/milvus-io/milvus-proto/go-api/v2/commonpb"
"github.com/milvus-io/milvus-proto/go-api/v2/federpb"
"github.com/milvus-io/milvus-proto/go-api/v2/milvuspb"
"github.com/milvus-io/milvus/internal/mocks"
"github.com/milvus-io/milvus/internal/proto/datapb"
@ -1717,3 +1718,25 @@ func Test_NewServer_GetVersion(t *testing.T) {
assert.NoError(t, err)
})
}
func TestNotImplementedAPIs(t *testing.T) {
server := getServer(t)
t.Run("ListIndexedSegment", func(t *testing.T) {
assert.NotPanics(t, func() {
resp, err := server.ListIndexedSegment(context.TODO(), &federpb.ListIndexedSegmentRequest{})
assert.NoError(t, err)
assert.NotNil(t, resp)
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
})
})
t.Run("DescribeSegmentIndexData", func(t *testing.T) {
assert.NotPanics(t, func() {
resp, err := server.DescribeSegmentIndexData(context.TODO(), &federpb.DescribeSegmentIndexDataRequest{})
assert.NoError(t, err)
assert.NotNil(t, resp)
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.GetStatus().GetErrorCode())
})
})
}