From 396f3e408b1f8b0f40615117802da95e775d2b28 Mon Sep 17 00:00:00 2001 From: NicoYuan1986 <109071306+NicoYuan1986@users.noreply.github.com> Date: Tue, 8 Nov 2022 16:55:03 +0800 Subject: [PATCH] Modify test cases related to pagination (#20400) Signed-off-by: nico Signed-off-by: nico --- .../python_client/base/collection_wrapper.py | 2 +- tests/python_client/testcases/test_query.py | 42 ++++++++----------- tests/python_client/testcases/test_search.py | 5 +-- 3 files changed, 21 insertions(+), 28 deletions(-) diff --git a/tests/python_client/base/collection_wrapper.py b/tests/python_client/base/collection_wrapper.py index e577db6d0..497300479 100644 --- a/tests/python_client/base/collection_wrapper.py +++ b/tests/python_client/base/collection_wrapper.py @@ -175,7 +175,7 @@ class ApiCollectionWrapper: timeout = TIMEOUT if timeout is None else timeout 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, expression=expr, partition_names=partition_names, output_fields=output_fields, diff --git a/tests/python_client/testcases/test_query.py b/tests/python_client/testcases/test_query.py index 502044703..547b2f367 100644 --- a/tests/python_client/testcases/test_query.py +++ b/tests/python_client/testcases/test_query.py @@ -1019,7 +1019,6 @@ class TestQueryParams(TestcaseBase): assert query_res == res @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue #19482") @pytest.mark.parametrize("limit", ["12 s", " ", [0, 1], {2}]) def test_query_pagination_with_invalid_limit_type(self, limit): """ @@ -1032,14 +1031,12 @@ class TestQueryParams(TestcaseBase): int_values = vectors[0][ct.default_int64_field_name].values.tolist() 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') - query_params = {"offset": 10, "limit": limit} - collection_w.query(term_expr, params=query_params, - check_task=CheckTasks.check_query_results, - check_items={exp_res: res}) + collection_w.query(term_expr, offset=10, limit=limit, + check_task=CheckTasks.err_res, + check_items={ct.err_code: 1, + ct.err_msg: "limit [%s] is invalid" % limit}) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue #19482") @pytest.mark.parametrize("limit", [-1, 67890]) def test_query_pagination_with_invalid_limit_value(self, limit): """ @@ -1052,14 +1049,13 @@ class TestQueryParams(TestcaseBase): int_values = vectors[0][ct.default_int64_field_name].values.tolist() 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') - query_params = {"offset": 10, "limit": limit} - collection_w.query(term_expr, params=query_params, - check_task=CheckTasks.check_query_results, - check_items={exp_res: res}) + collection_w.query(term_expr, offset=10, limit=limit, + check_task=CheckTasks.err_res, + check_items={ct.err_code: 1, + ct.err_msg: "limit [%s] is invalid, should be in range " + "[1, 16384], but got %s" % (limit, limit)}) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue #19482") @pytest.mark.parametrize("offset", ["12 s", " ", [0, 1], {2}]) def test_query_pagination_with_invalid_offset_type(self, offset): """ @@ -1072,14 +1068,12 @@ class TestQueryParams(TestcaseBase): int_values = vectors[0][ct.default_int64_field_name].values.tolist() 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') - query_params = {"offset": offset, "limit": 10} - collection_w.query(term_expr, params=query_params, - check_task=CheckTasks.check_query_results, - check_items={exp_res: res}) + collection_w.query(term_expr, offset=offset, limit=10, + check_task=CheckTasks.err_res, + check_items={ct.err_code: 1, + ct.err_msg: "offset [%s] is invalid" % offset}) @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue #19482") @pytest.mark.parametrize("offset", [-1, 67890]) def test_query_pagination_with_invalid_offset_value(self, offset): """ @@ -1092,11 +1086,11 @@ class TestQueryParams(TestcaseBase): int_values = vectors[0][ct.default_int64_field_name].values.tolist() 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') - query_params = {"offset": offset, "limit": 10} - collection_w.query(term_expr, params=query_params, - check_task=CheckTasks.check_query_results, - check_items={exp_res: res}) + collection_w.query(term_expr, offset=offset, limit=10, + check_task=CheckTasks.err_res, + check_items={ct.err_code: 1, + ct.err_msg: "offset [%s] is invalid, should be in range " + "[1, 16384], but got %s" % (offset, offset)}) class TestQueryOperation(TestcaseBase): diff --git a/tests/python_client/testcases/test_search.py b/tests/python_client/testcases/test_search.py index 2da9f8aec..10917df83 100644 --- a/tests/python_client/testcases/test_search.py +++ b/tests/python_client/testcases/test_search.py @@ -3879,8 +3879,7 @@ class TestsearchPagination(TestcaseBase): assert search_res[0].ids == res[0].ids[offset:] @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.skip(reason="wait to test") - @pytest.mark.parametrize("limit", [1, 10, 100, 3000]) + @pytest.mark.parametrize("limit", [100, 3000, 10000]) def test_search_with_pagination_topK(self, auto_id, dim, limit, _async): """ target: test search with pagination limit + offset = topK @@ -3893,7 +3892,7 @@ class TestsearchPagination(TestcaseBase): # 1. create a collection topK = 16384 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 search_param = {"metric_type": "L2", "params": {"nprobe": 10}, "offset": offset} vectors = [[random.random() for _ in range(dim)] for _ in range(default_nq)] -- GitLab