mirror of
https://gitee.com/milvus-io/milvus.git
synced 2025-12-08 10:08:42 +08:00
Remove metric_type check and fix some minor bugs (#24921)
Signed-off-by: zhenshan.cao <zhenshan.cao@zilliz.com> Co-authored-by: zhenshan.cao <zhenshan.cao@zilliz.com>
This commit is contained in:
parent
31c08a8135
commit
c9e456c6eb
@ -579,4 +579,4 @@ trace:
|
|||||||
|
|
||||||
autoIndex:
|
autoIndex:
|
||||||
params:
|
params:
|
||||||
build: '{"M": 30,"efConstruction": 360,"index_type": "HNSW", "metric_type": "IP"}'
|
build: '{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "IP"}'
|
||||||
|
|||||||
@ -141,7 +141,7 @@ func parseSearchInfo(searchParamsPair []*commonpb.KeyValuePair) (*planpb.QueryIn
|
|||||||
|
|
||||||
metricType, err := funcutil.GetAttrByKeyFromRepeatedKV(common.MetricTypeKey, searchParamsPair)
|
metricType, err := funcutil.GetAttrByKeyFromRepeatedKV(common.MetricTypeKey, searchParamsPair)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, 0, errors.New(common.MetricTypeKey + " not found in search_params")
|
metricType = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
roundDecimalStr, err := funcutil.GetAttrByKeyFromRepeatedKV(RoundDecimalKey, searchParamsPair)
|
roundDecimalStr, err := funcutil.GetAttrByKeyFromRepeatedKV(RoundDecimalKey, searchParamsPair)
|
||||||
|
|||||||
@ -96,6 +96,19 @@ func createColl(t *testing.T, name string, rc types.RootCoord) {
|
|||||||
require.NoError(t, createColT.PostExecute(ctx))
|
require.NoError(t, createColT.PostExecute(ctx))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getBaseSearchParams() []*commonpb.KeyValuePair {
|
||||||
|
return []*commonpb.KeyValuePair{
|
||||||
|
{
|
||||||
|
Key: AnnsFieldKey,
|
||||||
|
Value: testFloatVecField,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: TopKKey,
|
||||||
|
Value: "10",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func getValidSearchParams() []*commonpb.KeyValuePair {
|
func getValidSearchParams() []*commonpb.KeyValuePair {
|
||||||
return []*commonpb.KeyValuePair{
|
return []*commonpb.KeyValuePair{
|
||||||
{
|
{
|
||||||
@ -1693,16 +1706,46 @@ func TestTaskSearch_parseQueryInfo(t *testing.T) {
|
|||||||
t.Run("parseSearchInfo no error", func(t *testing.T) {
|
t.Run("parseSearchInfo no error", func(t *testing.T) {
|
||||||
var targetOffset int64 = 200
|
var targetOffset int64 = 200
|
||||||
|
|
||||||
sp := getValidSearchParams()
|
normalParam := getValidSearchParams()
|
||||||
sp = append(sp, &commonpb.KeyValuePair{
|
|
||||||
|
noMetricTypeParams := getBaseSearchParams()
|
||||||
|
noMetricTypeParams = append(noMetricTypeParams, &commonpb.KeyValuePair{
|
||||||
|
Key: SearchParamsKey,
|
||||||
|
Value: `{"nprobe": 10}`,
|
||||||
|
})
|
||||||
|
|
||||||
|
//noSearchParams := getBaseSearchParams()
|
||||||
|
//noSearchParams = append(noSearchParams, &commonpb.KeyValuePair{
|
||||||
|
// Key: common.MetricTypeKey,
|
||||||
|
// Value: distance.L2,
|
||||||
|
//})
|
||||||
|
|
||||||
|
offsetParam := getValidSearchParams()
|
||||||
|
offsetParam = append(offsetParam, &commonpb.KeyValuePair{
|
||||||
Key: OffsetKey,
|
Key: OffsetKey,
|
||||||
Value: strconv.FormatInt(targetOffset, 10),
|
Value: strconv.FormatInt(targetOffset, 10),
|
||||||
})
|
})
|
||||||
|
|
||||||
info, offset, err := parseSearchInfo(sp)
|
tests := []struct {
|
||||||
|
description string
|
||||||
|
validParams []*commonpb.KeyValuePair
|
||||||
|
}{
|
||||||
|
{"noMetricType", noMetricTypeParams},
|
||||||
|
//{"noSearchParams", noSearchParams},
|
||||||
|
{"normal", normalParam},
|
||||||
|
{"offsetParam", offsetParam},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, test := range tests {
|
||||||
|
t.Run(test.description, func(t *testing.T) {
|
||||||
|
info, offset, err := parseSearchInfo(test.validParams)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
assert.NotNil(t, info)
|
assert.NotNil(t, info)
|
||||||
|
if test.description == "offsetParam" {
|
||||||
assert.Equal(t, targetOffset, offset)
|
assert.Equal(t, targetOffset, offset)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
t.Run("parseSearchInfo error", func(t *testing.T) {
|
t.Run("parseSearchInfo error", func(t *testing.T) {
|
||||||
@ -1774,8 +1817,6 @@ func TestTaskSearch_parseQueryInfo(t *testing.T) {
|
|||||||
{"Invalid_topk", spInvalidTopk},
|
{"Invalid_topk", spInvalidTopk},
|
||||||
{"Invalid_topk_65536", spInvalidTopk65536},
|
{"Invalid_topk_65536", spInvalidTopk65536},
|
||||||
{"Invalid_topk_plus_offset", spInvalidTopkPlusOffset},
|
{"Invalid_topk_plus_offset", spInvalidTopkPlusOffset},
|
||||||
{"No_Metric_type", spNoMetricType},
|
|
||||||
{"No_search_params", spNoSearchParams},
|
|
||||||
{"Invalid_round_decimal", spInvalidRoundDecimal},
|
{"Invalid_round_decimal", spInvalidRoundDecimal},
|
||||||
{"Invalid_round_decimal_1000", spInvalidRoundDecimal2},
|
{"Invalid_round_decimal_1000", spInvalidRoundDecimal2},
|
||||||
{"Invalid_offset_not_int", spInvalidOffsetNoInt},
|
{"Invalid_offset_not_int", spInvalidOffsetNoInt},
|
||||||
|
|||||||
@ -49,7 +49,7 @@ func (p *autoIndexConfig) init(base *BaseTable) {
|
|||||||
p.IndexParams = ParamItem{
|
p.IndexParams = ParamItem{
|
||||||
Key: "autoIndex.params.build",
|
Key: "autoIndex.params.build",
|
||||||
Version: "2.2.0",
|
Version: "2.2.0",
|
||||||
DefaultValue: `{"M": 30,"efConstruction": 360,"index_type": "HNSW", "metric_type": "IP"}`,
|
DefaultValue: `{"M": 18,"efConstruction": 240,"index_type": "HNSW", "metric_type": "IP"}`,
|
||||||
}
|
}
|
||||||
p.IndexParams.Init(base.mgr)
|
p.IndexParams.Init(base.mgr)
|
||||||
|
|
||||||
|
|||||||
@ -101,6 +101,21 @@ get_invalid_strs = [
|
|||||||
"%$#",
|
"%$#",
|
||||||
"".join("a" for i in range(max_name_length + 1))]
|
"".join("a" for i in range(max_name_length + 1))]
|
||||||
|
|
||||||
|
get_invalid_type_fields = [
|
||||||
|
1,
|
||||||
|
[1, "2", 3],
|
||||||
|
(1,),
|
||||||
|
{1: 1},
|
||||||
|
None,
|
||||||
|
"",
|
||||||
|
" ",
|
||||||
|
"12-s",
|
||||||
|
"12 s",
|
||||||
|
"(mn)",
|
||||||
|
"中文",
|
||||||
|
"%$#",
|
||||||
|
"".join("a" for i in range(max_name_length + 1))]
|
||||||
|
|
||||||
get_not_string = [
|
get_not_string = [
|
||||||
[],
|
[],
|
||||||
{},
|
{},
|
||||||
@ -174,7 +189,6 @@ get_invalid_metric_type = [
|
|||||||
[1, "2", 3],
|
[1, "2", 3],
|
||||||
(1,),
|
(1,),
|
||||||
{1: 1},
|
{1: 1},
|
||||||
None,
|
|
||||||
" ",
|
" ",
|
||||||
"12-s",
|
"12-s",
|
||||||
"12 s",
|
"12 s",
|
||||||
|
|||||||
@ -12,7 +12,7 @@ allure-pytest==2.7.0
|
|||||||
pytest-print==0.2.1
|
pytest-print==0.2.1
|
||||||
pytest-level==0.1.1
|
pytest-level==0.1.1
|
||||||
pytest-xdist==2.5.0
|
pytest-xdist==2.5.0
|
||||||
pymilvus==2.4.0.dev67
|
pymilvus==2.4.0.dev73
|
||||||
pytest-rerunfailures==9.1.1
|
pytest-rerunfailures==9.1.1
|
||||||
git+https://github.com/Projectplace/pytest-tags
|
git+https://github.com/Projectplace/pytest-tags
|
||||||
ndg-httpsclient
|
ndg-httpsclient
|
||||||
|
|||||||
@ -59,7 +59,7 @@ class TestCollectionParams(TestcaseBase):
|
|||||||
pytest.skip("None schema is valid")
|
pytest.skip("None schema is valid")
|
||||||
yield request.param
|
yield request.param
|
||||||
|
|
||||||
@pytest.fixture(scope="function", params=ct.get_invalid_strs)
|
@pytest.fixture(scope="function", params=ct.get_invalid_type_fields)
|
||||||
def get_invalid_type_fields(self, request):
|
def get_invalid_type_fields(self, request):
|
||||||
if isinstance(request.param, list):
|
if isinstance(request.param, list):
|
||||||
pytest.skip("list is valid fields")
|
pytest.skip("list is valid fields")
|
||||||
@ -734,10 +734,9 @@ class TestCollectionParams(TestcaseBase):
|
|||||||
self._connect()
|
self._connect()
|
||||||
int_field = cf.gen_int64_field(is_primary=True, auto_id=True)
|
int_field = cf.gen_int64_field(is_primary=True, auto_id=True)
|
||||||
vec_field = cf.gen_float_vec_field(name='vec')
|
vec_field = cf.gen_float_vec_field(name='vec')
|
||||||
error = {ct.err_code: 0, ct.err_msg: "The auto_id of the collection is inconsistent with "
|
|
||||||
"the auto_id of the primary key field"}
|
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=False)
|
||||||
self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=False,
|
assert schema.auto_id
|
||||||
check_task=CheckTasks.err_res, check_items=error)
|
|
||||||
|
|
||||||
@pytest.mark.tags(CaseLabel.L2)
|
@pytest.mark.tags(CaseLabel.L2)
|
||||||
@pytest.mark.parametrize("auto_id", [True, False])
|
@pytest.mark.parametrize("auto_id", [True, False])
|
||||||
@ -3759,13 +3758,9 @@ class TestCollectionString(TestcaseBase):
|
|||||||
vec_field = cf.gen_float_vec_field()
|
vec_field = cf.gen_float_vec_field()
|
||||||
string_field = cf.gen_string_field(is_primary=True, auto_id=True)
|
string_field = cf.gen_string_field(is_primary=True, auto_id=True)
|
||||||
fields = [int_field, string_field, vec_field]
|
fields = [int_field, string_field, vec_field]
|
||||||
schema, _ = self.collection_schema_wrap.init_collection_schema(fields=fields)
|
error = {ct.err_code: 0, ct.err_msg: "The auto_id can only be specified on field with DataType.INT64"}
|
||||||
# error = {ct.err_code: 0, ct.err_msg: "autoID is not supported when the VarChar field is the primary key"}
|
self.collection_schema_wrap.init_collection_schema(fields=fields,
|
||||||
c_name = cf.gen_unique_str(prefix)
|
check_task=CheckTasks.err_res, check_items=error)
|
||||||
self.collection_wrap.init_collection(name=c_name, schema=schema,
|
|
||||||
check_task=CheckTasks.check_collection_property,
|
|
||||||
check_items={exp_name: c_name, exp_schema: schema})
|
|
||||||
|
|
||||||
|
|
||||||
class TestCollectionJSON(TestcaseBase):
|
class TestCollectionJSON(TestcaseBase):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user