未验证 提交 396f3e40 编写于 作者: N NicoYuan1986 提交者: GitHub

Modify test cases related to pagination (#20400)

Signed-off-by: Nnico <cheng.yuan@zilliz.com>
Signed-off-by: Nnico <cheng.yuan@zilliz.com>
上级 510106bd
...@@ -175,7 +175,7 @@ class ApiCollectionWrapper: ...@@ -175,7 +175,7 @@ class ApiCollectionWrapper:
timeout = TIMEOUT if timeout is None else timeout timeout = TIMEOUT if timeout is None else timeout
func_name = sys._getframe().f_code.co_name func_name = sys._getframe().f_code.co_name
res, check = api_request([self.collection.query, expr, output_fields, partition_names, timeout]) res, check = api_request([self.collection.query, expr, output_fields, partition_names, timeout], **kwargs)
check_result = ResponseChecker(res, func_name, check_task, check_items, check, check_result = ResponseChecker(res, func_name, check_task, check_items, check,
expression=expr, partition_names=partition_names, expression=expr, partition_names=partition_names,
output_fields=output_fields, output_fields=output_fields,
......
...@@ -1019,7 +1019,6 @@ class TestQueryParams(TestcaseBase): ...@@ -1019,7 +1019,6 @@ class TestQueryParams(TestcaseBase):
assert query_res == res assert query_res == res
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="issue #19482")
@pytest.mark.parametrize("limit", ["12 s", " ", [0, 1], {2}]) @pytest.mark.parametrize("limit", ["12 s", " ", [0, 1], {2}])
def test_query_pagination_with_invalid_limit_type(self, limit): def test_query_pagination_with_invalid_limit_type(self, limit):
""" """
...@@ -1032,14 +1031,12 @@ class TestQueryParams(TestcaseBase): ...@@ -1032,14 +1031,12 @@ class TestQueryParams(TestcaseBase):
int_values = vectors[0][ct.default_int64_field_name].values.tolist() int_values = vectors[0][ct.default_int64_field_name].values.tolist()
pos = 10 pos = 10
term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos+10]}' term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos+10]}'
res = vectors[0].iloc[10: pos+10, :1].to_dict('records') collection_w.query(term_expr, offset=10, limit=limit,
query_params = {"offset": 10, "limit": limit} check_task=CheckTasks.err_res,
collection_w.query(term_expr, params=query_params, check_items={ct.err_code: 1,
check_task=CheckTasks.check_query_results, ct.err_msg: "limit [%s] is invalid" % limit})
check_items={exp_res: res})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="issue #19482")
@pytest.mark.parametrize("limit", [-1, 67890]) @pytest.mark.parametrize("limit", [-1, 67890])
def test_query_pagination_with_invalid_limit_value(self, limit): def test_query_pagination_with_invalid_limit_value(self, limit):
""" """
...@@ -1052,14 +1049,13 @@ class TestQueryParams(TestcaseBase): ...@@ -1052,14 +1049,13 @@ class TestQueryParams(TestcaseBase):
int_values = vectors[0][ct.default_int64_field_name].values.tolist() int_values = vectors[0][ct.default_int64_field_name].values.tolist()
pos = 10 pos = 10
term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}' term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}'
res = vectors[0].iloc[10: pos + 10, :1].to_dict('records') collection_w.query(term_expr, offset=10, limit=limit,
query_params = {"offset": 10, "limit": limit} check_task=CheckTasks.err_res,
collection_w.query(term_expr, params=query_params, check_items={ct.err_code: 1,
check_task=CheckTasks.check_query_results, ct.err_msg: "limit [%s] is invalid, should be in range "
check_items={exp_res: res}) "[1, 16384], but got %s" % (limit, limit)})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="issue #19482")
@pytest.mark.parametrize("offset", ["12 s", " ", [0, 1], {2}]) @pytest.mark.parametrize("offset", ["12 s", " ", [0, 1], {2}])
def test_query_pagination_with_invalid_offset_type(self, offset): def test_query_pagination_with_invalid_offset_type(self, offset):
""" """
...@@ -1072,14 +1068,12 @@ class TestQueryParams(TestcaseBase): ...@@ -1072,14 +1068,12 @@ class TestQueryParams(TestcaseBase):
int_values = vectors[0][ct.default_int64_field_name].values.tolist() int_values = vectors[0][ct.default_int64_field_name].values.tolist()
pos = 10 pos = 10
term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}' term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}'
res = vectors[0].iloc[10: pos + 10, :1].to_dict('records') collection_w.query(term_expr, offset=offset, limit=10,
query_params = {"offset": offset, "limit": 10} check_task=CheckTasks.err_res,
collection_w.query(term_expr, params=query_params, check_items={ct.err_code: 1,
check_task=CheckTasks.check_query_results, ct.err_msg: "offset [%s] is invalid" % offset})
check_items={exp_res: res})
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="issue #19482")
@pytest.mark.parametrize("offset", [-1, 67890]) @pytest.mark.parametrize("offset", [-1, 67890])
def test_query_pagination_with_invalid_offset_value(self, offset): def test_query_pagination_with_invalid_offset_value(self, offset):
""" """
...@@ -1092,11 +1086,11 @@ class TestQueryParams(TestcaseBase): ...@@ -1092,11 +1086,11 @@ class TestQueryParams(TestcaseBase):
int_values = vectors[0][ct.default_int64_field_name].values.tolist() int_values = vectors[0][ct.default_int64_field_name].values.tolist()
pos = 10 pos = 10
term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}' term_expr = f'{ct.default_int64_field_name} in {int_values[10: pos + 10]}'
res = vectors[0].iloc[10: pos + 10, :1].to_dict('records') collection_w.query(term_expr, offset=offset, limit=10,
query_params = {"offset": offset, "limit": 10} check_task=CheckTasks.err_res,
collection_w.query(term_expr, params=query_params, check_items={ct.err_code: 1,
check_task=CheckTasks.check_query_results, ct.err_msg: "offset [%s] is invalid, should be in range "
check_items={exp_res: res}) "[1, 16384], but got %s" % (offset, offset)})
class TestQueryOperation(TestcaseBase): class TestQueryOperation(TestcaseBase):
......
...@@ -3879,8 +3879,7 @@ class TestsearchPagination(TestcaseBase): ...@@ -3879,8 +3879,7 @@ class TestsearchPagination(TestcaseBase):
assert search_res[0].ids == res[0].ids[offset:] assert search_res[0].ids == res[0].ids[offset:]
@pytest.mark.tags(CaseLabel.L2) @pytest.mark.tags(CaseLabel.L2)
@pytest.mark.skip(reason="wait to test") @pytest.mark.parametrize("limit", [100, 3000, 10000])
@pytest.mark.parametrize("limit", [1, 10, 100, 3000])
def test_search_with_pagination_topK(self, auto_id, dim, limit, _async): def test_search_with_pagination_topK(self, auto_id, dim, limit, _async):
""" """
target: test search with pagination limit + offset = topK target: test search with pagination limit + offset = topK
...@@ -3893,7 +3892,7 @@ class TestsearchPagination(TestcaseBase): ...@@ -3893,7 +3892,7 @@ class TestsearchPagination(TestcaseBase):
# 1. create a collection # 1. create a collection
topK = 16384 topK = 16384
offset = topK - limit offset = topK - limit
collection_w = self.init_collection_general(prefix, True, auto_id=auto_id, dim=dim)[0] collection_w = self.init_collection_general(prefix, True, nb=20000, auto_id=auto_id, dim=dim)[0]
# 2. search # 2. search
search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset} search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset}
vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)] vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册