diff --git a/tests/python_client/base/collection_wrapper.py b/tests/python_client/base/collection_wrapper.py index 6b64dbac36..d8de7e0b42 100644 --- a/tests/python_client/base/collection_wrapper.py +++ b/tests/python_client/base/collection_wrapper.py @@ -53,10 +53,12 @@ class ApiCollectionWrapper: @property def is_empty(self): + self.flush() return self.collection.is_empty @property def num_entities(self): + self.flush() return self.collection.num_entities @property @@ -120,22 +122,33 @@ class ApiCollectionWrapper: **kwargs).run() return res, check_result + # @trace() + # def flush(self, check_task=None, check_items=None, **kwargs): + # #TODO:currently, flush is not supported by sdk in milvus + # timeout = kwargs.get("timeout", TIMEOUT) + # + # @timeout_decorator.timeout(timeout, timeout_exception=TimeoutError) + # def _flush(): + # res = self.collection.num_entities + # return res + # try: + # res = _flush() + # return res, True + # except TimeoutError as e: + # log.error(f"flush timeout error: {e}") + # res = None + # return res, False + @trace() def flush(self, check_task=None, check_items=None, **kwargs): - #TODO:currently, flush is not supported by sdk in milvus timeout = kwargs.get("timeout", TIMEOUT) - - @timeout_decorator.timeout(timeout, timeout_exception=TimeoutError) - def _flush(): - res = self.collection.num_entities - return res - try: - res = _flush() - return res, True - except TimeoutError as e: - log.error(f"flush timeout error: {e}") - res = None - return res, False + kwargs.update({"timeout": timeout}) + + func_name = sys._getframe().f_code.co_name + res, check = api_request([self.collection.flush], **kwargs) + check_result = ResponseChecker(res, func_name, check_task, + check_items, check, **kwargs).run() + return res, check_result @trace() def search(self, data, anns_field, param, limit, expr=None, diff --git a/tests/python_client/base/partition_wrapper.py b/tests/python_client/base/partition_wrapper.py index 5f58d1415d..45a9fc561d 100644 --- a/tests/python_client/base/partition_wrapper.py +++ b/tests/python_client/base/partition_wrapper.py @@ -35,10 +35,12 @@ class ApiPartitionWrapper: @property def is_empty(self): + self.flush() return self.partition.is_empty if self.partition else None @property def num_entities(self): + self.flush() return self.partition.num_entities if self.partition else None def drop(self, check_task=None, check_items=None, **kwargs): @@ -73,6 +75,17 @@ class ApiPartitionWrapper: **kwargs).run() return res, check_result + def flush(self, 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, succ = api_request([self.partition.flush], **kwargs) + check_result = ResponseChecker(res, func_name, check_task, + check_items, is_succ=succ, + **kwargs).run() + return res, check_result + def insert(self, data, check_task=None, check_items=None, **kwargs): timeout = kwargs.get("timeout", TIMEOUT) kwargs.update({"timeout": timeout}) diff --git a/tests/python_client/requirements.txt b/tests/python_client/requirements.txt index 6cbcaf0b8a..dade6d85d0 100644 --- a/tests/python_client/requirements.txt +++ b/tests/python_client/requirements.txt @@ -9,7 +9,7 @@ allure-pytest==2.7.0 pytest-print==0.2.1 pytest-level==0.1.1 pytest-xdist==2.5.0 -pymilvus==2.1.0.dev103 +pymilvus==2.2.0.dev6 pytest-rerunfailures==9.1.1 git+https://github.com/Projectplace/pytest-tags ndg-httpsclient diff --git a/tests/python_client/testcases/test_alias.py b/tests/python_client/testcases/test_alias.py index ac63e2b077..aae687e4c9 100644 --- a/tests/python_client/testcases/test_alias.py +++ b/tests/python_client/testcases/test_alias.py @@ -241,8 +241,8 @@ class TestAliasOperation(TestcaseBase): # assert insert data pytest.assume(insert_data_flag is True and - collection_alias.num_entities == ct.default_nb and - collection_w.num_entities == ct.default_nb) + collection_w.num_entities == ct.default_nb and + collection_alias.num_entities == ct.default_nb) # create index by alias default_index = {"index_type": "IVF_FLAT", "params": {"nlist": 128}, "metric_type": "L2"} diff --git a/tests/python_client/testcases/test_collection.py b/tests/python_client/testcases/test_collection.py index 4e1f206f73..08387ad272 100644 --- a/tests/python_client/testcases/test_collection.py +++ b/tests/python_client/testcases/test_collection.py @@ -1381,6 +1381,7 @@ class TestCollectionDataframe(TestcaseBase): res, _ = self.collection_wrap.construct_from_dataframe(cf.gen_unique_str(prefix), df, primary_field=ct.default_int64_field_name, auto_id=False) collection_w = res[0] + collection_w.flush() assert collection_w.num_entities == nb mutation_res = res[1] assert mutation_res.primary_keys == df[ct.default_int64_field_name].values.tolist() diff --git a/tests/python_client/testcases/test_e2e.py b/tests/python_client/testcases/test_e2e.py index 6b0bf75f3f..9d197513b2 100644 --- a/tests/python_client/testcases/test_e2e.py +++ b/tests/python_client/testcases/test_e2e.py @@ -33,9 +33,9 @@ class TestE2e(TestcaseBase): # flush t0 = time.time() - num_entities, check_result = collection_w.flush(timeout=180) + _, check_result = collection_w.flush(timeout=180) assert check_result - assert num_entities == len(data[0]) + entities + assert collection_w.num_entities == len(data[0]) + entities tt = time.time() - t0 entities = collection_w.num_entities log.info(f"assert flush: {tt}, entities: {entities}") diff --git a/tests/python_client/testcases/test_index.py b/tests/python_client/testcases/test_index.py index 46cc5a4023..5afe35fcc2 100644 --- a/tests/python_client/testcases/test_index.py +++ b/tests/python_client/testcases/test_index.py @@ -90,7 +90,7 @@ class TestIndexParams(TestcaseBase): ct.err_msg: f"cannot create index on non-existed field: {f_name}"}) @pytest.mark.tags(CaseLabel.L0) - # TODO (reason="pymilvus issue #677", raises=TypeError) + @pytest.mark.xfail(reason="pymilvus issue 677") @pytest.mark.parametrize("index_type", ct.get_invalid_strs) def test_index_type_invalid(self, index_type): """