mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-12-02 11:59:00 +08:00
Refine test case for multiple vectors (#12855)
Signed-off-by: Binbin Lv <binbin.lv@zilliz.com>
This commit is contained in:
parent
de00aa038a
commit
290b51dc5d
@ -421,20 +421,24 @@ class TestCollectionParams(TestcaseBase):
|
||||
error = {ct.err_code: 0, ct.err_msg: "Primary field must in dataframe"}
|
||||
self.collection_schema_wrap.init_collection_schema([field], check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680")
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_collection_multi_float_vectors(self):
|
||||
"""
|
||||
target: test collection with multi float vectors
|
||||
method: create collection with two float-vec fields
|
||||
expected: raise exception
|
||||
expected: raise exception (not supported yet)
|
||||
"""
|
||||
# 1. connect
|
||||
self._connect()
|
||||
# 2. create collection with multiple vectors
|
||||
c_name = cf.gen_unique_str(prefix)
|
||||
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_vec_field(), cf.gen_float_vec_field(name="tmp")]
|
||||
schema = cf.gen_collection_schema(fields=fields, auto_id=True)
|
||||
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: c_name, exp_schema: schema})
|
||||
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_field(),
|
||||
cf.gen_float_vec_field(dim=default_dim), cf.gen_float_vec_field(name="tmp", dim=default_dim)]
|
||||
schema = cf.gen_collection_schema(fields=fields)
|
||||
err_msg = "multiple vector fields is not supported"
|
||||
self.collection_wrap.init_collection(c_name, schema=schema,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={"err_code": 1, "err_msg": err_msg})[0]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip("https://github.com/milvus-io/milvus/issues/12680")
|
||||
|
@ -782,7 +782,6 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
||||
check_items={"err_code": 1,
|
||||
"err_msg": f"`round_decimal` value {round_decimal} is illegal"})
|
||||
|
||||
|
||||
class TestCollectionSearch(TestcaseBase):
|
||||
""" Test case of search interface """
|
||||
|
||||
@ -1424,54 +1423,6 @@ class TestCollectionSearch(TestcaseBase):
|
||||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_multiple_vectors(self, nb, nq, dim, auto_id, _async):
|
||||
"""
|
||||
target: test search with multiple vectors
|
||||
method: create connection, collection with multiple
|
||||
vectors, insert and search
|
||||
expected: search successfully with limit(topK)
|
||||
"""
|
||||
# 1. connect
|
||||
self._connect()
|
||||
# 2. create collection with multiple vectors
|
||||
c_name = cf.gen_unique_str(prefix)
|
||||
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_field(),
|
||||
cf.gen_float_vec_field(dim=dim), cf.gen_float_vec_field(name="tmp", dim=dim)]
|
||||
schema = cf.gen_collection_schema(fields=fields, auto_id=auto_id)
|
||||
collection_w = self.collection_wrap.init_collection(c_name, schema=schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={"name": c_name, "schema": schema})[0]
|
||||
# 3. insert
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nb)]
|
||||
vectors_tmp = [[random.random() for _ in range(dim)] for _ in range(nb)]
|
||||
data = [[i for i in range(nb)], [np.float32(i) for i in range(nb)], vectors, vectors_tmp]
|
||||
if auto_id:
|
||||
data = [[np.float32(i) for i in range(nb)], vectors, vectors_tmp]
|
||||
res = collection_w.insert(data)
|
||||
insert_ids = res.primary_keys
|
||||
assert collection_w.num_entities == nb
|
||||
# 4. load
|
||||
collection_w.load()
|
||||
# 5. search all the vectors
|
||||
log.info("test_search_multiple_vectors: searching collection %s" % collection_w.name)
|
||||
collection_w.search(vectors[:nq], default_search_field,
|
||||
default_search_params, default_limit,
|
||||
default_search_exp, _async=_async,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
collection_w.search(vectors[:nq], "tmp",
|
||||
default_search_params, default_limit,
|
||||
default_search_exp, _async=_async,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip(reason="issue #12680")
|
||||
# TODO: add one more for binary vectors
|
||||
|
Loading…
Reference in New Issue
Block a user