19 Commits
Author SHA1 Message Date
21266e0cb7 test: fix nightly E2E test assertions for master #650/#651 failures (#48584)
## Summary

Fix 16 consistently failing test cases from nightly CI master build 650
(2026-03-26) and build 651 (2026-03-27). All failures reproduced across
all 3 configs (kafka / pulsar-mmap / woodpecker).

- Nightly build 650:
https://jenkins.milvus.io:18080/job/Milvus%20Nightly%20CI(new)/job/master/650/
- Nightly build 651:
https://jenkins.milvus.io:18080/job/Milvus%20Nightly%20CI(new)/job/master/651/

## Changes

### 1. `param_check.py` — fix `output_field_value_check` for sparse and
bfloat16 fields

**Fixes:**
- `test_search_by_pk_with_output_fields_all` — `KeyError: -1` (3/3
configs)
- `test_search_with_output_fields_all@TestMilvusClientSearchBasicV2` —
`TypeError: ufunc 'equal' not supported` (3/3 configs)

**Root cause:** Sparse vector comparison used hardcoded
`original[-1][_id]` instead of pk-based lookup. bfloat16/float16 vectors
returned as `bytes` cannot be compared via numpy `ufunc 'equal'`.

**Fix:** Use pk-based index for sparse comparison; skip value check for
`bytes` type (bfloat16/float16/binary).

### 2. `test_milvus_client_hybrid_search_v2.py` — fix expected output
fields

**Fixes:**
- `test_hybrid_search_with_diff_output_fields` — `AssertionError` (3/3
configs)

**Root cause:** Test excluded ALL sparse fields from expected output,
but only BM25-generated sparse fields cannot be output. User-inserted
nullable sparse vectors CAN be output.

**Fix:** Only exclude BM25 sparse fields
(`sparse_vector_field_name1/2`), keep `nullable_sparse_vec_field_name`.

### 3. `test_milvus_client_search_by_pk.py` /
`test_milvus_client_search_v2_new.py` — exclude DISKANN from mmap test

**Fixes:**
- `test_search_by_pk_each_index_with_mmap_enabled_search[DISKANN]` —
`alter_index_properties expect True, but got False` (3/3 configs)
- `test_each_index_with_mmap_enabled_search[DISKANN]` — same error (3/3
configs)

**Root cause:** DISKANN is a disk-based index and does not support mmap.
`alter_index_properties` correctly rejects it.

**Fix:** Exclude DISKANN from the `dense_float_index_types` parametrize
list in both files.

### 4. `test_milvus_client_search_group_by.py` — rewrite nonexistent
field group_by tests

**Fixes:**
-
`test_search_group_by_nonexistent_field_on_dynamic_enabled_collection[nonexist_field]`
— `AssertionError` (3/3 configs)
-
`test_search_group_by_nonexistent_field_on_dynamic_enabled_collection[21]`
— `TypeError: object of type 'Error' has no len()` (3/3 configs)

**Root cause:** With dynamic field enabled, group_by on a nonexistent
field name returns 1 result (all rows have null for that field → one
group), not `limit` results. Passing `21` (int) as field name is an
invalid type that the server rejects.

**Fix:** Split into 2 tests:
`test_search_group_by_nonexistent_field_on_dynamic_enabled_collection`
expects `limit=1`; new `test_search_group_by_invalid_field_type` expects
`err_res` with code 65535.

### 5. `test_milvus_client_search_pagination.py` — fix search params for
pagination topk

**Fixes:**
- `test_search_with_pagination_topk[100]` — `AssertionError` (3/3
configs)
- `test_search_with_pagination_topk[3000]` — `AssertionError` (3/3
configs)
- `test_search_with_pagination_topk[10000]` — `AssertionError` (3/3
configs)

**Root cause:** Missing `metric_type` and low `nprobe=10` caused poor
recall at high offset, leading to empty or incorrect pagination results.

**Fix:** Add `metric_type: COSINE` and increase `nprobe` to 128.

### 6. `test_milvus_client_search_v2.py` — fix recall, exists
expression, and metric type error

**Fixes:**
- `test_search_with_expression_auto_id` — `recall too low: got 313,
expected >= 800` (3/3 configs)
- `test_search_with_expression_exists[json_field]` — `TypeError: object
of type 'Error' has no len()` (3/3 configs)
- `test_search_with_expression_exists[float_array]` — same error (3/3
configs)
- `test_search_with_invalid_metric_type[JACCARD]` — `KeyError:
'err_msg'` (3/3 configs)
- `test_search_with_invalid_metric_type[HAMMING]` — `KeyError:
'err_msg'` (3/3 configs)
- `test_search_with_output_fields_all@TestSearchV2Shared` —
`AssertionError` (3/3 configs)

**Fixes applied:**
- **recall**: Add `metric_type: COSINE` + `nprobe: 64` to search params
- **exists expression**: Remove `json_field` and `float_array` from
parametrize (top-level field `exists` expression is not valid for these
types)
- **invalid metric type**: Add `err_msg` assertion (was only checking
`err_code`, `KeyError` when test accessed missing key)
- **output_fields_all**: Add `new_added_field` to expected output fields
list

### 7. `test_milvus_client_sparse_search.py` — update error message for
invalid metric type

**Fixes:**
- `test_sparse_search_invalid_metric_type[L2]` — `got 65535 ... expected
1100` (3/3 configs)
- `test_sparse_search_invalid_metric_type[COSINE]` — same error (3/3
configs)

**Root cause:** Server error message changed from `"only IP is
supported"` to `"metric type not match: invalid
parameter[expected=IP][actual=...]"`.

**Fix:** Update `err_msg` assertion to match new format.

## Test plan

- [x] `test_upsert_preserves_element_filter` — verified PASSED locally
- [x] `test_insert_without_connection` — verified PASSED locally
- [ ] Full nightly CI run to validate all 16 fixes

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

Signed-off-by: nico <cheng.yuan@zilliz.com>
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-31 11:57:32 +08:00
yanliang567andGitHub 4bbc01324b fix: handle NaN vs None comparison in output field value check for nullable fields (#47841)
## Summary

- Fix `output_field_value_check` in `param_check.py` to handle NaN vs
None comparison for nullable fields
- When nullable fields contain `None` values, `pandas.DataFrame`
converts them to `NaN`. The check function then fails comparing `NaN`
(from DataFrame) with `None` (from Milvus search results). This fix
treats both as equivalent null values.
- Remove resolved issue reference comments (`#47065`)

**Related issue**: #47065

### Changes

**Modified Files:**
- `tests/python_client/check/param_check.py`: Add NaN/None equivalence
check before asserting output field values
- `tests/python_client/milvus_client/test_add_field_feature.py`: Remove
resolved `#47065` comment
- `tests/python_client/milvus_client/test_milvus_client_collection.py`:
Remove resolved `#47065` comment

### Test Plan

- [x]
`test_search_by_pk_with_output_fields_and_consistency_level[Strong/Session/Bounded/Eventually]`
- 4 previously failing tests now PASS
- [x] All 98 search_by_pk tests: 93 passed + 4 fixed + 1 skipped
- [x] 13 null/nullable vector related tests all PASS

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

Signed-off-by: yanliang567 <82361606+yanliang567@users.noreply.github.com>
2026-02-25 16:14:46 +08:00
zhuwenxingandGitHub a80e003731 test: add snapshot API test cases (#47309)
## Summary
- Add comprehensive test cases for Milvus snapshot API functionality
- Cover snapshot create, list, describe, drop, restore operations
- Test various data types, index types, partition scenarios
- Add concurrent operation and data integrity tests
- Update pymilvus to 2.7.0rc122 for snapshot API support

## Test Coverage
- L0 smoke tests: basic snapshot lifecycle
- L1 tests: data types, partitions, indexes
- L2 tests: boundary conditions, negative cases, concurrency

## Related Issue
https://github.com/milvus-io/milvus/issues/44358

## Test plan
- [x] Run tests with `-n 6` parallel execution
- [x] Verify all tests pass (67 tests: 62 passed, 4 xfail)

---------

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
2026-01-28 19:41:33 +08:00
yanliang567andGitHub bdb56f6053 enhance: Optimize Python test logging from 60MB to 3-5MB per run (#47253)
## Summary

This PR optimizes Python test logging to reduce log file size from 60MB+
to 3-5MB per test run (90%+ reduction) while preserving full debugging
information for failed tests.

related issue:  #47256

### Key Improvements

- **Conditional Logging**: PASSED tests save only metadata, FAILED tests
preserve complete logs
- **Memory Buffering**: Eliminates runtime disk I/O (no file writes
during test execution)
- **Unified Reports**: Generates 2 formats
  - `test_report.json`: AI-friendly structured data
  - `test_report.html`: Human-readable with color-coded logs
- **Worker Parallelism**: Full support for `pytest -n` with data merging

### Performance Impact

| Metric | Before | After | Improvement |
|--------|--------|-------|-------------|
| **Log Size** (15K tests) | 60 MB | 3-5 MB | **-90%+** |
| **Memory Usage** (6 workers) | ~50 MB | ~450 MB | +400 MB |
| **CPU Overhead** | N/A | 0.0004% | Negligible |
| **Runtime I/O** | 75 seconds | 75 ms | **-99.9%** |

### Changes

**New Files:**
- `plugin/log_filter.py`: Conditional log handler with per-test memory
buffers
- `plugin/__init__.py`: Plugin package initialization

**Modified Files:**
- `config/log_config.py`: Simplified config (only JSON/HTML paths)
- `conftest.py`: Register log filter plugin
- `utils/util_log.py`: Removed redundant file handlers
- `utils/api_request.py`: Optimized API request logging
- `check/param_check.py`: Truncate long lists in error messages
- `common/common_func.py`: Removed verbose logging
- `pytest.ini`: Added log filter plugin

**Cleanup:**
- `milvus_client/test_add_field_feature.py`: Removed unused variable

### Test Plan

- [x] Syntax validation: All Python files pass `py_compile`
- [x] Module imports: All modules load successfully
- [x] Data structures: Verified serialization without report/buffer
objects
- [x] Log configuration: Confirmed only necessary attributes present
- [x] Small-scale test (17 tests):  Generated correct JSON + HTML
reports
- [x] Performance analysis: Memory/CPU profiling for 15K test scenario

### Example Output

**test_report.html** (human-readable):
- Beautiful color-coded UI
- Failed tests with full error traceback
- Expandable log sections by level (debug/info/warning/error)

**test_report.json** (AI-friendly):
```json
{
  "metadata": { "total_tests": 15000, ... },
  "summary": { "passed": 13500, "failed": 1500, ... },
  "tests": {
    "failed": [
      {
        "id": "test.py::test_func",
        "error": { "type": "AssertionError", ... },
        "logs": { "debug": [...], "error": [...] }
      }
    ]
  }
}
```

### Memory Safety

For the standard scenario (15K tests, 10% failure, 6 workers):
- Worker memory: ~53 MB each (318 MB total)
- Main process peak: ~112 MB
- Total system: **< 450 MB**  Safe

High-risk scenarios (>30% failure or >50K tests) may require optional
streaming optimizations (documented in performance analysis).

### Backward Compatibility

-  No breaking changes to external APIs
-  Existing test commands work unchanged
-  Compatible with all pytest plugins

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

Signed-off-by: Claude Opus 4.5 <noreply@anthropic.com>
Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2026-01-27 16:37:33 +08:00
624147740b test: fix timestamptz e2e case failure on Jenkins Weekly (#46210)
Issue: #46188 

Bug was caused by inconsistent version of tzdata as well as wrong month
assignment in convert_timestamptz function.
Also fix when debug_mode=True the compare function can correctly return
True or False.

---------

Signed-off-by: Eric Hou <eric.hou@zilliz.com>
Co-authored-by: Eric Hou <eric.hou@zilliz.com>
2025-12-09 16:09:15 +08:00
yanliang567andGitHub 1da75c0ee2 test: Update hybrid search tests to milvus client style (#45772)
related issue: #45326

---------

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2025-11-24 17:55:07 +08:00
zhuwenxingandGitHub 1e130683be test: add geometry datatype in checker (#44794)
/kind improvement

---------

Signed-off-by: zhuwenxing <wenxing.zhu@zilliz.com>
2025-10-24 11:28:04 +08:00
yanliang567andGitHub abb3aeacdf test: Refactor diskann and hsnw index, and update gen data functions (#43452)
related issue #40698
1. add diskann and hnsw index test
2. update gen_row_data and gen_column_data functions

---------

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2025-07-23 22:04:54 +08:00
yanliang567andGitHub e8011908ac test: Add tests for partition key filter issue and ttl eventually search (#43052)
related issue: #42918
1. add tests for ttl eventually search
2. add tests for partition key filter 
3. improve check query results for output fields 
4. verify some fix for rabitq index and update the test accordingly
5. update gen random float vector in (-1, 1) instead of (0,1)

---------

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2025-07-02 11:02:43 +08:00
yanliang567andGitHub ee659d50db test: [E2e Refactor] update search basic tests and add a pk_name instead of hard code (#41669)
related issue: https://github.com/milvus-io/milvus/issues/40698

---------

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2025-05-09 21:58:54 +08:00
nicoandGitHub 5c11c4add1 enhance: update pymilvus version (#41695)
Signed-off-by: nico <cheng.yuan@zilliz.com>
2025-05-08 10:04:54 +08:00
yanliang567andGitHub 2e434b2358 test: Add group size tests (#36240)
related issue: #36146

Signed-off-by: yanliang567 <yanliang.qiao@zilliz.com>
2024-09-13 16:13:08 +08:00
binbinandGitHub 4ba922876e Add test cases support for random primary keys (#25840)
Signed-off-by: binbin lv <binbin.lv@zilliz.com>
2023-07-25 19:39:12 +08:00
nicoandGitHub 9b64f12a6c Add output fields value check (#24255)
Signed-off-by: nico <cheng.yuan@zilliz.com>
2023-07-07 16:58:25 +08:00
binbinandGitHub e3b4e77915 Update cosine test cases (#24925)
Signed-off-by: Binbin Lv <binbin.lv@zilliz.com>
2023-06-20 11:26:41 +08:00
jingklandGitHub 619bab21c5 [test]Add the string testcase of delete (#17085)
Signed-off-by: jingkl <jingjing.jia@zilliz.com>
2022-05-19 09:35:56 +08:00
binbinandGitHub 640645265e Support service name to connect in pytest (#12186)
Signed-off-by: Binbin Lv <binbin.lv@zilliz.com>
2021-11-23 15:21:15 +08:00
ThreadDaoandGitHub 3cb79662d9 Fix parameter changed in query result check (#11886)
Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
2021-11-17 19:01:11 +08:00
binbinandGitHub eff75c7701 Replace sdk source and merge tests and tests20 (#7182)
Signed-off-by: Binbin Lv <binbin.lv@zilliz.com>
2021-08-20 11:00:56 +08:00