From 4b12cb8847fb54cd6d2d026e028f1ad7b62cca9f Mon Sep 17 00:00:00 2001 From: MrPresent-Han <116052805+MrPresent-Han@users.noreply.github.com> Date: Fri, 22 Sep 2023 19:07:26 +0800 Subject: [PATCH] fix unstable ut due to unstable sort of unique set (#27302) Signed-off-by: MrPresent-Han --- internal/querycoordv2/services_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/internal/querycoordv2/services_test.go b/internal/querycoordv2/services_test.go index 113266a10f..57d5750ab2 100644 --- a/internal/querycoordv2/services_test.go +++ b/internal/querycoordv2/services_test.go @@ -19,6 +19,7 @@ package querycoordv2 import ( "context" "encoding/json" + "sort" "testing" "time" @@ -1768,7 +1769,7 @@ func (suite *ServiceSuite) updateChannelDist(collection int64) { replicas := suite.meta.ReplicaManager.GetByCollection(collection) for _, replica := range replicas { i := 0 - for _, node := range replica.GetNodes() { + for _, node := range suite.sortInt64(replica.GetNodes()) { suite.dist.ChannelDistManager.Update(node, meta.DmChannelFromVChannel(&datapb.VchannelInfo{ CollectionID: collection, ChannelName: channels[i], @@ -1792,13 +1793,20 @@ func (suite *ServiceSuite) updateChannelDist(collection int64) { } } +func (suite *ServiceSuite) sortInt64(ints []int64) []int64 { + sort.Slice(ints, func(i int, j int) bool { + return ints[i] < ints[j] + }) + return ints +} + func (suite *ServiceSuite) updateChannelDistWithoutSegment(collection int64) { channels := suite.channels[collection] replicas := suite.meta.ReplicaManager.GetByCollection(collection) for _, replica := range replicas { i := 0 - for _, node := range replica.GetNodes() { + for _, node := range suite.sortInt64(replica.GetNodes()) { suite.dist.ChannelDistManager.Update(node, meta.DmChannelFromVChannel(&datapb.VchannelInfo{ CollectionID: collection, ChannelName: channels[i],