fix get partition progress return wrong error msg (#24899)

Signed-off-by: Wei Liu <wei.liu@zilliz.com>
This commit is contained in:
wei liu 2023-06-15 11:14:39 +08:00 committed by GitHub
parent db31e88a73
commit 59457eb75b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -1191,6 +1191,16 @@ func getPartitionProgress(
)
return
}
if resp.GetStatus().GetErrorCode() != commonpb.ErrorCode_Success {
err = merr.Error(resp.GetStatus())
log.Warn("fail to show partitions",
zap.String("collection_name", collectionName),
zap.Strings("partition_names", partitionNames),
zap.String("reason", resp.Status.Reason))
return
}
if len(resp.InMemoryPercentages) != len(partitionIDs) {
errMsg := "fail to show partitions from the querycoord, invalid data num"
err = errors.New(errMsg)

View File

@ -1765,3 +1765,15 @@ func Test_TopKLimit(t *testing.T) {
assert.Error(t, validateTopKLimit(16385))
assert.Error(t, validateTopKLimit(0))
}
func Test_GetPartitionProgressFailed(t *testing.T) {
qc := types.NewMockQueryCoord(t)
qc.EXPECT().ShowPartitions(mock.Anything, mock.Anything).Return(&querypb.ShowPartitionsResponse{
Status: &commonpb.Status{
ErrorCode: commonpb.ErrorCode_UnexpectedError,
Reason: "Unexpected error",
},
}, nil)
_, _, err := getPartitionProgress(context.TODO(), qc, &commonpb.MsgBase{}, []string{}, "", 1)
assert.Error(t, err)
}