From ff80e2f3ecd264501511f8ccbdea0ae8c70eb9df Mon Sep 17 00:00:00 2001 From: ThreadDao Date: Sun, 24 Oct 2021 16:25:09 +0800 Subject: [PATCH] Add case to test merge delete ids (#10525) Signed-off-by: ThreadDao --- tests/python_client/base/client_base.py | 4 +- .../python_client/testcases/test_delete_20.py | 94 +++++++++++++++++++ 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/tests/python_client/base/client_base.py b/tests/python_client/base/client_base.py index 57eeac750..b259bbeb1 100644 --- a/tests/python_client/base/client_base.py +++ b/tests/python_client/base/client_base.py @@ -103,13 +103,13 @@ class TestcaseBase(Base): port=param_info.param_port) return res - def init_collection_wrap(self, name=None, schema=None, check_task=None, check_items=None, **kwargs): + def init_collection_wrap(self, name=None, schema=None, shards_num=2, check_task=None, check_items=None, **kwargs): name = cf.gen_unique_str('coll_') if name is None else name schema = cf.gen_default_collection_schema() if schema is None else schema if self.connection_wrap.get_connection(alias=DefaultConfig.DEFAULT_USING)[0] is None: self._connect() collection_w = ApiCollectionWrapper() - collection_w.init_collection(name=name, schema=schema, check_task=check_task, check_items=check_items, **kwargs) + collection_w.init_collection(name=name, schema=schema, shards_num=shards_num, check_task=check_task, check_items=check_items, **kwargs) self.collection_object_list.append(collection_w) return collection_w diff --git a/tests/python_client/testcases/test_delete_20.py b/tests/python_client/testcases/test_delete_20.py index aecb67d1b..16c274b5e 100644 --- a/tests/python_client/testcases/test_delete_20.py +++ b/tests/python_client/testcases/test_delete_20.py @@ -314,6 +314,40 @@ class TestDeleteOperation(TestcaseBase): assert collection_w.num_entities == tmp_nb - 1 assert collection_w.has_index() + @pytest.mark.xfail(reason="Issue: #10459") + @pytest.mark.tags(CaseLabel.L2) + def test_delete_query_ids_both_sealed_and_channel(self): + """ + target: test query that delete ids from both channle and sealed + method: 1.create and insert + 2.delete id 0 and flush + 3.load and query id 0 + 4.insert new id and delete the id + 5.query id 0 and new id + expected: Empty querybresult + """ + # init collection and insert data without flush + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix)) + df = cf.gen_default_dataframe_data(tmp_nb) + collection_w.insert(df) + + # delete id 0 and flush + del_res, _ = collection_w.delete(tmp_expr) + assert del_res.delete_count == 1 + assert collection_w.num_entities == tmp_nb + + # load and query id 0 + collection_w.query(tmp_expr, check_task=CheckTasks.check_query_empty) + + # insert id tmp_nb and delete id 0 and tmp_nb + df_new = cf.gen_default_dataframe_data(nb=1, start=tmp_nb) + collection_w.insert(df_new) + collection_w.delete(expr=f'{ct.default_int64_field_name} in {[tmp_nb]}') + + # query with id 0 and tmp_nb + collection_w.query(expr=f'{ct.default_int64_field_name} in {[0, tmp_nb]}', + check_task=CheckTasks.check_query_empty) + @pytest.mark.xfail(reason="Waiting for debug") @pytest.mark.tags(CaseLabel.L2) def test_delete_search(self): @@ -665,6 +699,66 @@ class TestDeleteOperation(TestcaseBase): expr = f'{ct.default_int64_field_name} in {ids}' collection_w.query(expr, check_task=CheckTasks.check_query_empty) + @pytest.mark.skip(reason="Issue: #10459") + @pytest.mark.tags(CaseLabel.L2) + def test_delete_merge_same_id_channel_and_sealed(self): + """ + target: test merge same delete ids from channel and sealed + method: 1.create, insert + 2.delete id and flush (data and deleted become sealed) + 3.load and query (verify delete successfully) + 4.insert entity with deleted id + 5.delete id + 6.query with id + expected: Empty query result + """ + # init collection and insert data without flush + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix), shards_num=1) + df = cf.gen_default_dataframe_data(tmp_nb) + collection_w.insert(df) + + # delete id 0 and flush + del_res, _ = collection_w.delete(tmp_expr) + assert del_res.delete_count == 1 + assert collection_w.num_entities == tmp_nb + + # load and query id 0 + collection_w.query(tmp_expr, check_task=CheckTasks.check_query_empty) + + # re-insert id 0 and re-delete id 0 + collection_w.insert(df[:1]) + collection_w.delete(tmp_expr) + collection_w.query(tmp_expr, check_task=CheckTasks.check_query_empty) + + @pytest.mark.skip(reason="Issue: #10459") + @pytest.mark.tags(CaseLabel.L2) + def test_delete_merge_ids_channel_and_sealed(self): + """ + target: test merge deleted ids come from both channel and sealed + method: 1.create, insert ids [0, tmp_nb) with shard_num=1 + 2.delete id 0 and flush + 3.load and query with id 0 + 4.delete id 1 (merge same segment deleted ids 0 and 1) + 5.query with id 0 and 1 + expected: Empty query result + """ + # init collection and insert data without flush + collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix), shards_num=1) + df = cf.gen_default_dataframe_data(tmp_nb) + collection_w.insert(df) + + # delete id 0 and flush + del_res, _ = collection_w.delete(tmp_expr) + assert del_res.delete_count == 1 + assert collection_w.num_entities == tmp_nb + + # load and query id 0 + collection_w.query(tmp_expr, check_task=CheckTasks.check_query_empty) + + # delete id 1 and query id 0 and 1 + collection_w.delete(expr=f'{ct.default_int64_field_name} in {[1]}') + collection_w.query(expr=f'{ct.default_int64_field_name} in {[0, 1]}', check_task=CheckTasks.check_query_empty) + @pytest.mark.tags(CaseLabel.L2) @pytest.mark.xfail(reason="TODO") def test_delete_multi_threading(self): -- GitLab