From 35bb577da1d9f29e58b511414380edd1299de1d7 Mon Sep 17 00:00:00 2001 From: nico <109071306+NicoYuan1986@users.noreply.github.com> Date: Fri, 12 May 2023 18:49:21 +0800 Subject: [PATCH] Replace num_entities with count(*) in some test cases (#24033) Signed-off-by: nico --- tests/python_client/testcases/test_delete.py | 6 ++++-- tests/python_client/testcases/test_insert.py | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/python_client/testcases/test_delete.py b/tests/python_client/testcases/test_delete.py index c494c7f91..69335ce88 100644 --- a/tests/python_client/testcases/test_delete.py +++ b/tests/python_client/testcases/test_delete.py @@ -1250,8 +1250,8 @@ class TestDeleteString(TestcaseBase): # delete half and flush expr = f'{ct.default_string_field_name} in {insert_res.primary_keys[:ct.default_nb // 2]}' expr = expr.replace("'", "\"") - del_res, _ = collection_w.delete(expr) - assert collection_w.num_entities == ct.default_nb + collection_w.delete(expr) + collection_w.flush() # create index index_params = {"index_type": "IVF_SQ8", @@ -1260,6 +1260,8 @@ class TestDeleteString(TestcaseBase): assert collection_w.has_index()[0] collection_w.load() + res = collection_w.query(expr="", output_fields=["count(*)"])[0] + assert res[0]["count(*)"] == ct.default_nb // 2 search_res, _ = collection_w.search([df[ct.default_float_vec_field_name][0]], ct.default_float_vec_field_name, ct.default_search_params, ct.default_limit) diff --git a/tests/python_client/testcases/test_insert.py b/tests/python_client/testcases/test_insert.py index 1c724689a..01f35a05a 100644 --- a/tests/python_client/testcases/test_insert.py +++ b/tests/python_client/testcases/test_insert.py @@ -1535,10 +1535,13 @@ class TestUpsertValid(TestcaseBase): upsert_nb = 1000 collection_w = self.init_collection_general(pre_upsert, True)[0] # upsert + step = 500 for i in range(10): - data = cf.gen_default_data_for_upsert(upsert_nb, start=i*500)[0] + data = cf.gen_default_data_for_upsert(upsert_nb, start=i*step)[0] collection_w.upsert(data) - assert collection_w.num_entities == upsert_nb*10 + ct.default_nb + # check the result + res = collection_w.query(expr="", output_fields=["count(*)"])[0] + assert res[0]["count(*)"] == upsert_nb * 10 - step * 9 @pytest.mark.tags(CaseLabel.L2) def test_upsert_pk_string_multiple_times(self): @@ -1554,12 +1557,17 @@ class TestUpsertValid(TestcaseBase): name = cf.gen_unique_str(pre_upsert) collection_w = self.init_collection_wrap(name, schema) collection_w.insert(cf.gen_default_list_data()) - # upsert + step = 500 for i in range(10): - data = cf.gen_default_list_data(upsert_nb, start=i * 500) + data = cf.gen_default_list_data(upsert_nb, start=i * step) collection_w.upsert(data) - assert collection_w.num_entities == upsert_nb * 10 + ct.default_nb + # load + collection_w.create_index(ct.default_float_vec_field_name, default_index_params) + collection_w.load() + # check the result + res = collection_w.query(expr="", output_fields=["count(*)"])[0] + assert res[0]["count(*)"] == upsert_nb * 10 - step * 9 class TestUpsertInvalid(TestcaseBase): -- GitLab