Skip to content

Commit f75c418

Browse files
MrLohcursoragent
andcommitted
fix: repair pre-existing e2e test failures
Bump pymilvus from 2.4.4 to 2.5.4 in test requirements — the old version depended on milvus-lite<2.5.0, causing pip to downgrade the freshly built 2.5.2 wheel to 2.4.12 from PyPI so tests never ran against the CI-built code. Guard the `from pymilvus import Milvus` import in util_pymilvus.py with try/except — the legacy Milvus class was removed in pymilvus 2.5 and its top-level import crashed conftest.py before any test could run. Fix test_milvus_client_collection_self_creation_default: - DataType.Array → DataType.ARRAY (enum naming) - metric_type "cosine" → "COSINE" (case-sensitive in C++) - Correct check_items to match schema field names (id_string, embeddings) and enable_dynamic_field=False - Fix list_indexes assertion to match actual field name Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 9a37dde commit f75c418

3 files changed

Lines changed: 12 additions & 5 deletions

File tree

tests/milvus_lite/test_milvus_lite_collection.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -301,21 +301,24 @@ def test_milvus_client_collection_self_creation_default(self, enable_milvus_loca
301301
schema.add_field("id_string", DataType.VARCHAR, max_length=64, is_primary=True, auto_id = False)
302302
schema.add_field("embeddings", DataType.FLOAT_VECTOR, dim=128)
303303
schema.add_field("title", DataType.VARCHAR, max_length=64, is_partition_key=True)
304-
schema.add_field("array_field", DataType.Array, max_capacity=12,
304+
schema.add_field("array_field", DataType.ARRAY, max_capacity=12,
305305
element_type_params={"type": DataType.VARCHAR, "max_length": 64})
306306
index_params = client_w.prepare_index_params()
307-
index_params.add_index("embeddings", metric_type="cosine")
307+
index_params.add_index("embeddings", metric_type="COSINE")
308308
index_params.add_index("title")
309309
client_w.create_collection(client, collection_name, schema=schema, index_params=index_params)
310310
collections = client_w.list_collections(client)[0]
311311
assert collection_name in collections
312312
client_w.describe_collection(client, collection_name,
313313
check_task=CheckTasks.check_describe_collection_property,
314314
check_items={"collection_name": collection_name,
315+
"enable_dynamic_field": False,
316+
"id_name": "id_string",
317+
"vector_name": "embeddings",
315318
"dim": 128,
316319
"consistency_level": 0})
317320
index = client_w.list_indexes(client, collection_name)[0]
318-
assert index == ['vector']
321+
assert "embeddings" in index
319322
# load_state = client_w.get_load_state(collection_name)[0]
320323
if client_w.has_collection(client, collection_name)[0]:
321324
client_w.drop_collection(client, collection_name)

tests/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ allure-pytest==2.7.0
1212
pytest-print==0.2.1
1313
pytest-level==0.1.1
1414
pytest-xdist==2.5.0
15-
pymilvus==2.4.4
15+
pymilvus==2.5.4
1616
pytest-rerunfailures==9.1.1
1717
git+https://github.com/Projectplace/pytest-tags
1818
ndg-httpsclient

tests/utils/util_pymilvus.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import numpy as np
99
import requests
1010
from sklearn import preprocessing
11-
from pymilvus import Milvus, DataType
11+
from pymilvus import DataType
12+
try:
13+
from pymilvus import Milvus
14+
except ImportError:
15+
Milvus = None
1216
from utils.util_log import test_log as log
1317
from utils.util_k8s import init_k8s_client_config
1418

0 commit comments

Comments
 (0)