mirror of
https://github.com/milvus-io/milvus.git
synced 2026-07-21 10:15:43 +00:00
test: Optimize query aggregation tests and add count(*) validation (#47355)
## Summary Optimized query aggregation test structure by consolidating negative tests into shared collection, adding count(*) validation, and eliminating test redundancy. **Related issue**: #47353 ## Key Improvements ### 1. Test Structure Optimization - **Moved 7 negative tests** to TestQueryAggregationSharedV2 (uses shared collection) - test_group_by_field_not_in_output_fields - test_unsupported_vector_field - test_unsupported_aggregation_function_varchar - test_mixed_aggregation_and_non_aggregation_fields - test_invalid_aggregation_function_syntax - test_unsupported_float_type_for_groupby - test_unsupported_double_type_for_groupby - **Deleted redundant test** (test_nullable_field_aggregation - covered by shared collection) - **Deleted entire class** TestQueryAggregationNegativeV2 ### 2. count(*) Functionality Validation Added 3 new L1 tests to validate compatibility between original count(*) feature and new aggregation: - `test_count_star_without_group_by` - Validates original count(*) global counting feature - `test_count_star_vs_count_field` - Validates difference on nullable fields - count(*) = 3000 (includes NULL rows) - count(c2) = 2568 (excludes NULL values) - `test_count_star_with_group_by_error` - Validates proper error when count(*) used with GROUP BY ### 3. Test Deduplication - **Deleted** `test_filter_and_limit_with_aggregation` (L2/xfail, redundant) - **Enhanced** `test_group_by_with_limit` to cover both scenarios: - Scenario 1: limit without filter - Scenario 2: limit with filter (validates aggregation from filtered data) - Eliminated redundant independent collection creation ### 4. Performance Benefits - **~10-15 seconds faster** per test run (eliminated 8 collection create/drop cycles) - **~420 lines removed** (duplicate code: ~350 + ~73) - **Simplified structure** from 3 test classes to 2 ## Changes **Modified Files:** - `tests/python_client/testcases/test_query_aggregation.py` - TestQueryAggregationSharedV2: 26 tests (+9: 17 → 26) - TestQueryAggregationIndependentV2: 2 tests (-1: only JSON/Array remain) - Total: 28 tests (29 → 28, -1 due to deduplication) ## Test Plan - [x] All L0 tests passing: 3 passed in 6.78s - [x] All L1 tests passing: 20 passed, 2 skipped, 1 xfailed - [x] New count(*) tests validate: - count(*) returns total entity count (3000) - count(*) vs count(field) difference on nullable fields (3000 vs 2568) - count(*) + GROUP BY properly returns error - [x] Enhanced test_group_by_with_limit covers both limit scenarios - [x] All moved negative tests still validate error messages correctly - [x] Shared collection tests remain isolated via xdist_group marker 🤖 Generated with [Claude Code](https://claude.com/claude-code) Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
This commit is contained in: