mirror of https://github.com/milvus-io/milvus.git
test: add test cases (#28541)
1. modify test cases about output a non-existed field. issue: #28465 2. add cases about creating collection using different language 3. add test case about inserting a string value to a pk(int64) field 4. add test case about search with expression using double quotes. issue: #28365 Signed-off-by: nico <cheng.yuan@zilliz.com>pull/28878/head
parent
92b48c5384
commit
845851ea1c
|
@ -1749,6 +1749,36 @@ class TestCreateCollectionInvalid(TestcaseBase):
|
|||
schema, _ = self.collection_schema_wrap.init_collection_schema(fields=field_schema_list)
|
||||
self.init_collection_wrap(name=c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("invalid_name", ["中文", "español", "عربي", "हिंदी", "Русский"])
|
||||
def test_create_schema_with_different_language(self, invalid_name):
|
||||
"""
|
||||
target: test create collection with maximum fields
|
||||
method: create collection with maximum field number
|
||||
expected: raise exception
|
||||
"""
|
||||
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_vec_field(),
|
||||
cf.gen_string_field(name=invalid_name)]
|
||||
schema = cf.gen_collection_schema(fields)
|
||||
self.init_collection_wrap(schema=schema,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1701,
|
||||
ct.err_msg: "Invalid field name: %s" % invalid_name})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("invalid_name", ["中文", "español", "عربي", "हिंदी", "Русский"])
|
||||
def test_create_collection_with_different_language(self, invalid_name):
|
||||
"""
|
||||
target: test create collection with maximum fields
|
||||
method: create collection with maximum field number
|
||||
expected: raise exception
|
||||
"""
|
||||
schema = cf.gen_default_collection_schema()
|
||||
self.init_collection_wrap(name=invalid_name, schema=schema,
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 1100,
|
||||
ct.err_msg: "Invalid collection name: %s" % invalid_name})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
@pytest.mark.parametrize("default_value", ["abc"])
|
||||
@pytest.mark.skip(reason="issue #24634")
|
||||
|
|
|
@ -1251,6 +1251,24 @@ class TestInsertInvalid(TestcaseBase):
|
|||
mutation_res, _ = collection_w.insert(
|
||||
data=df, check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_insert_string_to_int64_pk_field(self):
|
||||
"""
|
||||
target: test insert, with using auto id is invalid, which are not int64
|
||||
method: create collection and insert entities in it
|
||||
expected: raise exception
|
||||
"""
|
||||
nb = 100
|
||||
collection_name = cf.gen_unique_str(prefix)
|
||||
collection_w = self.init_collection_wrap(name=collection_name)
|
||||
df = cf.gen_default_dataframe_data(nb)
|
||||
invalid_id = random.randint(0, nb)
|
||||
# df[ct.default_int64_field_name][invalid_id] = "2000000"
|
||||
df.at[invalid_id, ct.default_int64_field_name] = "2000000"
|
||||
error = {ct.err_code: 1,
|
||||
ct.err_msg: "The data in the same column must be of the same type."}
|
||||
mutation_res, _ = collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_insert_with_invalid_partition_name(self):
|
||||
"""
|
||||
|
|
|
@ -941,20 +941,23 @@ class TestCollectionSearchInvalid(TestcaseBase):
|
|||
"parameter[expected=JACCARD][actual=L2]"})
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_with_output_fields_not_exist(self):
|
||||
@pytest.mark.skip("issue #28465")
|
||||
@pytest.mark.parametrize("output_fields", ["int63", ""])
|
||||
@pytest.mark.parametrize("enable_dynamic", [True, False])
|
||||
def test_search_with_output_fields_not_exist(self, output_fields, enable_dynamic):
|
||||
"""
|
||||
target: test search with output fields
|
||||
method: search with non-exist output_field
|
||||
expected: raise exception
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix)[0]
|
||||
collection_w = self.init_collection_general(prefix, True, enable_dynamic_field=enable_dynamic)[0]
|
||||
# 2. search
|
||||
log.info("test_search_with_output_fields_not_exist: Searching collection %s" %
|
||||
collection_w.name)
|
||||
collection_w.search(vectors[:default_nq], default_search_field,
|
||||
default_search_params, default_limit,
|
||||
default_search_exp, output_fields=["int63"],
|
||||
default_search_exp, output_fields=[output_fields],
|
||||
check_task=CheckTasks.err_res,
|
||||
check_items={ct.err_code: 65535,
|
||||
ct.err_msg: "field int63 not exist"})
|
||||
|
@ -3345,6 +3348,40 @@ class TestCollectionSearch(TestcaseBase):
|
|||
ids = hits.ids
|
||||
assert set(ids).issubset(filter_ids_set)
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_expression_with_double_quotes(self):
|
||||
"""
|
||||
target: test search with expressions with double quotes
|
||||
method: test search with expressions with double quotes
|
||||
expected: searched successfully with correct limit(topK)
|
||||
"""
|
||||
# 1. initialize with data
|
||||
collection_w = self.init_collection_general(prefix)[0]
|
||||
string_value = [(f"'{cf.gen_str_by_length(3)}'{cf.gen_str_by_length(3)}\""
|
||||
f"{cf.gen_str_by_length(3)}\"") for _ in range(default_nb)]
|
||||
data = cf.gen_default_dataframe_data()
|
||||
data[default_string_field_name] = string_value
|
||||
insert_ids = data[default_int64_field_name]
|
||||
collection_w.insert(data)
|
||||
|
||||
# 2. create index
|
||||
index_param = {"index_type": "FLAT", "metric_type": "COSINE", "params": {}}
|
||||
collection_w.create_index("float_vector", index_param)
|
||||
collection_w.load()
|
||||
|
||||
# 3. search with expression
|
||||
_id = random.randint(0, default_nb)
|
||||
string_value[_id] = string_value[_id].replace("\"", "\\\"")
|
||||
expression = f"{default_string_field_name} == \"{string_value[_id]}\""
|
||||
log.info("test_search_with_expression: searching with expression: %s" % expression)
|
||||
search_res, _ = collection_w.search(vectors[:default_nq], default_search_field,
|
||||
default_search_params, default_limit, expression,
|
||||
check_task=CheckTasks.check_search_results,
|
||||
check_items={"nq": default_nq,
|
||||
"ids": insert_ids,
|
||||
"limit": 1})
|
||||
assert search_res[0].ids == [_id]
|
||||
|
||||
@pytest.mark.tags(CaseLabel.L2)
|
||||
def test_search_with_output_fields_empty(self, nb, nq, dim, auto_id, _async):
|
||||
"""
|
||||
|
|
Loading…
Reference in New Issue