diff --git a/tests/python_client/deploy/scripts/first_recall_test.py b/tests/python_client/deploy/scripts/first_recall_test.py index 91789357e8..e50afc450e 100644 --- a/tests/python_client/deploy/scripts/first_recall_test.py +++ b/tests/python_client/deploy/scripts/first_recall_test.py @@ -2,12 +2,14 @@ import h5py import numpy as np import time from pathlib import Path +import pymilvus from pymilvus import ( connections, FieldSchema, CollectionSchema, DataType, Collection ) +pymilvus_version = pymilvus.__version__ def read_benchmark_hdf5(file_path): @@ -58,7 +60,10 @@ def milvus_recall_test(host='127.0.0.1'): t0 = time.time() print(f"\nGet collection entities...") - collection.flush() + if pymilvus_version >= "2.2.0": + collection.flush() + else: + collection.num_entities print(collection.num_entities) t1 = time.time() print(f"\nGet collection entities cost {t1 - t0:.4f} seconds") diff --git a/tests/python_client/deploy/scripts/utils.py b/tests/python_client/deploy/scripts/utils.py index 774fe514dc..d4a318fba7 100644 --- a/tests/python_client/deploy/scripts/utils.py +++ b/tests/python_client/deploy/scripts/utils.py @@ -1,10 +1,13 @@ import copy import time +import pymilvus from pymilvus import ( FieldSchema, CollectionSchema, DataType, Collection, list_collections, ) +pymilvus_version = pymilvus.__version__ + all_index_types = ["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_PQ", "HNSW", "ANNOY"] default_index_params = [{"nlist": 128}, {"nlist": 128}, {"nlist": 128}, {"nlist": 128, "m": 16, "nbits": 8}, @@ -55,7 +58,10 @@ def get_collections(prefix, check=False): # list entities if collections for name in col_list: c = Collection(name=name) - c.flush() + if pymilvus_version >= "2.2.0": + c.flush() + else: + c.num_entities num_entities = c.num_entities print(f"{name}: {num_entities}") if check: @@ -99,6 +105,10 @@ def create_collections_and_insert_data(prefix, flush=True, count=3000, collectio if flush: print("Get collection entities") start_time = time.time() + if pymilvus_version >= "2.2.0": + collection.flush() + else: + collection.num_entities print(f"collection entities: {collection.num_entities}") end_time = time.time() print("Get collection entities time = %.4fs" % (end_time - start_time)) diff --git a/tests/python_client/deploy/testcases/test_action_first_deployment.py b/tests/python_client/deploy/testcases/test_action_first_deployment.py index a190d04ae3..dda434d02d 100644 --- a/tests/python_client/deploy/testcases/test_action_first_deployment.py +++ b/tests/python_client/deploy/testcases/test_action_first_deployment.py @@ -1,4 +1,5 @@ import pytest +import pymilvus from common import common_func as cf from common import common_type as ct from common.common_type import CaseLabel, CheckTasks @@ -8,6 +9,7 @@ from deploy.base import TestDeployBase from deploy.common import gen_index_param, gen_search_param from utils.util_log import test_log as log +pymilvus_version = pymilvus.__version__ default_nb = ct.default_nb default_nq = ct.default_nq @@ -134,7 +136,10 @@ class TestActionFirstDeployment(TestDeployBase): self.init_collection_general(insert_data=True, is_binary=is_binary, nb=data_size, is_flush=False, is_index=True, name=name) # at this step, all segment are sealed - collection_w.flush() + if pymilvus_version >= "2.2.0": + collection_w.flush() + else: + collection_w.collection.num_entities # delete data for sealed segment and before index delete_expr = f"{ct.default_int64_field_name} in {[i for i in range(10,20)]}" if is_deleted == "is_deleted": diff --git a/tests/python_client/deploy/testcases/test_action_second_deployment.py b/tests/python_client/deploy/testcases/test_action_second_deployment.py index aeb1a87ff3..f4b5932dfb 100644 --- a/tests/python_client/deploy/testcases/test_action_second_deployment.py +++ b/tests/python_client/deploy/testcases/test_action_second_deployment.py @@ -1,4 +1,5 @@ import pytest +import pymilvus from common import common_func as cf from common import common_type as ct from common.common_type import CaseLabel, CheckTasks @@ -23,7 +24,7 @@ binary_field_name = default_binary_vec_field_name default_search_exp = "int64 >= 0" default_term_expr = f'{ct.default_int64_field_name} in [0, 1]' - +pymilvus_version = pymilvus.__version__ class TestActionSecondDeployment(TestDeployBase): """ Test case of action before reinstall """ @@ -121,7 +122,10 @@ class TestActionSecondDeployment(TestDeployBase): check_task=check_task) # flush - collection_w.num_entities + if pymilvus_version >= "2.2.0": + collection_w.flush() + else: + collection_w.collection.num_entities # search and query if "empty" in name: @@ -146,7 +150,10 @@ class TestActionSecondDeployment(TestDeployBase): for i in range(2): self.init_collection_general(insert_data=True, is_binary=is_binary, nb=data_size, is_flush=False, is_index=True, name=name) - collection_w.num_entities + if pymilvus_version >= "2.2.0": + collection_w.flush() + else: + collection_w.collection.num_entities # delete data delete_expr = f"{ct.default_int64_field_name} in [0,1,2,3,4,5,6,7,8,9]"