mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-05 13:28:49 +08:00
e6e03fc93f
Signed-off-by: cai.zhang <cai.zhang@zilliz.com>
111 lines
3.5 KiB
Go
111 lines
3.5 KiB
Go
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
|
//
|
|
// Licensed 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.
|
|
|
|
package grpcindexcoord
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/milvus-io/milvus/internal/indexcoord"
|
|
"github.com/milvus-io/milvus/internal/proto/commonpb"
|
|
"github.com/milvus-io/milvus/internal/proto/indexpb"
|
|
"github.com/milvus-io/milvus/internal/proto/internalpb"
|
|
"github.com/milvus-io/milvus/internal/proto/milvuspb"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIndexCoordinateServer(t *testing.T) {
|
|
ctx := context.Background()
|
|
indexCoord, err := NewServer(ctx)
|
|
assert.Nil(t, err)
|
|
assert.NotNil(t, indexCoord)
|
|
indexCoordClient := &indexcoord.Mock{}
|
|
err = indexCoord.SetClient(indexCoordClient)
|
|
assert.Nil(t, err)
|
|
err = indexCoord.Run()
|
|
assert.Nil(t, err)
|
|
|
|
t.Run("GetComponentStates", func(t *testing.T) {
|
|
req := &internalpb.GetComponentStatesRequest{}
|
|
states, err := indexCoord.GetComponentStates(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, internalpb.StateCode_Healthy, states.State.StateCode)
|
|
})
|
|
|
|
t.Run("GetTimeTickChannel", func(t *testing.T) {
|
|
req := &internalpb.GetTimeTickChannelRequest{}
|
|
resp, err := indexCoord.GetTimeTickChannel(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
})
|
|
|
|
t.Run("GetStatisticsChannel", func(t *testing.T) {
|
|
req := &internalpb.GetStatisticsChannelRequest{}
|
|
resp, err := indexCoord.GetStatisticsChannel(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
})
|
|
|
|
t.Run("BuildIndex", func(t *testing.T) {
|
|
req := &indexpb.BuildIndexRequest{
|
|
IndexBuildID: 0,
|
|
IndexID: 0,
|
|
DataPaths: []string{},
|
|
}
|
|
resp, err := indexCoord.BuildIndex(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
})
|
|
|
|
t.Run("GetIndexStates", func(t *testing.T) {
|
|
req := &indexpb.GetIndexStatesRequest{
|
|
IndexBuildIDs: []UniqueID{0},
|
|
}
|
|
resp, err := indexCoord.GetIndexStates(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, len(req.IndexBuildIDs), len(resp.States))
|
|
assert.Equal(t, commonpb.IndexState_Finished, resp.States[0].State)
|
|
})
|
|
|
|
t.Run("DropIndex", func(t *testing.T) {
|
|
req := &indexpb.DropIndexRequest{
|
|
IndexID: 0,
|
|
}
|
|
resp, err := indexCoord.DropIndex(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.ErrorCode)
|
|
})
|
|
|
|
t.Run("GetIndexFilePaths", func(t *testing.T) {
|
|
req := &indexpb.GetIndexFilePathsRequest{
|
|
IndexBuildIDs: []UniqueID{0, 1},
|
|
}
|
|
resp, err := indexCoord.GetIndexFilePaths(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
assert.Equal(t, len(req.IndexBuildIDs), len(resp.FilePaths))
|
|
})
|
|
|
|
t.Run("GetMetrics", func(t *testing.T) {
|
|
req := &milvuspb.GetMetricsRequest{
|
|
Request: "",
|
|
}
|
|
resp, err := indexCoord.GetMetrics(ctx, req)
|
|
assert.Nil(t, err)
|
|
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
|
assert.Equal(t, "IndexCoord", resp.ComponentName)
|
|
})
|
|
|
|
err = indexCoord.Stop()
|
|
assert.Nil(t, err)
|
|
}
|