mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
Add test cases of index annoy (#21220)
Signed-off-by: nico <cheng.yuan@zilliz.com> Signed-off-by: nico <cheng.yuan@zilliz.com>
This commit is contained in:
parent
1518baacd1
commit
37152d58bb
@ -536,6 +536,7 @@ def gen_normal_expressions():
|
||||
]
|
||||
return expressions
|
||||
|
||||
|
||||
def gen_field_compare_expressions():
|
||||
expressions = [
|
||||
"int64_1 | int64_2 == 1",
|
||||
@ -551,6 +552,7 @@ def gen_field_compare_expressions():
|
||||
]
|
||||
return expressions
|
||||
|
||||
|
||||
def gen_normal_string_expressions(field):
|
||||
expressions = [
|
||||
f"\"0\"< {field} < \"3\"",
|
||||
|
@ -1264,6 +1264,22 @@ class TestIndexInvalid(TestcaseBase):
|
||||
"err_msg": "index cannot be dropped, collection is "
|
||||
"loaded, please release it first"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("n_trees", [-1, 1025, 'a', {34}])
|
||||
def test_annoy_index_with_invalid_params(self, n_trees):
|
||||
"""
|
||||
target: test create index with invalid params
|
||||
method: 1. set annoy index param n_trees out of range [1, 1024]
|
||||
2. set annoy index param n_trees type invalid(not int)
|
||||
expected: raise exception
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, True, is_index=True)[0]
|
||||
index_annoy = {"index_type": "ANNOY", "params": {"n_trees": n_trees}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", index_annoy,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": "invalid index params"})
|
||||
|
||||
|
||||
class TestNewIndexAsync(TestcaseBase):
|
||||
@pytest.fixture(scope="function", params=[False, True])
|
||||
@ -1553,7 +1569,8 @@ class TestIndexString(TestcaseBase):
|
||||
assert collection_w.has_index(index_name=index_name2)[0] == True
|
||||
collection_w.drop_index(index_name=index_name2)
|
||||
assert len(collection_w.indexes) == 0
|
||||
|
||||
|
||||
|
||||
class TestIndexDiskann(TestcaseBase):
|
||||
"""
|
||||
******************************************************************
|
||||
@ -1835,4 +1852,4 @@ class TestIndexDiskann(TestcaseBase):
|
||||
collection_w.create_index(default_float_vec_field_name, ct.default_diskann_index,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1,
|
||||
ct.err_msg: "invalid index params"})
|
||||
ct.err_msg: "invalid index params"})
|
||||
|
@ -330,6 +330,30 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": message})
|
||||
|
||||
@pytest.mark.skip("not fixed yet")
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("search_k", [-10, -1, 0, 10, 125])
|
||||
def test_search_param_invalid_annoy_index(self, search_k):
|
||||
"""
|
||||
target: test search with invalid search params matched with annoy index
|
||||
method: search with invalid param search_k out of [top_k, ∞)
|
||||
expected: raise exception and report the error
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix, True, 3000, is_index=True)[0]
|
||||
# 2. create annoy index and load
|
||||
index_annoy = {"index_type": "ANNOY", "params": {"n_trees": 512}, "metric_type": "L2"}
|
||||
collection_w.create_index("float_vector", index_annoy)
|
||||
collection_w.load()
|
||||
# 3. search
|
||||
annoy_search_param = {"index_type": "ANNOY", "search_params": {"search_k": search_k}}
|
||||
collection_w.search(vectors[:default_nq], default_search_field,
|
||||
annoy_search_param, default_limit,
|
||||
default_search_exp,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": "Search params check failed"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_param_invalid_limit_type(self, get_invalid_limit):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user