Skip to content

[Enhancement]: Improve Unit Test Coverage for PyMilvus Client #3190

@jac0626

Description

@jac0626

Is there an existing issue for this?

  • I have searched the existing issues

What would you like to be added?

Background

According to the latest coverage report, the overall unit test coverage for pymilvus/client is approximately 38%. Key modules like async_grpc_handler.py (23%) and entity_helper.py (9%) have significant gaps, presenting risks for future refactoring and feature additions.

Current Coverage Snapshot

  • pymilvus/client/schema_cache.py: 100% (New)
  • pymilvus/client/grpc_handler.py: 49%
  • pymilvus/client/async_grpc_handler.py: 23%
  • pymilvus/client/entity_helper.py: 9%
  • pymilvus/client/search_result.py: 21%

Objectives

Establish a long-term goal to increase core client coverage to >80% to ensure codebase stability and facilitate safe refactoring (e.g., upcoming metadata/db_name refactoring).

Action Plan

  1. Critical Path Testing: Prioritize coverage for insert, search, query, and delete operations in both sync and async handlers.
  2. Entity Helper Logic: Add granular unit tests for data packing and dynamic field handling in entity_helper.py.
  3. Error Handling: Increase coverage for gRPC error states and retry logic (the common except blocks).
  4. Async Coverage: Close the gap in AsyncGrpcHandler which is currently significantly under-tested compared to its synchronous counterpart.

How to Help

  • Every new PR should include corresponding unit tests and maintain or increase the current coverage percentage.
  • Encourage "test-only" PRs that specifically target low-coverage files identified above.

Why is this needed?

No response

Anything else?

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions