From e1cef261cdbc48ded5a93a7ba1cb7c84e92fc30e Mon Sep 17 00:00:00 2001 From: binbin <83755740+binbinlv@users.noreply.github.com> Date: Mon, 4 Jul 2022 08:56:20 +0800 Subject: [PATCH] Update test case level (#18019) Signed-off-by: Binbin Lv --- tests/python_client/common/common_func.py | 25 ++++++++++++++++++++ tests/python_client/testcases/test_search.py | 22 ++++++++--------- 2 files changed, 36 insertions(+), 11 deletions(-) diff --git a/tests/python_client/common/common_func.py b/tests/python_client/common/common_func.py index 535a167471..6f950fb147 100644 --- a/tests/python_client/common/common_func.py +++ b/tests/python_client/common/common_func.py @@ -409,6 +409,31 @@ def gen_search_param(index_type, metric_type="L2"): return search_params +def gen_invalid_search_param(index_type, metric_type="L2"): + search_params = [] + if index_type in ["FLAT", "IVF_FLAT", "IVF_SQ8", "IVF_SQ8H", "IVF_PQ"] \ + or index_type in ["BIN_FLAT", "BIN_IVF_FLAT"]: + for nprobe in [-1]: + ivf_search_params = {"metric_type": metric_type, "params": {"nprobe": nprobe}} + search_params.append(ivf_search_params) + elif index_type in ["HNSW", "RHNSW_FLAT", "RHNSW_PQ", "RHNSW_SQ"]: + for ef in [-1]: + hnsw_search_param = {"metric_type": metric_type, "params": {"ef": ef}} + search_params.append(hnsw_search_param) + elif index_type in ["NSG", "RNSG"]: + for search_length in [100, 300]: + nsg_search_param = {"metric_type": metric_type, "params": {"search_length": search_length}} + search_params.append(nsg_search_param) + elif index_type == "ANNOY": + for search_k in ["-1"]: + annoy_search_param = {"metric_type": metric_type, "params": {"search_k": search_k}} + search_params.append(annoy_search_param) + else: + log.error("Invalid index_type.") + raise Exception("Invalid index_type.") + return search_params + + def gen_all_type_fields(): fields = [] for k, v in DataType.__members__.items(): diff --git a/tests/python_client/testcases/test_search.py b/tests/python_client/testcases/test_search.py index 65a54e56c5..6b1debac64 100644 --- a/tests/python_client/testcases/test_search.py +++ b/tests/python_client/testcases/test_search.py @@ -274,7 +274,8 @@ class TestCollectionSearchInvalid(TestcaseBase): "err_msg": "Field %s doesn't exist in schema" % invalid_search_field}) - @pytest.mark.tags(CaseLabel.L2) + @pytest.mark.tags(CaseLabel.L1) + @pytest.mark.xfail(reason="issue 17935") def test_search_param_invalid_metric_type(self, get_invalid_metric_type): """ target: test search with invalid parameter values @@ -293,7 +294,7 @@ class TestCollectionSearchInvalid(TestcaseBase): check_items={"err_code": 1, "err_msg": "metric type not found"}) - @pytest.mark.tags(CaseLabel.L2) + @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("index, params", zip(ct.all_index_types[:9], ct.default_index_params[:9])) @@ -614,11 +615,10 @@ class TestCollectionSearchInvalid(TestcaseBase): check_items={"err_code": 1, "err_msg": "PartitonName: %s not found" % deleted_par_name}) - @pytest.mark.tags(CaseLabel.L2) - @pytest.mark.xfail(reason="issue 6731") + @pytest.mark.tags(CaseLabel.L1) @pytest.mark.parametrize("index, params", - zip(ct.all_index_types[:9], - ct.default_index_params[:9])) + zip(ct.all_index_types[1:9], + ct.default_index_params[1:9])) def test_search_different_index_invalid_params(self, index, params): """ target: test search with different index @@ -640,13 +640,13 @@ class TestCollectionSearchInvalid(TestcaseBase): collection_w.load() # 3. search log.info("test_search_different_index_invalid_params: Searching after creating index-%s" % index) + search_params = cf.gen_invalid_search_param(index) collection_w.search(vectors, default_search_field, - default_search_params, default_limit, + search_params[0], default_limit, default_search_exp, - check_task=CheckTasks.check_search_results, - check_items={"nq": default_nq, - "ids": insert_ids, - "limit": default_limit}) + check_task=CheckTasks.err_res, + check_items={"err_code": 1, + "err_msg": "Search params check failed"}) @pytest.mark.tags(CaseLabel.L2) def test_search_index_partition_not_existed(self):