mirror of https://github.com/milvus-io/milvus.git
Fix typo in error message (#18688)
Signed-off-by: yangxuan <xuan.yang@zilliz.com> Signed-off-by: yangxuan <xuan.yang@zilliz.com>pull/18290/head
parent
a782ded0bd
commit
e05e9cb9b4
|
@ -95,7 +95,7 @@ func parseQueryInfo(searchParamsPair []*commonpb.KeyValuePair) (*planpb.QueryInf
|
|||
}
|
||||
topK, err := strconv.Atoi(topKStr)
|
||||
if err != nil {
|
||||
return nil, errors.New(TopKKey + " " + topKStr + " is not invalid")
|
||||
return nil, fmt.Errorf("%s [%s] is invalid", TopKKey, topKStr)
|
||||
}
|
||||
|
||||
metricType, err := funcutil.GetAttrByKeyFromRepeatedKV(MetricTypeKey, searchParamsPair)
|
||||
|
@ -114,11 +114,11 @@ func parseQueryInfo(searchParamsPair []*commonpb.KeyValuePair) (*planpb.QueryInf
|
|||
}
|
||||
roundDecimal, err := strconv.Atoi(roundDecimalStr)
|
||||
if err != nil {
|
||||
return nil, errors.New(RoundDecimalKey + " " + roundDecimalStr + " is not invalid")
|
||||
return nil, fmt.Errorf("%s [%s] is invalid, should be -1 or an integer in range [0, 6]", RoundDecimalKey, roundDecimalStr)
|
||||
}
|
||||
|
||||
if roundDecimal != -1 && (roundDecimal > 6 || roundDecimal < 0) {
|
||||
return nil, errors.New(RoundDecimalKey + " " + roundDecimalStr + " is not invalid")
|
||||
return nil, fmt.Errorf("%s [%s] is invalid, should be -1 or an integer in range [0, 6]", RoundDecimalKey, roundDecimalStr)
|
||||
}
|
||||
|
||||
return &planpb.QueryInfo{
|
||||
|
|
|
@ -217,70 +217,6 @@ func TestSearchTask_PreExecute(t *testing.T) {
|
|||
qc.ResetShowPartitionsFunc()
|
||||
})
|
||||
|
||||
t.Run("invalid key value pairs", func(t *testing.T) {
|
||||
spNoTopk := []*commonpb.KeyValuePair{{
|
||||
Key: AnnsFieldKey,
|
||||
Value: testFloatVecField}}
|
||||
|
||||
spInvalidTopk := append(spNoTopk, &commonpb.KeyValuePair{
|
||||
Key: TopKKey,
|
||||
Value: "invalid",
|
||||
})
|
||||
|
||||
spNoMetricType := append(spNoTopk, &commonpb.KeyValuePair{
|
||||
Key: TopKKey,
|
||||
Value: "10",
|
||||
})
|
||||
|
||||
spNoSearchParams := append(spNoMetricType, &commonpb.KeyValuePair{
|
||||
Key: MetricTypeKey,
|
||||
Value: distance.L2,
|
||||
})
|
||||
|
||||
spNoRoundDecimal := append(spNoSearchParams, &commonpb.KeyValuePair{
|
||||
Key: SearchParamsKey,
|
||||
Value: `{"nprobe": 10}`,
|
||||
})
|
||||
|
||||
spInvalidRoundDecimal := append(spNoRoundDecimal, &commonpb.KeyValuePair{
|
||||
Key: RoundDecimalKey,
|
||||
Value: "invalid",
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
description string
|
||||
invalidParams []*commonpb.KeyValuePair
|
||||
}{
|
||||
{"No_topk", spNoTopk},
|
||||
{"Invalid_topk", spInvalidTopk},
|
||||
{"No_Metric_type", spNoMetricType},
|
||||
{"No_search_params", spNoSearchParams},
|
||||
{"no_round_decimal", spNoRoundDecimal},
|
||||
{"Invalid_round_decimal", spInvalidRoundDecimal},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.description, func(t *testing.T) {
|
||||
collName := "collection_" + test.description
|
||||
createColl(t, collName, rc)
|
||||
collID, err := globalMetaCache.GetCollectionID(context.TODO(), collName)
|
||||
require.NoError(t, err)
|
||||
task := getSearchTask(t, collName)
|
||||
task.request.DslType = commonpb.DslType_BoolExprV1
|
||||
|
||||
status, err := qc.LoadCollection(ctx, &querypb.LoadCollectionRequest{
|
||||
Base: &commonpb.MsgBase{
|
||||
MsgType: commonpb.MsgType_LoadCollection,
|
||||
},
|
||||
CollectionID: collID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, commonpb.ErrorCode_Success, status.GetErrorCode())
|
||||
assert.Error(t, task.PreExecute(ctx))
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("search with timeout", func(t *testing.T) {
|
||||
collName := "search_with_timeout" + funcutil.GenRandomStr()
|
||||
createColl(t, collName, rc)
|
||||
|
@ -1734,3 +1670,60 @@ func TestSearchTask_ErrExecute(t *testing.T) {
|
|||
qn.withSearchResult = result1
|
||||
assert.NoError(t, task.Execute(ctx))
|
||||
}
|
||||
|
||||
func TestTaskSearch_parseQueryInfo(t *testing.T) {
|
||||
t.Run("parseQueryInfo error", func(t *testing.T) {
|
||||
spNoTopk := []*commonpb.KeyValuePair{{
|
||||
Key: AnnsFieldKey,
|
||||
Value: testFloatVecField}}
|
||||
|
||||
spInvalidTopk := append(spNoTopk, &commonpb.KeyValuePair{
|
||||
Key: TopKKey,
|
||||
Value: "invalid",
|
||||
})
|
||||
|
||||
spNoMetricType := append(spNoTopk, &commonpb.KeyValuePair{
|
||||
Key: TopKKey,
|
||||
Value: "10",
|
||||
})
|
||||
|
||||
spNoSearchParams := append(spNoMetricType, &commonpb.KeyValuePair{
|
||||
Key: MetricTypeKey,
|
||||
Value: distance.L2,
|
||||
})
|
||||
noRoundDecimal := append(spNoSearchParams, &commonpb.KeyValuePair{
|
||||
Key: SearchParamsKey,
|
||||
Value: `{"nprobe": 10}`,
|
||||
})
|
||||
|
||||
spInvalidRoundDecimal2 := append(noRoundDecimal, &commonpb.KeyValuePair{
|
||||
Key: RoundDecimalKey,
|
||||
Value: "1000",
|
||||
})
|
||||
|
||||
spInvalidRoundDecimal := append(noRoundDecimal, &commonpb.KeyValuePair{
|
||||
Key: RoundDecimalKey,
|
||||
Value: "invalid",
|
||||
})
|
||||
|
||||
tests := []struct {
|
||||
description string
|
||||
invalidParams []*commonpb.KeyValuePair
|
||||
}{
|
||||
{"No_topk", spNoTopk},
|
||||
{"Invalid_topk", spInvalidTopk},
|
||||
{"No_Metric_type", spNoMetricType},
|
||||
{"No_search_params", spNoSearchParams},
|
||||
{"Invalid_round_decimal", spInvalidRoundDecimal},
|
||||
{"Invalid_round_decimal_1000", spInvalidRoundDecimal2},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
t.Run(test.description, func(t *testing.T) {
|
||||
info, err := parseQueryInfo(test.invalidParams)
|
||||
assert.Error(t, err)
|
||||
assert.Nil(t, info)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue