未验证 提交 a9cbf433 编写于 作者: N nico 提交者: GitHub

Add cases about offset and alias (#26067)

Signed-off-by: Nnico <cheng.yuan@zilliz.com>
上级 c0870d3c
......@@ -12,7 +12,7 @@ allure-pytest==2.7.0
pytest-print==0.2.1
pytest-level==0.1.1
pytest-xdist==2.5.0
pymilvus==2.4.0.dev109
pymilvus==2.4.0.dev115
pytest-rerunfailures==9.1.1
git+https://github.com/Projectplace/pytest-tags
ndg-httpsclient
......
......@@ -3805,7 +3805,8 @@ class TestCollectionString(TestcaseBase):
schema = self.collection_schema_wrap.init_collection_schema(fields=fields)[0]
self.init_collection_wrap(schema=schema, check_task=CheckTasks.check_collection_property,
check_items={"schema": schema, "primary": ct.default_string_field_name})
class TestCollectionJSON(TestcaseBase):
"""
******************************************************************
......@@ -3884,5 +3885,3 @@ class TestCollectionJSON(TestcaseBase):
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})
......@@ -5425,6 +5425,26 @@ class TestSearchPagination(TestcaseBase):
# assert sorted(search_res[0].distances, key=numpy.float32) == sorted(res_distance, key=numpy.float32)
assert set(search_res[0].ids) == set(res[0].ids[offset:])
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.parametrize("offset", [100, default_nb // 2])
def test_search_offset_different_position(self, offset):
"""
target: test search pagination with offset in different position
method: create connection, collection, insert entities and search with offset
expected: search successfully
"""
# 1. initialize
collection_w = self.init_collection_general(prefix, True)[0]
# 2. search with offset in params
search_params = {"metric_type": "COSINE", "params": {"nprobe": 10}, "offset": offset}
res1 = collection_w.search(vectors[:default_nq], default_search_field,
search_params, default_limit)[0]
# 3. search with offset outside params
res2 = collection_w.search(vectors[:default_nq], default_search_field, default_search_params,
default_limit, offset=offset)[0]
assert res1[0].ids == res2[0].ids
class TestSearchPaginationInvalid(TestcaseBase):
""" Test case of search pagination """
......
......@@ -1647,6 +1647,33 @@ class TestUtilityBase(TestcaseBase):
assert collection_alias[0] in collections
assert old_collection_name not in collections
@pytest.mark.tags(CaseLabel.L2)
def test_create_alias_using_dropped_collection_name(self):
"""
target: test create alias using a dropped collection name
method: create 2 collections and drop one collection
expected: raise no exception
"""
# 1. create 2 collections
a_name = cf.gen_unique_str("aa")
b_name = cf.gen_unique_str("bb")
self.init_collection_wrap(name=a_name, schema=default_schema,
check_task=CheckTasks.check_collection_property,
check_items={exp_name: a_name, exp_schema: default_schema})
self.init_collection_wrap(name=b_name, schema=default_schema,
check_task=CheckTasks.check_collection_property,
check_items={exp_name: b_name, exp_schema: default_schema})
# 2. drop collection a
self.utility_wrap.drop_collection(a_name)
assert self.utility_wrap.has_collection(a_name)[0] is False
assert len(self.utility_wrap.list_aliases(b_name)[0]) == 0
# 3. create alias with the name of collection a
self.utility_wrap.create_alias(b_name, a_name)
b_alias, _ = self.utility_wrap.list_aliases(b_name)
assert a_name in b_alias
class TestUtilityAdvanced(TestcaseBase):
""" Test case of index interface """
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册