mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
Add test cases of naming rules for some interfaces (#19051)
Signed-off-by: “nico” <cheng.yuan@zilliz.com> Signed-off-by: “nico” <cheng.yuan@zilliz.com>
This commit is contained in:
parent
9d40be7e67
commit
d476fb47be
@ -101,7 +101,7 @@ class TestCollectionParams(TestcaseBase):
|
||||
check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("name", [[], 1, [1, "2", 3], (1,), {1: 1}, None])
|
||||
@pytest.mark.parametrize("name", [[], 1, [1, "2", 3], (1,), {1: 1}, "qw$_o90", "1ns_", None])
|
||||
def test_collection_illegal_name(self, name):
|
||||
"""
|
||||
target: test collection with illegal name
|
||||
@ -109,10 +109,27 @@ class TestCollectionParams(TestcaseBase):
|
||||
expected: raise exception
|
||||
"""
|
||||
self._connect()
|
||||
error = {ct.err_code: -1, ct.err_msg: "`collection_name` value {} is illegal".format(name)}
|
||||
error = {ct.err_code: 1, ct.err_msg: "`collection_name` value {} is illegal".format(name)}
|
||||
self.collection_wrap.init_collection(name, schema=default_schema, check_task=CheckTasks.err_res,
|
||||
check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("name", ["_co11ection", "co11_ection"])
|
||||
def test_collection_naming_rules(self, name):
|
||||
"""
|
||||
target: test collection with valid name
|
||||
method: 1. connect milvus
|
||||
2. Create a field with a name which uses all the supported elements in the naming rules
|
||||
3. Create a collection with a name which uses all the supported elements in the naming rules
|
||||
expected: Collection created successfully
|
||||
"""
|
||||
self._connect()
|
||||
fields = [cf.gen_int64_field(), cf.gen_int64_field("_1nt"), cf.gen_float_vec_field("f10at_")]
|
||||
schema = cf.gen_collection_schema(fields=fields, primary_field=ct.default_int64_field_name)
|
||||
self.collection_wrap.init_collection(name, schema=schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={exp_name: name, exp_schema: schema})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("name", ["12-s", "12 s", "(mn)", "中文", "%$#", "a".join("a" for i in range(256))])
|
||||
def test_collection_invalid_name(self, name):
|
||||
|
||||
@ -138,9 +138,46 @@ class TestIndexParams(TestcaseBase):
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1, ct.err_msg: ""})
|
||||
|
||||
# TODO: not supported
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.skip(reason='not supported')
|
||||
@pytest.mark.parametrize("index_name", ["_1ndeX", "In_t0"])
|
||||
def test_index_naming_rules(self, index_name):
|
||||
"""
|
||||
target: test index naming rules
|
||||
method: 1. connect milvus
|
||||
2. Create a collection
|
||||
3. Create an index with an index_name which uses all the supported elements in the naming rules
|
||||
expected: Index create successfully
|
||||
"""
|
||||
self._connect()
|
||||
collection_w = self.init_collection_wrap()
|
||||
collection_w.create_index(default_field_name, default_index_params, index_name=index_name)
|
||||
assert len(collection_w.indexes) == 1
|
||||
assert collection_w.indexes[0].index_name == index_name
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("index_name", ["_1ndeX", "In_0"])
|
||||
def test_index_same_index_name_two_fields(self, index_name):
|
||||
"""
|
||||
target: test index naming rules
|
||||
method: 1. connect milvus
|
||||
2. Create a collection with more than 3 fields
|
||||
3. Create two indexes on two fields with the same index name
|
||||
expected: raise exception
|
||||
"""
|
||||
self._connect()
|
||||
collection_w = self.init_collection_wrap()
|
||||
self.index_wrap.init_index(collection_w.collection, default_field_name, default_index_params,
|
||||
index_name=index_name)
|
||||
self.index_wrap.init_index(collection_w.collection, ct.default_int64_field_name, default_index_params,
|
||||
index_name=index_name,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1,
|
||||
ct.err_msg: "CreateIndex failed: index already exist, "
|
||||
"but parameters are inconsistent"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.xfail(reason="issue 19181")
|
||||
@pytest.mark.parametrize("get_invalid_index_name", ["1nDex", "$in4t", "12 s", None, "(中文)"])
|
||||
def test_index_name_invalid(self, get_invalid_index_name):
|
||||
"""
|
||||
target: test index with error index name
|
||||
@ -151,8 +188,7 @@ class TestIndexParams(TestcaseBase):
|
||||
index_name = get_invalid_index_name
|
||||
collection_w = self.init_collection_wrap(name=c_name)
|
||||
self.index_wrap.init_index(collection_w.collection, default_field_name, default_index_params,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1, ct.err_msg: ""})
|
||||
index_name=get_invalid_index_name)
|
||||
|
||||
|
||||
class TestIndexOperation(TestcaseBase):
|
||||
|
||||
@ -179,6 +179,22 @@ class TestPartitionParams(TestcaseBase):
|
||||
check_items={ct.err_code: 1, 'err_msg': "is illegal"}
|
||||
)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("partition_name", ["_Partiti0n", "pArt1_ti0n"])
|
||||
def test_partition_naming_rules(self, partition_name):
|
||||
"""
|
||||
target: test partition naming rules
|
||||
method: 1. connect milvus
|
||||
2. Create a collection
|
||||
3. Create a partition with a name which uses all the supported elements in the naming rules
|
||||
expected: Partition create successfully
|
||||
"""
|
||||
self._connect()
|
||||
collection_w = self.init_collection_wrap()
|
||||
self.partition_wrap.init_partition(collection_w.collection, partition_name,
|
||||
check_task=CheckTasks.check_partition_property,
|
||||
check_items={"name": partition_name})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("partition_name", ct.get_invalid_strs)
|
||||
def test_partition_invalid_name(self, partition_name):
|
||||
|
||||
@ -37,6 +37,7 @@ default_int64_field_name = ct.default_int64_field_name
|
||||
default_float_field_name = ct.default_float_field_name
|
||||
default_bool_field_name = ct.default_bool_field_name
|
||||
default_string_field_name = ct.default_string_field_name
|
||||
default_index_params = {"index_type": "IVF_SQ8", "metric_type": "L2", "params": {"nlist": 64}}
|
||||
vectors = [[random.random() for _ in range(default_dim)] for _ in range(default_nq)]
|
||||
|
||||
uid = "test_search"
|
||||
@ -2792,6 +2793,106 @@ class TestCollectionSearch(TestcaseBase):
|
||||
"limit": nb_old + nb_new,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("name", ["_co11ection", "co11_ection"])
|
||||
@pytest.mark.parametrize("index_name", ["_1ndeX", "In_0"])
|
||||
def test_search_collection_naming_rules(self, nq, dim, name, index_name, _async):
|
||||
"""
|
||||
target: test search collection naming rules
|
||||
method: 1. Connect milvus
|
||||
2. Create a field with a name which uses all the supported elements in the naming rules
|
||||
3. Create a collection with a name which uses all the supported elements in the naming rules
|
||||
4. Create an index with a name which uses all the supported elements in the naming rules
|
||||
5. Insert data (5000) into collection
|
||||
6. Search collection
|
||||
expected: searched successfully
|
||||
"""
|
||||
nb = 5000
|
||||
field_name1 = "_1nt"
|
||||
field_name2 = "f10at_"
|
||||
collection_name = cf.gen_unique_str(name)
|
||||
self._connect()
|
||||
fields = [cf.gen_int64_field(), cf.gen_int64_field(field_name1),
|
||||
cf.gen_float_vec_field(field_name2, dim=dim)]
|
||||
schema = cf.gen_collection_schema(fields=fields, primary_field=ct.default_int64_field_name)
|
||||
collection_w = self.init_collection_wrap(name=collection_name, schema=schema,
|
||||
check_task=CheckTasks.check_collection_property,
|
||||
check_items={"name": collection_name, "schema": schema})
|
||||
collection_w.create_index(field_name1, default_index_params, index_name=index_name)
|
||||
int_values = pd.Series(data=[i for i in range(0, nb)])
|
||||
float_vec_values = gen_vectors(nb, dim)
|
||||
dataframe = pd.DataFrame({ct.default_int64_field_name: int_values,
|
||||
field_name1: int_values, field_name2: float_vec_values})
|
||||
collection_w.insert(dataframe)
|
||||
collection_w.load()
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
collection_w.search(vectors[:nq], field_name2, default_search_params,
|
||||
default_limit, _async=_async,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"limit": default_limit,
|
||||
"_async": _async})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", ["_PartiTi0n", "pArt1_ti0n"])
|
||||
def test_search_partition_naming_rules_without_index(self, nq, dim, auto_id, partition_name):
|
||||
"""
|
||||
target: test search collection naming rules
|
||||
method: 1. Connect milvus
|
||||
2. Create a collection
|
||||
3. Create a partition with a name which uses all the supported elements in the naming rules
|
||||
4. Insert data into collection
|
||||
5. without index with a name which uses all the supported elements in the naming rules
|
||||
6. Search partition (should successful)
|
||||
expected: searched successfully
|
||||
"""
|
||||
nb = 5000
|
||||
self._connect()
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, False, nb,
|
||||
auto_id=auto_id,
|
||||
dim=dim)[0:4]
|
||||
collection_w.create_partition(partition_name)
|
||||
insert_ids = cf.insert_data(collection_w, nb, auto_id=auto_id, dim=dim)[3]
|
||||
collection_w.load()
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
collection_w.search(vectors[:nq], default_search_field, default_search_params,
|
||||
default_limit, default_search_exp, [partition_name],
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L1)
|
||||
@pytest.mark.parametrize("partition_name", ["_PartiTi0n", "pArt1_ti0n"])
|
||||
@pytest.mark.parametrize("index_name", ["_1ndeX", "In_0"])
|
||||
def test_search_partition_naming_rules_with_index(self, nq, dim, auto_id, partition_name, index_name):
|
||||
"""
|
||||
target: test search collection naming rules
|
||||
method: 1. Connect milvus
|
||||
2. Create a collection
|
||||
3. Create a partition with a name which uses all the supported elements in the naming rules
|
||||
4. Insert data into collection
|
||||
5. with index with a name which uses all the supported elements in the naming rules
|
||||
6. Search partition (should successful)
|
||||
expected: searched successfully
|
||||
"""
|
||||
nb = 5000
|
||||
self._connect()
|
||||
collection_w, _, _, insert_ids = self.init_collection_general(prefix, False, nb,
|
||||
auto_id=auto_id,
|
||||
dim=dim)[0:4]
|
||||
collection_w.create_partition(partition_name)
|
||||
insert_ids = cf.insert_data(collection_w, nb, auto_id=auto_id, dim=dim)[3]
|
||||
collection_w.create_index(default_search_field, default_index_params, index_name=index_name)
|
||||
collection_w.load()
|
||||
vectors = [[random.random() for _ in range(dim)] for _ in range(nq)]
|
||||
collection_w.search(vectors[:nq], default_search_field, default_search_params,
|
||||
default_limit, default_search_exp, [partition_name],
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": nq,
|
||||
"ids": insert_ids,
|
||||
"limit": default_limit})
|
||||
|
||||
|
||||
class TestSearchBase(TestcaseBase):
|
||||
@pytest.fixture(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user