diff --git a/tests/python_client/base/collection_wrapper.py b/tests/python_client/base/collection_wrapper.py index 82740a2f8b..e577db6d0e 100644 --- a/tests/python_client/base/collection_wrapper.py +++ b/tests/python_client/base/collection_wrapper.py @@ -13,7 +13,7 @@ from utils.util_log import test_log as log from pymilvus.orm.types import CONSISTENCY_STRONG from common.common_func import param_info -TIMEOUT = 20 +TIMEOUT = 120 INDEX_NAME = "" diff --git a/tests/python_client/chaos/checker.py b/tests/python_client/chaos/checker.py index c6eb5bb42c..5f7f085567 100644 --- a/tests/python_client/chaos/checker.py +++ b/tests/python_client/chaos/checker.py @@ -146,7 +146,7 @@ class SearchChecker(Checker): super().__init__(collection_name=collection_name, shards_num=shards_num) self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str('index_'), + index_name=cf.gen_unique_str('index_'), timeout=timeout, enable_traceback=enable_traceback, check_task=CheckTasks.check_nothing) @@ -318,6 +318,7 @@ class IndexChecker(Checker): if collection_name is None: collection_name = cf.gen_unique_str("IndexChecker_") super().__init__(collection_name=collection_name) + self.index_name = cf.gen_unique_str('index_') self.c_wrap.insert(data=cf.gen_default_list_data(nb=5 * constants.ENTITIES_FOR_SEARCH), timeout=timeout, enable_traceback=enable_traceback) # do as a flush before indexing @@ -327,8 +328,7 @@ class IndexChecker(Checker): def create_index(self): res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( - 'index_'), + index_name=self.index_name, timeout=timeout, enable_traceback=enable_traceback, check_task=CheckTasks.check_nothing) @@ -356,7 +356,7 @@ class QueryChecker(Checker): super().__init__(collection_name=collection_name, shards_num=shards_num) res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( + index_name=cf.gen_unique_str( 'index_'), timeout=timeout, enable_traceback=enable_traceback, @@ -395,7 +395,7 @@ class LoadChecker(Checker): self.replica_number = replica_number res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( + index_name=cf.gen_unique_str( 'index_'), timeout=timeout, enable_traceback=enable_traceback, @@ -428,7 +428,7 @@ class DeleteChecker(Checker): super().__init__(collection_name=collection_name) res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( + index_name=cf.gen_unique_str( 'index_'), timeout=timeout, enable_traceback=enable_traceback, @@ -468,7 +468,7 @@ class CompactChecker(Checker): self.ut = ApiUtilityWrapper() res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( + index_name=cf.gen_unique_str( 'index_'), timeout=timeout, enable_traceback=enable_traceback, @@ -532,7 +532,7 @@ class LoadBalanceChecker(Checker): self.utility_wrap = ApiUtilityWrapper() res, result = self.c_wrap.create_index(ct.default_float_vec_field_name, constants.DEFAULT_INDEX_PARAM, - name=cf.gen_unique_str( + index_name=cf.gen_unique_str( 'index_'), timeout=timeout, enable_traceback=enable_traceback, diff --git a/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py b/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py index e93f5d3a1d..949fc3ae98 100644 --- a/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py +++ b/tests/python_client/chaos/testcases/test_all_collections_after_chaos.py @@ -51,15 +51,26 @@ class TestAllCollection(TestcaseBase): entities = collection_w.num_entities log.info(f"assert flush: {tt}, entities: {entities}") - # search - _index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} - t0 = time.time() - index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) - tt = time.time() - t0 - log.info(f"assert index: {tt}") + # create index if not have + index_infos = [index.to_dict() for index in collection_w.indexes] + index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} + if len(index_infos) == 0: + log.info("collection {name} does not have index, create index for it") + t0 = time.time() + index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, + index_params=index_params, + index_name=cf.gen_unique_str()) + tt = time.time() - t0 + log.info(f"assert index: {tt}") + + # show index infos + index_infos = [index.to_dict() for index in collection_w.indexes] + log.info(f"index info: {index_infos}") + + # load collection_w.load() + + # search search_vectors = cf.gen_vectors(1, ct.default_dim) search_params = {"metric_type": "L2", "params": {"ef": 64}} t0 = time.time() @@ -71,24 +82,17 @@ class TestAllCollection(TestcaseBase): assert len(res_1) == 1 collection_w.release() - # index + # insert data d = cf.gen_default_list_data() collection_w.insert(d) - log.info(f"assert index entities: {collection_w.num_entities}") - _index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} - t0 = time.time() - index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) - tt = time.time() - t0 - log.info(f"assert index: {tt}") - assert len(collection_w.indexes) == 1 - # search + # load t0 = time.time() collection_w.load() tt = time.time() - t0 log.info(f"assert load: {tt}") + + # search search_vectors = cf.gen_vectors(1, ct.default_dim) t0 = time.time() res_1, _ = collection_w.search(data=search_vectors, diff --git a/tests/python_client/chaos/testcases/test_data_persistence.py b/tests/python_client/chaos/testcases/test_data_persistence.py index 0d0bd0cd04..2d18f0a2db 100644 --- a/tests/python_client/chaos/testcases/test_data_persistence.py +++ b/tests/python_client/chaos/testcases/test_data_persistence.py @@ -44,15 +44,28 @@ class TestDataPersistence(TestcaseBase): entities = collection_w.num_entities log.info(f"assert flush: {tt}, entities: {entities}") - # search - _index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} - t0 = time.time() - index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) - tt = time.time() - t0 - log.info(f"assert index: {tt}") + # create index if not have + index_infos = [index.to_dict() for index in collection_w.indexes] + index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} + if len(index_infos) == 0: + log.info("collection {name} does not have index, create index for it") + t0 = time.time() + index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, + index_params=index_params, + index_name=cf.gen_unique_str()) + index, _ = collection_w.create_index(field_name=ct.default_string_field_name, + index_params={}, + index_name=cf.gen_unique_str()) + tt = time.time() - t0 + log.info(f"assert index: {tt}") + + # show index infos + index_infos = [index.to_dict() for index in collection_w.indexes] + log.info(f"index info: {index_infos}") + + # load collection_w.load() + # search search_vectors = cf.gen_vectors(1, ct.default_dim) search_params = {"metric_type": "L2", "params": {"ef": 64}} t0 = time.time() @@ -64,20 +77,12 @@ class TestDataPersistence(TestcaseBase): assert len(res_1) == 1 collection_w.release() - # index + # insert data d = cf.gen_default_list_data() collection_w.insert(d) - log.info(f"assert index entities: {collection_w.num_entities}") - _index_params = {"index_type": "HNSW", "metric_type": "L2", "params": {"M": 48, "efConstruction": 500}} - t0 = time.time() - index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) - tt = time.time() - t0 - log.info(f"assert index: {tt}") - assert len(collection_w.indexes) == 1 + log.info(f"assert entities: {collection_w.num_entities}") - # search + # load and search t0 = time.time() collection_w.load() tt = time.time() - t0 diff --git a/tests/python_client/testcases/test_e2e.py b/tests/python_client/testcases/test_e2e.py index 5663f9f02d..91a808f6d8 100644 --- a/tests/python_client/testcases/test_e2e.py +++ b/tests/python_client/testcases/test_e2e.py @@ -40,12 +40,23 @@ class TestE2e(TestcaseBase): entities = collection_w.num_entities log.info(f"assert flush: {tt}, entities: {entities}") - # search - _index_params = {"index_type": "IVF_SQ8", "params": {"nlist": 64}, "metric_type": "L2"} + # index + index_params = {"index_type": "IVF_SQ8", "params": {"nlist": 64}, "metric_type": "L2"} + t0 = time.time() index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) + index_params=index_params, + index_name=cf.gen_unique_str()) + index, _ = collection_w.create_index(field_name=ct.default_string_field_name, + index_params={}, + index_name=cf.gen_unique_str()) + tt = time.time() - t0 + log.info(f"assert index: {tt}") + assert len(collection_w.indexes) == 2 + + # load collection_w.load() + + # search search_vectors = cf.gen_vectors(1, ct.default_dim) search_params = {"metric_type": "L2", "params": {"nprobe": 16}} t0 = time.time() @@ -55,20 +66,13 @@ class TestE2e(TestcaseBase): tt = time.time() - t0 log.info(f"assert search: {tt}") assert len(res_1) == 1 + + # release collection_w.release() - # index + # insert d = cf.gen_default_list_data() collection_w.insert(d) - log.info(f"assert index entities: {collection_w.num_entities}") - _index_params = {"index_type": "IVF_SQ8", "params": {"nlist": 64}, "metric_type": "L2"} - t0 = time.time() - index, _ = collection_w.create_index(field_name=ct.default_float_vec_field_name, - index_params=_index_params, - name=cf.gen_unique_str()) - tt = time.time() - t0 - log.info(f"assert index: {tt}") - assert len(collection_w.indexes) == 1 # search t0 = time.time()