From 28f8dc89e5c4347462e8f4fc83fe7285def8a764 Mon Sep 17 00:00:00 2001 From: NicoYuan1986 <109071306+NicoYuan1986@users.noreply.github.com> Date: Tue, 21 Mar 2023 09:27:57 +0800 Subject: [PATCH] Add test cases of ignore growing segment (#22865) Signed-off-by: nico --- tests/python_client/testcases/test_query.py | 22 ++++++++++++++ tests/python_client/testcases/test_search.py | 31 ++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/tests/python_client/testcases/test_query.py b/tests/python_client/testcases/test_query.py index 244072e591..294b1f721a 100644 --- a/tests/python_client/testcases/test_query.py +++ b/tests/python_client/testcases/test_query.py @@ -901,6 +901,28 @@ class TestQueryParams(TestcaseBase): collection_w.query(default_term_expr, partition_names=[partition_names], check_task=CheckTasks.err_res, check_items=error) + @pytest.mark.tags(CaseLabel.L1) + def test_query_ignore_growing(self): + """ + target: test search ignoring growing segment + method: 1. create a collection, insert data, create index and load + 2. insert data again + 3. query with param ignore_growing=True + expected: query successfully + """ + # 1. create a collection + collection_w = self.init_collection_general(prefix, True)[0] + + # 2. insert data again + data = cf.gen_default_dataframe_data(start=10000) + collection_w.insert(data) + + # 3. query with param ignore_growing=True + res = collection_w.query('int64 >= 0', ignore_growing=True)[0] + assert len(res) == ct.default_nb + for ids in [res[i][default_int_field_name] for i in range(ct.default_nb)]: + assert ids < 10000 + @pytest.fixture(scope="function", params=[0, 10, 100]) def offset(self, request): yield request.param diff --git a/tests/python_client/testcases/test_search.py b/tests/python_client/testcases/test_search.py index 8ee7742b6d..e89920f7e0 100644 --- a/tests/python_client/testcases/test_search.py +++ b/tests/python_client/testcases/test_search.py @@ -3178,6 +3178,37 @@ class TestCollectionSearch(TestcaseBase): "limit": nb_old + nb_new, "_async": _async}) + @pytest.mark.tags(CaseLabel.L1) + def test_search_ignore_growing(self, nq, dim, _async): + """ + target: test search ignoring growing segment + method: 1. create a collection, insert data, create index and load + 2. insert data again + 3. search with param ignore_growing=True + expected: searched successfully + """ + # 1. create a collection + collection_w = self.init_collection_general(prefix, True, dim=dim)[0] + + # 2. insert data again + data = cf.gen_default_dataframe_data(dim=dim, start=10000) + collection_w.insert(data) + + # 3. search with param ignore_growing=True + search_params = {"metric_type": "L2", "params": {"nprobe": 10}, "ignore_growing": True} + vector = [[random.random() for _ in range(dim)] for _ in range(nq)] + res = collection_w.search(vector[:nq], default_search_field, search_params, default_limit, + default_search_exp, _async=_async, + check_task=CheckTasks.check_search_results, + check_items={"nq": nq, + "limit": default_limit, + "_async": _async})[0] + if _async: + res.done() + res = res.result() + for ids in res[0].ids: + assert ids < 10000 + @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("name", ["_co11ection", "co11_ection"]) @pytest.mark.parametrize("index_name", ["_1ndeX", "In_0"])