mirror of https://github.com/milvus-io/milvus.git
test: add null and default test cases (#36612)
issue: #36129 Signed-off-by: binbin lv <binbin.lv@zilliz.com>pull/36668/head^2
parent
1fded42277
commit
0d57ff01a6
|
@ -239,6 +239,14 @@ class ResponseChecker:
|
|||
assert res["fields"][1]["name"] == check_items.get("vector_name", "vector")
|
||||
if check_items.get("dim", None) is not None:
|
||||
assert res["fields"][1]["params"]["dim"] == check_items.get("dim")
|
||||
if check_items.get("nullable_fields", None) is not None:
|
||||
nullable_fields = check_items.get("nullable_fields")
|
||||
if not isinstance(nullable_fields, list):
|
||||
log.error("nullable_fields should be a list including all the nullable fields name")
|
||||
assert False
|
||||
for field in res["fields"]:
|
||||
if field["name"] in nullable_fields:
|
||||
assert field["nullable"] is True
|
||||
assert res["fields"][0]["is_primary"] is True
|
||||
assert res["fields"][0]["field_id"] == 100 and (res["fields"][0]["type"] == 5 or 21)
|
||||
assert res["fields"][1]["field_id"] == 101 and res["fields"][1]["type"] == 101
|
||||
|
|
|
@ -291,8 +291,8 @@ class TestMilvusClientCollectionValid(TestcaseBase):
|
|||
client_w.drop_collection(client, collection_name)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
@pytest.mark.skip(reason="pymilvus issue 1864")
|
||||
def test_milvus_client_collection_self_creation_default(self):
|
||||
@pytest.mark.parametrize("nullable", [True, False])
|
||||
def test_milvus_client_collection_self_creation_default(self, nullable):
|
||||
"""
|
||||
target: test fast create collection normal case
|
||||
method: create collection
|
||||
|
@ -300,27 +300,35 @@ class TestMilvusClientCollectionValid(TestcaseBase):
|
|||
"""
|
||||
client = self._connect(enable_milvus_client_api=True)
|
||||
collection_name = cf.gen_unique_str(prefix)
|
||||
dim = 128
|
||||
# 1. create collection
|
||||
schema = client_w.create_schema(client, enable_dynamic_field=False)[0]
|
||||
schema.add_field("id_string", DataType.VARCHAR, max_length=64, is_primary=True, auto_id = False)
|
||||
schema.add_field("embeddings", DataType.FLOAT_VECTOR, dim=128)
|
||||
schema.add_field("embeddings", DataType.FLOAT_VECTOR, dim=dim)
|
||||
schema.add_field("title", DataType.VARCHAR, max_length=64, is_partition_key=True)
|
||||
schema.add_field("array_field", DataType.Array, max_capacity=12,
|
||||
element_type_params={"type": DataType.VARCHAR, "max_length": 64})
|
||||
index_params = client_w.prepare_index_params()
|
||||
index_params.add_index("embeddings", metric_type="cosine")
|
||||
index_params.add_index("title")
|
||||
client_w.create_collection(client, collection_name, schema=schema, index_params=index_params)
|
||||
schema.add_field("nullable_field", DataType.INT64, nullable=nullable, default_value=10)
|
||||
schema.add_field("array_field", DataType.ARRAY, element_type=DataType.INT64, max_capacity=12,
|
||||
max_length=64, nullable=nullable)
|
||||
index_params = client_w.prepare_index_params(client)[0]
|
||||
index_params.add_index("embeddings", metric_type="COSINE")
|
||||
# index_params.add_index("title")
|
||||
client_w.create_collection(client, collection_name, dimension=dim, schema=schema, index_params=index_params)
|
||||
collections = client_w.list_collections(client)[0]
|
||||
assert collection_name in collections
|
||||
check_items = {"collection_name": collection_name,
|
||||
"dim": dim,
|
||||
"consistency_level": 0,
|
||||
"enable_dynamic_field": False,
|
||||
"num_partitions": 16,
|
||||
"id_name": "id_string",
|
||||
"vector_name": "embeddings"}
|
||||
if nullable:
|
||||
check_items["nullable_fields"] = ["nullable_field", "array_field"]
|
||||
client_w.describe_collection(client, collection_name,
|
||||
check_task=CheckTasks.check_describe_collection_property,
|
||||
check_items={"collection_name": collection_name,
|
||||
"dim": 128,
|
||||
"consistency_level": 0})
|
||||
check_items=check_items)
|
||||
index = client_w.list_indexes(client, collection_name)[0]
|
||||
assert index == ['vector']
|
||||
# load_state = client_w.get_load_state(collection_name)[0]
|
||||
assert index == ['embeddings']
|
||||
if client_w.has_collection(client, collection_name)[0]:
|
||||
client_w.drop_collection(client, collection_name)
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@ from common.common_type import CaseLabel, CheckTasks
|
|||
from utils.util_pymilvus import *
|
||||
from common.constants import *
|
||||
from pymilvus.orm.types import CONSISTENCY_STRONG, CONSISTENCY_BOUNDED, CONSISTENCY_SESSION, CONSISTENCY_EVENTUALLY
|
||||
from pymilvus import DataType
|
||||
from base.high_level_api_wrapper import HighLevelApiWrapper
|
||||
client_w = HighLevelApiWrapper()
|
||||
|
||||
|
@ -170,7 +171,7 @@ class TestMilvusClientSearchValid(TestcaseBase):
|
|||
******************************************************************
|
||||
"""
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
def test_milvus_client_search_query_default(self):
|
||||
"""
|
||||
target: test search (high level api) normal case
|
||||
|
@ -214,6 +215,37 @@ class TestMilvusClientSearchValid(TestcaseBase):
|
|||
client_w.release_collection(client, collection_name)
|
||||
client_w.drop_collection(client, collection_name)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip(reason="issue #36484")
|
||||
@pytest.mark.parametrize("nullable", [True, False])
|
||||
def test_milvus_client_search_query_self_creation_default(self, nullable):
|
||||
"""
|
||||
target: test fast create collection normal case
|
||||
method: create collection
|
||||
expected: create collection with default schema, index, and load successfully
|
||||
"""
|
||||
client = self._connect(enable_milvus_client_api=True)
|
||||
collection_name = cf.gen_unique_str(prefix)
|
||||
dim = 128
|
||||
# 1. create collection
|
||||
schema = client_w.create_schema(client, enable_dynamic_field=False)[0]
|
||||
schema.add_field(default_primary_key_field_name, DataType.VARCHAR, max_length=64, is_primary=True, auto_id = False)
|
||||
schema.add_field(default_vector_field_name, DataType.FLOAT_VECTOR, dim=dim)
|
||||
schema.add_field(default_string_field_name, DataType.VARCHAR, max_length=64, is_partition_key=True)
|
||||
schema.add_field("nullable_field", DataType.INT64, nullable=True, default_value=10)
|
||||
schema.add_field("array_field", DataType.ARRAY, element_type=DataType.INT64, max_capacity=12,
|
||||
max_length=64, nullable=True)
|
||||
index_params = client_w.prepare_index_params(client)[0]
|
||||
index_params.add_index(default_vector_field_name, metric_type="COSINE")
|
||||
client_w.create_collection(client, collection_name, dimension=dim, schema=schema, index_params=index_params)
|
||||
# 2. insert
|
||||
rng = np.random.default_rng(seed=19530)
|
||||
rows = [{default_primary_key_field_name: str(i), default_vector_field_name: list(rng.random((1, default_dim))[0]),
|
||||
default_string_field_name: str(i), "nullable_field": None, "array_field": None} for i in range(default_nb)]
|
||||
client_w.insert(client, collection_name, rows)
|
||||
if client_w.has_collection(client, collection_name)[0]:
|
||||
client_w.drop_collection(client, collection_name)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
def test_milvus_client_rename_search_query_default(self):
|
||||
"""
|
||||
|
|
|
@ -3142,6 +3142,28 @@ class TestDescribeCollection(TestcaseBase):
|
|||
log.info(res)
|
||||
assert description == res
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip(reason="issue #36596")
|
||||
def test_collection_describe_nullable_default_value(self):
|
||||
"""
|
||||
target: test describe collection with nullable and default_value fields
|
||||
method: create a collection with nullable and default_value fields, then check its information when describe
|
||||
expected: return correct information
|
||||
"""
|
||||
collection_w = self.init_collection_general(prefix, False,
|
||||
nullable_fields={ct.default_float_field_name: 0},
|
||||
default_value_fields={ct.default_string_field_name: "1"})[0]
|
||||
res = collection_w.describe()[0]
|
||||
for field in res["fields"]:
|
||||
if field["name"] == ct.default_float_field_name:
|
||||
assert field["nullable"] is True
|
||||
if field["name"] == ct.default_string_field_name:
|
||||
if "default_value" not in field.keys():
|
||||
log.error("there is no default_value key in the result of describe collection, please file a bug")
|
||||
assert False
|
||||
else:
|
||||
assert field["default_value"] == "1"
|
||||
|
||||
|
||||
class TestReleaseAdvanced(TestcaseBase):
|
||||
@pytest.mark.tags(CaseLabel.L0)
|
||||
|
|
Loading…
Reference in New Issue