query_coord_test.go 2.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// 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.

12
package querycoord
X
xige-16 已提交
13 14 15 16 17 18

import (
	"context"
	"testing"

	"github.com/stretchr/testify/assert"
19

X
Xiangyu Wang 已提交
20 21
	"github.com/milvus-io/milvus/internal/msgstream"
	"github.com/milvus-io/milvus/internal/proto/querypb"
X
xige-16 已提交
22 23
)

24
func TestQueryCoord_Init(t *testing.T) {
G
godchen 已提交
25
	ctx := context.Background()
X
Xiangyu Wang 已提交
26
	msFactory := msgstream.NewPmsFactory()
27
	service, err := NewQueryCoord(context.Background(), msFactory)
X
xige-16 已提交
28 29 30 31 32
	assert.Nil(t, err)
	service.Init()
	service.Start()

	t.Run("Test create channel", func(t *testing.T) {
33 34
		request := &querypb.CreateQueryChannelRequest{}
		response, err := service.CreateQueryChannel(ctx, request)
X
xige-16 已提交
35 36 37 38 39 40
		assert.Nil(t, err)
		assert.Equal(t, response.RequestChannel, "query-0")
		assert.Equal(t, response.ResultChannel, "queryResult-0")
	})

	t.Run("Test Get statistics channel", func(t *testing.T) {
G
godchen 已提交
41
		response, err := service.GetStatisticsChannel(ctx)
X
xige-16 已提交
42 43 44 45 46
		assert.Nil(t, err)
		assert.Equal(t, response, "query-node-stats")
	})

	t.Run("Test Get timeTick channel", func(t *testing.T) {
G
godchen 已提交
47
		response, err := service.GetTimeTickChannel(ctx)
X
xige-16 已提交
48 49 50 51 52 53
		assert.Nil(t, err)
		assert.Equal(t, response, "queryTimeTick")
	})

	service.Stop()
}
54

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
//func TestQueryCoord_load(t *testing.T) {
//	ctx := context.Background()
//	msFactory := msgstream.NewPmsFactory()
//	service, err := NewQueryCoord(context.Background(), msFactory)
//	assert.Nil(t, err)
//	service.Init()
//	service.Start()
//	service.SetRootCoord(NewRootCoordMock())
//	service.SetDataCoord(NewDataMock())
//	registerNodeRequest := &querypb.RegisterNodeRequest{
//		Address: &commonpb.Address{},
//	}
//	service.RegisterNode(ctx, registerNodeRequest)
//
//	t.Run("Test LoadSegment", func(t *testing.T) {
//		loadCollectionRequest := &querypb.LoadCollectionRequest{
//			CollectionID: 1,
//		}
//		response, err := service.LoadCollection(ctx, loadCollectionRequest)
//		assert.Nil(t, err)
//		assert.Equal(t, response.ErrorCode, commonpb.ErrorCode_Success)
//	})
//
//	t.Run("Test LoadPartition", func(t *testing.T) {
//		loadPartitionRequest := &querypb.LoadPartitionsRequest{
//			CollectionID: 1,
//			PartitionIDs: []UniqueID{1},
//		}
//		response, err := service.LoadPartitions(ctx, loadPartitionRequest)
//		assert.Nil(t, err)
//		assert.Equal(t, response.ErrorCode, commonpb.ErrorCode_Success)
//	})
//}