test: update the max binary vector dim in test code (#31208)

issue: https://github.com/milvus-io/milvus/issues/31160

Signed-off-by: elstic <hao.wang@zilliz.com>
This commit is contained in:
elstic 2024-03-13 11:23:04 +08:00 committed by GitHub
parent f7abfa7884
commit 5b4c0bdc20
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 50 additions and 2 deletions

View File

@ -66,6 +66,7 @@ float_vec_field_desc = "float vector type field"
binary_vec_field_desc = "binary vector type field"
max_dim = 32768
min_dim = 2
max_binary_vector_dim = 262144
gracefulTime = 1
default_nlist = 128
compact_segment_num_threshold = 3

View File

@ -1711,7 +1711,7 @@ class TestCollectionCountBinary(TestcaseBase):
expected: check error message successfully
"""
self._connect()
dim = 2
dim = ct.min_dim
c_schema = cf.gen_default_binary_collection_schema(auto_id=auto_id, dim=dim)
collection_w = self.init_collection_wrap(schema=c_schema,
check_task=CheckTasks.err_res,
@ -4336,7 +4336,7 @@ class TestCollectionMultipleVectorValid(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
another_dim = 2
another_dim = ct.min_dim
schema = cf.gen_default_collection_schema(primary_field=primary_key, auto_id=auto_id, dim=ct.max_dim,
enable_dynamic_field=enable_dynamic_field,
multiple_dim_array=[another_dim])

View File

@ -4561,6 +4561,53 @@ class TestCollectionSearch(TestcaseBase):
for i in range(default_nq):
assert res1[i].ids == res2[i].ids[:limit]
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("metrics", ct.binary_metrics[:2])
@pytest.mark.parametrize("index", ["BIN_FLAT", "BIN_IVF_FLAT", "HNSW"])
@pytest.mark.parametrize("dim", [32768, 65536, ct.max_binary_vector_dim-8, ct.max_binary_vector_dim])
def test_binary_indexed_large_dim_vectors_search(self, metrics, index, dim):
"""
target: binary vector large dim search
method: binary vector large dim search
expected: search success
"""
# 1. create a collection and insert data
collection_w = self.init_collection_general(prefix, dim=dim, is_binary=True, is_index=False)[0]
data = cf.gen_default_binary_dataframe_data(nb=200, dim=dim)[0]
collection_w.insert(data)
# 2. create index and load
params = {"M": 48, "efConstruction": 500} if index == "HNSW" else {"nlist": 128}
default_index = {"index_type": index, "metric_type": metrics, "params": params}
collection_w.create_index(binary_field_name, default_index)
collection_w.load()
# 3. search with output field vector
search_params = cf.gen_search_param(index, metrics)
binary_vectors = cf.gen_binary_vectors(1, dim)[1]
for search_param in search_params:
res = collection_w.search(binary_vectors, binary_field_name,
search_param, 2, default_search_exp,
output_fields=[binary_field_name])[0]
# 4. check the result vectors should be equal to the inserted
assert res[0][0].entity.binary_vector == data[binary_field_name][res[0][0].id]
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("dim", [ct.max_binary_vector_dim + 1, ct.max_binary_vector_dim + 8])
def test_binary_indexed_over_max_dim(self, dim):
"""
target: tests exceeding the maximum binary vector dimension
method: tests exceeding the maximum binary vector dimension
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
binary_schema = cf.gen_default_binary_collection_schema(dim=dim)
self.collection_wrap.init_collection(c_name, schema=binary_schema,
check_task=CheckTasks.err_res,
check_items={"err_code": 65535, "err_msg": f"invalid dimension {dim}."})
class TestSearchBase(TestcaseBase):
@pytest.fixture(