mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 20:09:57 +08:00
b99b65c26e
Resolves #16619 Add reference count for each search/query request For SegmentChangeInfo - Wait all segments in OnlineList to be loaded - Add handoff event into pending list - Wait all segments in OfflineList is not used (reference count = 0) Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package querynode
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/milvus-io/milvus/internal/proto/querypb"
|
|
"github.com/milvus-io/milvus/internal/util/sessionutil"
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
"go.etcd.io/etcd/server/v3/etcdserver/api/v3client"
|
|
)
|
|
|
|
func TestShardClusterService(t *testing.T) {
|
|
client := v3client.New(embedetcdServer.Server)
|
|
defer client.Close()
|
|
session := sessionutil.NewSession(context.Background(), "/by-dev/sessions/unittest/querynode/", client)
|
|
clusterService := newShardClusterService(client, session, nil)
|
|
|
|
assert.NotPanics(t, func() {
|
|
clusterService.addShardCluster(defaultCollectionID, defaultReplicaID, defaultDMLChannel)
|
|
})
|
|
|
|
shardCluster, ok := clusterService.getShardCluster(defaultDMLChannel)
|
|
assert.True(t, ok)
|
|
assert.NotNil(t, shardCluster)
|
|
|
|
_, ok = clusterService.getShardCluster("non-exist-channel")
|
|
assert.False(t, ok)
|
|
|
|
err := clusterService.releaseShardCluster(defaultDMLChannel)
|
|
assert.NoError(t, err)
|
|
|
|
err = clusterService.releaseShardCluster("non-exist-channel")
|
|
assert.Error(t, err)
|
|
}
|
|
|
|
func TestShardClusterService_HandoffSegments(t *testing.T) {
|
|
qn, err := genSimpleQueryNode(context.Background())
|
|
require.NoError(t, err)
|
|
|
|
client := v3client.New(embedetcdServer.Server)
|
|
defer client.Close()
|
|
session := sessionutil.NewSession(context.Background(), "/by-dev/sessions/unittest/querynode/", client)
|
|
clusterService := newShardClusterService(client, session, qn)
|
|
|
|
clusterService.addShardCluster(defaultCollectionID, defaultReplicaID, defaultDMLChannel)
|
|
//TODO change shardCluster to interface to mock test behavior
|
|
assert.NotPanics(t, func() {
|
|
clusterService.HandoffSegments(defaultCollectionID, &querypb.SegmentChangeInfo{})
|
|
})
|
|
}
|