diff --git a/tests/python_client/base/collection_wrapper.py b/tests/python_client/base/collection_wrapper.py index 69d3ffcef8..58e5974b73 100644 --- a/tests/python_client/base/collection_wrapper.py +++ b/tests/python_client/base/collection_wrapper.py @@ -63,6 +63,10 @@ class ApiCollectionWrapper: self.flush() return self.collection.num_entities + @property + def num_shards(self): + return self.collection.num_shards + @property def num_entities_without_flush(self): return self.collection.num_entities @@ -71,10 +75,6 @@ class ApiCollectionWrapper: def primary_field(self): return self.collection.primary_field - @property - def shards_num(self): - return self.collection.shards_num - @property def aliases(self): return self.collection.aliases @@ -305,36 +305,6 @@ class ApiCollectionWrapper: check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() return res, check_result - @trace() - def create_alias(self, alias_name, check_task=None, check_items=None, **kwargs): - timeout = kwargs.get("timeout", TIMEOUT) - kwargs.update({"timeout": timeout}) - - func_name = sys._getframe().f_code.co_name - res, check = api_request([self.collection.create_alias, alias_name], **kwargs) - check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() - return res, check_result - - @trace() - def drop_alias(self, alias_name, check_task=None, check_items=None, **kwargs): - timeout = kwargs.get("timeout", TIMEOUT) - kwargs.update({"timeout": timeout}) - - func_name = sys._getframe().f_code.co_name - res, check = api_request([self.collection.drop_alias, alias_name], **kwargs) - check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() - return res, check_result - - @trace() - def alter_alias(self, alias_name, check_task=None, check_items=None, **kwargs): - timeout = kwargs.get("timeout", TIMEOUT) - kwargs.update({"timeout": timeout}) - - func_name = sys._getframe().f_code.co_name - res, check = api_request([self.collection.alter_alias, alias_name], **kwargs) - check_result = ResponseChecker(res, func_name, check_task, check_items, check, **kwargs).run() - return res, check_result - @trace() def delete(self, expr, partition_name=None, timeout=None, check_task=None, check_items=None, **kwargs): timeout = TIMEOUT if timeout is None else timeout @@ -396,5 +366,3 @@ class ApiCollectionWrapper: res, check = api_request([self.collection.describe, timeout]) check_result = ResponseChecker(res, func_name, check_task, check_items, check).run() return res, check_result - - diff --git a/tests/python_client/base/schema_wrapper.py b/tests/python_client/base/schema_wrapper.py index 05e778f37c..98441977e2 100644 --- a/tests/python_client/base/schema_wrapper.py +++ b/tests/python_client/base/schema_wrapper.py @@ -22,6 +22,10 @@ class ApiCollectionSchemaWrapper: def primary_field(self): return self.collection_schema.primary_field if self.collection_schema else None + @property + def partition_key_field(self): + return self.collection_schema.partition_key_field if self.collection_schema else None + @property def fields(self): return self.collection_schema.fields if self.collection_schema else None @@ -34,6 +38,25 @@ class ApiCollectionSchemaWrapper: def auto_id(self): return self.collection_schema.auto_id if self.collection_schema else None + @property + def enable_dynamic_field(self): + return self.collection_schema.enable_dynamic_field if self.collection_schema else None + + @property + def to_dict(self): + return self.collection_schema.to_dict if self.collection_schema else None + + @property + def verify(self): + return self.collection_schema.verify if self.collection_schema else None + + def add_field(self, field_name, datatype, check_task=None, check_items=None, **kwargs): + func_name = sys._getframe().f_code.co_name + response, is_succ = api_request([self.collection_schema.add_field, field_name, datatype], **kwargs) + check_result = ResponseChecker(response, func_name, check_task, check_items, + field_name=field_name, datatype=datatype, **kwargs).run() + return response, check_result + class ApiFieldSchemaWrapper: field_schema = None diff --git a/tests/python_client/base/utility_wrapper.py b/tests/python_client/base/utility_wrapper.py index 07ab72c8a4..f092c0ed6c 100644 --- a/tests/python_client/base/utility_wrapper.py +++ b/tests/python_client/base/utility_wrapper.py @@ -223,6 +223,14 @@ class ApiUtilityWrapper: partition_names=partition_names, using=using).run() return res, check_result + def load_state(self, collection_name, partition_names=None, using="default", check_task=None, check_items=None): + func_name = sys._getframe().f_code.co_name + res, is_succ = api_request([self.ut.load_state, collection_name, partition_names, using]) + check_result = ResponseChecker(res, func_name, check_task, check_items, is_succ, + collection_name=collection_name, partition_names=partition_names, + using=using).run() + return res, check_result + def wait_for_loading_complete(self, collection_name, partition_names=None, timeout=None, using="default", check_task=None, check_items=None): timeout = TIMEOUT if timeout is None else timeout @@ -531,3 +539,16 @@ class ApiUtilityWrapper: using=using, timeout=timeout, **kwargs).run() return res, check_result + def get_server_type(self, using="default", check_task=None, check_items=None, **kwargs): + func_name = sys._getframe().f_code.co_name + res, check = api_request([self.ut.get_server_type, using], **kwargs) + check_result = ResponseChecker(res, func_name, check_task, check_items, check, + using=using, **kwargs).run() + return res, check_result + + def list_indexes(self, collection_name, using="default", timeout=None, check_task=None, check_items=None, **kwargs): + func_name = sys._getframe().f_code.co_name + res, check = api_request([self.ut.list_indexes, collection_name, using, timeout], **kwargs) + check_result = ResponseChecker(res, func_name, check_task, check_items, check, + collection_name=collection_name, using=using, timeout=timeout, **kwargs).run() + return res, check_result diff --git a/tests/python_client/testcases/test_utility.py b/tests/python_client/testcases/test_utility.py index 18951c6add..71e2f30f4b 100644 --- a/tests/python_client/testcases/test_utility.py +++ b/tests/python_client/testcases/test_utility.py @@ -1679,6 +1679,53 @@ class TestUtilityBase(TestcaseBase): b_alias, _ = self.utility_wrap.list_aliases(b_name) assert a_name in b_alias + @pytest.mark.tags(CaseLabel.L1) + def test_list_indexes(self): + """ + target: test utility.list_indexes + method: create 2 collections and list indexes + expected: raise no exception + """ + # 1. create 2 collections + string_field = ct.default_string_field_name + collection_w1 = self.init_collection_general(prefix, True)[0] + collection_w2 = self.init_collection_general(prefix, True, is_index=False)[0] + collection_w2.create_index(string_field) + + # 2. list indexes + res1, _ = self.utility_wrap.list_indexes(collection_w1.name) + assert res1 == [ct.default_float_vec_field_name] + res2, _ = self.utility_wrap.list_indexes(collection_w2.name) + assert res2 == [string_field] + + @pytest.mark.tags(CaseLabel.L1) + def test_get_server_type(self): + """ + target: test utility.get_server_type + method: get_server_type + expected: raise no exception + """ + self._connect() + res, _ = self.utility_wrap.get_server_type() + assert res == "milvus" + + @pytest.mark.tags(CaseLabel.L1) + def test_load_state(self): + """ + target: test utility.load_state + method: load_state + expected: raise no exception + """ + collection_w = self.init_collection_general(prefix, True, partition_num=1)[0] + res1, _ = self.utility_wrap.load_state(collection_w.name) + assert str(res1) == "Loaded" + collection_w.release() + res2, _ = self.utility_wrap.load_state(collection_w.name) + assert str(res2) == "NotLoad" + collection_w.load(partition_names=[ct.default_partition_name]) + res3, _ = self.utility_wrap.load_state(collection_w.name) + assert str(res3) == "Loaded" + class TestUtilityAdvanced(TestcaseBase): """ Test case of index interface """