Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Liu <wei.liu@zilliz.com>
  • Loading branch information
weiliu1031 committed Jul 4, 2024
1 parent a8acb7f commit 2231e62
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
21 changes: 13 additions & 8 deletions internal/querycoordv2/meta/coordinator_broker.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,17 @@ func (broker *CoordinatorBroker) GetCollectionLoadInfo(ctx context.Context, coll
return nil, 0, err
}

log.Info("collection props", zap.Any("xxx", collectionInfo.GetProperties()))
replicaNum, err := common.CollectionLevelReplicaNumber(collectionInfo.GetProperties())
if replicaNum > 0 {
if err != nil {
log.Warn("failed to get collection level load info", zap.Int64("collectionID", collectionID), zap.Error(err))
} else if replicaNum > 0 {
log.Info("get collection level load info", zap.Int64("collectionID", collectionID), zap.Int64("replica_num", replicaNum))
}

rgs, err := common.CollectionLevelResourceGroups(collectionInfo.GetProperties())
if len(rgs) > 0 {
if err != nil {
log.Warn("failed to get collection level load info", zap.Int64("collectionID", collectionID), zap.Error(err))
} else if len(rgs) > 0 {
log.Info("get collection level load info", zap.Int64("collectionID", collectionID), zap.Strings("resource_groups", rgs))
}

Expand All @@ -128,19 +131,21 @@ func (broker *CoordinatorBroker) GetCollectionLoadInfo(ctx context.Context, coll
if err != nil {
return nil, 0, err

Check warning on line 132 in internal/querycoordv2/meta/coordinator_broker.go

View check run for this annotation

Codecov / codecov/patch

internal/querycoordv2/meta/coordinator_broker.go#L132

Added line #L132 was not covered by tests
}
log.Info("database props", zap.Any("xxx", dbInfo.GetProperties()))
log.Info("xxx", zap.Int64("replicaNumber", replicaNum))
log.Info("xxx", zap.Strings("rgs", rgs))

if replicaNum <= 0 {
replicaNum, err = common.DatabaseLevelReplicaNumber(dbInfo.GetProperties())
if replicaNum > 0 {
if err != nil {
log.Warn("failed to get database level load info", zap.Int64("collectionID", collectionID), zap.Error(err))
} else if replicaNum > 0 {
log.Info("get database level load info", zap.Int64("collectionID", collectionID), zap.Int64("replica_num", replicaNum))
}
}

if len(rgs) == 0 {
rgs, err = common.DatabaseLevelResourceGroups(dbInfo.GetProperties())
if len(rgs) > 0 {
if err != nil {
log.Warn("failed to get database level load info", zap.Int64("collectionID", collectionID), zap.Error(err))
} else if len(rgs) > 0 {
log.Info("get database level load info", zap.Int64("collectionID", collectionID), zap.Strings("resource_groups", rgs))
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/querycoordv2/meta/coordinator_broker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ func (s *CoordinatorBrokerRootCoordSuite) TestGetCollectionLoadInfo() {
Properties: []*commonpb.KeyValuePair{},
}, nil)
_, _, err := s.broker.GetCollectionLoadInfo(ctx, 1)
s.Error(err)
s.NoError(err)
s.resetMock()
})
}
Expand Down

0 comments on commit 2231e62

Please sign in to comment.