fix: update expected error for test_search_no_connection after pymilvus rc162 (#48504)

## Summary
- Update `test_search_no_connection` expected error to match pymilvus
2.7.0rc162 behavior

## Root Cause
After pymilvus upgrade to rc162 (#48424), `MilvusClient.close()` sets
the internal gRPC handler to `None`. When `search()` is called after
`close()`:
- **Before rc162**: `MilvusException(code=1, "should create connection
first")`
- **After rc162**: `AttributeError("'NoneType' object has no attribute
'search'")` → wrapped as `err_code=-1`

This was not caught by PR #48424's CI because:
1. The test was refactored from ORM to MilvusClient v2 style in PR
#48347 (merged after #48424's CI ran)
2. PR #48424's CI ran the old ORM version which uses
`remove_connection()` (different code path, still returns err_code=1)
3. Only after both PRs merged to master did the combination break in
hourly CI

## Test plan
- [x] `test_search_no_connection` passes locally against Milvus
10.104.14.152 with pymilvus 2.7.0rc162

issue: #48048

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Signed-off-by: yanliang567 <82361606+yanliang567@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
yanliang567
2026-03-25 15:43:35 +08:00
committed by GitHub
co-authored by Claude Opus 4.6
parent 3b2526c7b6
commit d748a8b8b5
@@ -633,15 +633,16 @@ class TestSearchInvalidIndependent(TestMilvusClientV2Base):
client.close()
log.info("test_search_no_connection: closed client connection")
# 3. search without connection
# 3. search without connection — after client.close(), the internal gRPC handler
# is set to None, so pymilvus raises AttributeError instead of MilvusException
log.info("test_search_no_connection: searching without connection")
self.search(client, collection_name,
data=vectors[:default_nq], anns_field=default_search_field,
search_params=default_search_params, limit=default_limit,
filter=default_search_exp,
check_task=CheckTasks.err_res,
check_items={"err_code": 1,
"err_msg": "should create connection first"})
check_items={"err_code": -1,
"err_msg": "'NoneType' object has no attribute 'search'"})
@pytest.mark.tags(CaseLabel.L1)
def test_search_no_collection(self):