From e75ad275aa2291d1541cc3c76ad7bf8e7d3a8190 Mon Sep 17 00:00:00 2001 From: nico <109071306+NicoYuan1986@users.noreply.github.com> Date: Wed, 31 Dec 2025 10:17:22 +0800 Subject: [PATCH] test: update tets cases (#46699) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Pull Request Summary: Test Case Updates for API Behavior Changes **Core Invariant**: These test case updates reflect backend API improvements to error messaging and schema information returned by collection operations. The changes maintain backward compatibility—no public signatures change, and all modifications are test expectation updates. **Updated Error Messages for Better Diagnostics**: - `test_add_field_feature.py`: Updated expected error when adding a vector field without dimension specification from a generic "not support to add vector field" to the more descriptive "vector field must have dimension specified, field name = {field_name}: invalid parameter". This change is non-breaking for clients that only check error codes; it improves developer experience with clearer error context. **Schema Information Extension**: - `test_milvus_client_collection.py`: Added `enable_namespace: False` to the expected `describe_collection()` output. This is a new boolean field in the collection metadata that defaults to False, representing an opt-in feature. Existing code querying describe_collection continues to work; the new field is simply an additional property in the response dictionary. **Dynamic Error Message Construction**: - `test_milvus_client_search_invalid.py`: Replaced hardcoded error message with conditional logic that generates the appropriate error based on input state (None vectors vs invalid vector data). This prevents test brittle failure if multiple error conditions exist, and correctly validates the API's behavior handles both "missing data" and "malformed data" cases distinctly. **No Regression Risk**: All changes update test expectations to match improved backend behavior. The changes are additive (new field in schema) or clarifying (better error messages), with no modifications to existing response structures or behavior for valid inputs. Signed-off-by: nico --- .../python_client/milvus_client/test_add_field_feature.py | 2 +- .../milvus_client/test_milvus_client_collection.py | 3 ++- .../milvus_client_v2/test_milvus_client_search_invalid.py | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/python_client/milvus_client/test_add_field_feature.py b/tests/python_client/milvus_client/test_add_field_feature.py index 2311995cfa..18261fc549 100644 --- a/tests/python_client/milvus_client/test_add_field_feature.py +++ b/tests/python_client/milvus_client/test_add_field_feature.py @@ -472,7 +472,7 @@ class TestMilvusClientAddFieldFeatureInvalid(TestMilvusClientV2Base): collection_name = cf.gen_collection_name_by_testcase_name() # 1. create collection dim, field_name = 8, default_new_field_name - error = {ct.err_code: 1100, ct.err_msg: f"not support to add vector field, " + error = {ct.err_code: 1100, ct.err_msg: f"vector field must have dimension specified, " f"field name = {field_name}: invalid parameter"} self.create_collection(client, collection_name, dim) collections = self.list_collections(client)[0] diff --git a/tests/python_client/milvus_client/test_milvus_client_collection.py b/tests/python_client/milvus_client/test_milvus_client_collection.py index 3b671ccdb1..abad0d7c53 100644 --- a/tests/python_client/milvus_client/test_milvus_client_collection.py +++ b/tests/python_client/milvus_client/test_milvus_client_collection.py @@ -3057,7 +3057,8 @@ class TestMilvusClientDescribeCollectionValid(TestMilvusClientV2Base): 'consistency_level': 0, 'properties': {'timezone': 'UTC'}, 'num_partitions': 1, - 'enable_dynamic_field': True + 'enable_dynamic_field': True, + 'enable_namespace': False } # Get actual description res = self.describe_collection(client, collection_name)[0] diff --git a/tests/python_client/milvus_client_v2/test_milvus_client_search_invalid.py b/tests/python_client/milvus_client_v2/test_milvus_client_search_invalid.py index fe23d370fd..27dd0700c4 100644 --- a/tests/python_client/milvus_client_v2/test_milvus_client_search_invalid.py +++ b/tests/python_client/milvus_client_v2/test_milvus_client_search_invalid.py @@ -195,11 +195,14 @@ class TestCollectionSearchInvalid(TestcaseBase): invalid_vectors = get_invalid_vectors log.info("test_search_param_invalid_vectors: searching with " "invalid vectors: {}".format(invalid_vectors)) + if get_invalid_vectors is None: + err_msg = "Either ids or data must be provided" + else: + err_msg = "`search_data` value {} is illegal".format(invalid_vectors) collection_w.search(invalid_vectors, default_search_field, default_search_params, default_limit, default_search_exp, check_task=CheckTasks.err_res, - check_items={"err_code": 999, - "err_msg": "`search_data` value {} is illegal".format(invalid_vectors)}) + check_items={"err_code": 999, "err_msg": err_msg}) @pytest.mark.tags(CaseLabel.L2) def test_search_param_invalid_dim(self):