Update test cases for error check (#6312)

* update cases for issues

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* update cases for issues

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* update insert cases for error check

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>

* update query cases for error check

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
This commit is contained in:
ThreadDao 2021-07-06 09:22:01 +08:00 committed by GitHub
parent 126635fe97
commit 972c44d82c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 46 additions and 47 deletions

View File

@ -569,7 +569,6 @@ class TestCollectionParams(TestcaseBase):
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="#6093")
def test_collection_multi_primary_fields(self):
"""
target: test collection with multi primary
@ -579,13 +578,9 @@ class TestCollectionParams(TestcaseBase):
self._connect()
int_field_one = cf.gen_int64_field(is_primary=True)
int_field_two = cf.gen_int64_field(name="int2", is_primary=True)
# error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one"}
schema, _ = self.collection_schema_wrap.init_collection_schema(fields=[int_field_one, int_field_two,
cf.gen_float_vec_field()])
# check_task=CheckTasks.err_res, check_items=error)
log.debug(schema)
collection_w, _ = self.collection_wrap.init_collection(name="c", schema=schema)
log.debug(collection_w.schema)
error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one."}
self.collection_schema_wrap.init_collection_schema(fields=[int_field_one, int_field_two, cf.gen_float_vec_field()],
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_collection_primary_inconsistent(self):
@ -1130,18 +1125,17 @@ class TestCollectionDataframe(TestcaseBase):
auto_id=True, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="#5967")
def test_construct_auto_id_true_no_insert(self):
"""
target: test construct with true auto_id
method: auto_id=True and not insert ids
method: auto_id=True and not insert ids(primary fields all values are None)
expected: verify num entities
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
df = cf.gen_default_dataframe_data(ct.default_nb)
df.drop(ct.default_int64_field_name, axis=1, inplace=True)
log.debug(df.head(3))
# df.drop(ct.default_int64_field_name, axis=1, inplace=True)
df[ct.default_int64_field_name] = None
self.collection_wrap.construct_from_dataframe(c_name, df, primary_field=ct.default_int64_field_name,
auto_id=True)
assert self.collection_wrap.num_entities == ct.default_nb

View File

@ -103,7 +103,7 @@ class TestInsertParams(TestcaseBase):
collection_w = self.init_collection_wrap(name=c_name)
columns = [ct.default_int64_field_name, ct.default_float_vec_field_name]
df = pd.DataFrame(columns=columns)
error = {ct.err_code: 1, ct.err_msg: "Cannot infer schema from empty dataframe"}
error = {ct.err_code: 0, ct.err_msg: "Cannot infer schema from empty dataframe"}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -117,7 +117,7 @@ class TestInsertParams(TestcaseBase):
collection_w = self.init_collection_wrap(name=c_name)
df = cf.gen_default_dataframe_data(10)
df.rename(columns={ct.default_int64_field_name: ' '}, inplace=True)
error = {ct.err_code: 1, ct.err_msg: "The types of schema and data do not match"}
error = {ct.err_code: 0, ct.err_msg: "The types of schema and data do not match"}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -131,7 +131,7 @@ class TestInsertParams(TestcaseBase):
collection_w = self.init_collection_wrap(name=c_name)
df = cf.gen_default_dataframe_data(10)
df.rename(columns={ct.default_int64_field_name: get_invalid_field_name}, inplace=True)
error = {ct.err_code: 1, ct.err_msg: "The types of schema and data do not match"}
error = {ct.err_code: 0, ct.err_msg: "The types of schema and data do not match"}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
def test_insert_dataframe_index(self):
@ -167,7 +167,7 @@ class TestInsertParams(TestcaseBase):
c_name = cf.gen_unique_str(prefix)
collection_w = self.init_collection_wrap(name=c_name)
data = cf.gen_numpy_data(nb=10)
error = {ct.err_code: 1, ct.err_msg: "Data type not support numpy.ndarray"}
error = {ct.err_code: 0, ct.err_msg: "Data type not support numpy.ndarray"}
collection_w.insert(data=data, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -216,6 +216,7 @@ class TestInsertParams(TestcaseBase):
assert collection_w.num_entities == 1
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="exception not MilvusException")
def test_insert_dim_not_match(self):
"""
target: test insert with not match dim
@ -231,6 +232,7 @@ class TestInsertParams(TestcaseBase):
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="exception not MilvusException")
def test_insert_binary_dim_not_match(self):
"""
target: test insert binary with dim not match
@ -256,7 +258,7 @@ class TestInsertParams(TestcaseBase):
collection_w = self.init_collection_wrap(name=c_name)
df = cf.gen_default_dataframe_data(10)
df.rename(columns={ct.default_float_field_name: "int"}, inplace=True)
error = {ct.err_code: 1, ct.err_msg: 'The types of schema and data do not match'}
error = {ct.err_code: 0, ct.err_msg: 'The types of schema and data do not match'}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -272,7 +274,7 @@ class TestInsertParams(TestcaseBase):
df = cf.gen_default_dataframe_data(nb)
new_float_value = pd.Series(data=[float(i) for i in range(nb)], dtype="float64")
df.iloc[:, 1] = new_float_value
error = {ct.err_code: 1, ct.err_msg: 'The types of schema and data do not match'}
error = {ct.err_code: 0, ct.err_msg: 'The types of schema and data do not match'}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -352,7 +354,7 @@ class TestInsertParams(TestcaseBase):
float_values = [np.float32(i) for i in range(nb)]
float_vec_values = cf.gen_vectors(nb, ct.default_dim)
data = [float_values, int_values, float_vec_values]
error = {ct.err_code: 1, ct.err_msg: 'The types of schema and data do not match'}
error = {ct.err_code: 0, ct.err_msg: 'The types of schema and data do not match'}
collection_w.insert(data=data, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -373,7 +375,7 @@ class TestInsertParams(TestcaseBase):
ct.default_float_vec_field_name: float_vec_values,
ct.default_int64_field_name: int_values
})
error = {ct.err_code: 1, ct.err_msg: 'The types of schema and data do not match'}
error = {ct.err_code: 0, ct.err_msg: 'The types of schema and data do not match'}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -411,7 +413,7 @@ class TestInsertOperation(TestcaseBase):
res_list, _ = self.connection_wrap.list_connections()
assert ct.default_alias not in res_list
data = cf.gen_default_list_data(10)
error = {ct.err_code: 1, ct.err_msg: 'should create connect first'}
error = {ct.err_code: 0, ct.err_msg: 'should create connect first'}
collection_w.insert(data=data, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -568,7 +570,7 @@ class TestInsertOperation(TestcaseBase):
schema = cf.gen_default_collection_schema(auto_id=True)
collection_w = self.init_collection_wrap(name=c_name, schema=schema)
df = cf.gen_default_dataframe_data(nb=100)
error = {ct.err_code: 0, ct.err_msg: 'Column cnt not match with schema'}
error = {ct.err_code: 0, ct.err_msg: 'Auto_id is True, primary field should not have data'}
collection_w.insert(data=df, check_task=CheckTasks.err_res, check_items=error)
assert collection_w.is_empty
@ -583,7 +585,7 @@ class TestInsertOperation(TestcaseBase):
schema = cf.gen_default_collection_schema(auto_id=True)
collection_w = self.init_collection_wrap(name=c_name, schema=schema)
data = cf.gen_default_list_data(nb=100)
error = {ct.err_code: 0, ct.err_msg: 'Column cnt not match with schema'}
error = {ct.err_code: 0, ct.err_msg: 'The data fields number is not match with schema'}
collection_w.insert(data=data, check_task=CheckTasks.err_res, check_items=error)
assert collection_w.is_empty
@ -713,7 +715,6 @@ class TestInsertAsync(TestcaseBase):
assert collection_w.num_entities == ct.default_nb
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="#6160")
def test_insert_async_callback(self):
"""
target: test insert with callback func
@ -724,6 +725,8 @@ class TestInsertAsync(TestcaseBase):
df = cf.gen_default_dataframe_data(nb=ct.default_nb)
future, _ = collection_w.insert(data=df, _async=True, _callback=assert_mutation_result)
future.done()
mutation_res = future.result()
assert mutation_res.primary_keys == df[ct.default_int64_field_name].values.tolist()
assert collection_w.num_entities == ct.default_nb
@pytest.mark.tags(CaseLabel.L2)
@ -744,7 +747,6 @@ class TestInsertAsync(TestcaseBase):
assert collection_w.num_entities == nb
@pytest.mark.tags(CaseLabel.L2)
@pytest.mark.xfail(reason="#6167")
def test_insert_async_callback_timeout(self):
"""
target: test insert async with callback
@ -754,10 +756,8 @@ class TestInsertAsync(TestcaseBase):
nb = 100000
collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix))
df = cf.gen_default_dataframe_data(nb)
err_msg = "timeout"
future, _ = collection_w.insert(data=df, _async=True, _callback=assert_mutation_result, timeout=1)
future.done()
with pytest.raises(Exception, match=err_msg):
with pytest.raises(Exception):
future.result()
@pytest.mark.tags(CaseLabel.L2)
@ -770,7 +770,7 @@ class TestInsertAsync(TestcaseBase):
collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix))
columns = [ct.default_int64_field_name, ct.default_float_vec_field_name]
df = pd.DataFrame(columns=columns)
error = {ct.err_code: 1, ct.err_msg: "Cannot infer schema from empty dataframe"}
error = {ct.err_code: 0, ct.err_msg: "Cannot infer schema from empty dataframe"}
collection_w.insert(data=df, _async=True, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L2)
@ -790,7 +790,4 @@ class TestInsertAsync(TestcaseBase):
def assert_mutation_result(mutation_res):
# todo
log.info(f"The result is {mutation_res}")
# mutation_res = future.result()
# assert mutation_res.insert_count == 100
assert mutation_res.insert_count == ct.default_nb

View File

@ -132,6 +132,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(default_term_expr, check_task=CheckTasks.check_query_results, check_items={exp_res: res})
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_not_existed_field(self):
"""
target: test query with not existed field
@ -144,6 +145,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(term_expr, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_unsupported_field(self):
"""
target: test query on unsupported field
@ -156,6 +158,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(term_expr, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_non_primary_field(self):
"""
target: test query on non-primary field
@ -174,6 +177,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(default_term_expr, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_wrong_term_keyword(self):
"""
target: test query with wrong term expr keyword
@ -194,6 +198,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(expr_3, check_task=CheckTasks.err_res, check_items=error_3)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
@pytest.mark.parametrize("expr", [f'{ct.default_int64_field_name} in 1',
f'{ct.default_int64_field_name} in "in"',
f'{ct.default_int64_field_name} in (mn)'])
@ -220,6 +225,7 @@ class TestQueryBase(TestcaseBase):
assert len(res) == 0
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_inconstant_term_array(self):
"""
target: test query with term expr that field and array are inconsistent
@ -233,6 +239,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(term_expr, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
def test_query_expr_mix_term_array(self):
"""
target: test query with mix type value expr
@ -246,6 +253,7 @@ class TestQueryBase(TestcaseBase):
collection_w.query(term_expr, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6259")
@pytest.mark.parametrize("constant", [[1], (), {}])
def test_query_expr_non_constant_array_term(self, constant):
"""
@ -297,18 +305,18 @@ class TestQueryBase(TestcaseBase):
assert set(res_1[0].keys()) == set(fields)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("output_fields", [[ct.default_float_vec_field_name],
[ct.default_int64_field_name, ct.default_float_vec_field_name]])
def test_query_output_vec_field(self, output_fields):
def test_query_output_vec_field(self):
"""
target: test query with vec output field
method: specify vec field as output field
expected: raise exception
"""
collection_w, vectors, _, = self.init_collection_general(prefix, insert_data=True)
fields = [[ct.default_float_vec_field_name], [ct.default_int64_field_name, ct.default_float_vec_field_name]]
error = {ct.err_code: 1, ct.err_msg: "Query does not support vector field currently"}
collection_w.query(default_term_expr, output_fields=output_fields,
check_task=CheckTasks.err_res, check_items=error)
for output_fields in fields:
collection_w.query(default_term_expr, output_fields=output_fields,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_query_output_primary_field(self):
@ -322,7 +330,6 @@ class TestQueryBase(TestcaseBase):
assert list(res[0].keys()) == [ct.default_int64_field_name]
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #6074")
@pytest.mark.parametrize("output_fields", [["int"],
[ct.default_int64_field_name, "int"]])
def test_query_output_not_existed_field(self, output_fields):
@ -332,8 +339,8 @@ class TestQueryBase(TestcaseBase):
expected: raise exception
"""
collection_w, vectors, _, = self.init_collection_general(prefix, insert_data=True)
error = {ct.err_code: 1, ct.err_msg: 'cannot find field'}
collection_w.query(default_term_expr, output_fields=output_fields, check_items=CheckTasks.err_res, check_task=error)
error = {ct.err_code: 1, ct.err_msg: 'Field int not exist'}
collection_w.query(default_term_expr, output_fields=output_fields, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_query_empty_output_fields(self):
@ -348,16 +355,17 @@ class TestQueryBase(TestcaseBase):
assert list(query_res[0].keys()) == fields
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("fields", ct.get_invalid_strs)
def test_query_invalid_output_fields(self, fields):
@pytest.mark.xfail(reason="exception not MilvusException")
@pytest.mark.parametrize("output_fields", ["12-s", 1, [1, "2", 3], (1,), {1: 1}])
def test_query_invalid_output_fields(self, output_fields):
"""
target: test query with invalid output fields
method: query with invalid field fields
expected: raise exception
"""
collection_w, vectors, _, = self.init_collection_general(prefix, insert_data=True)
error = {ct.err_code: 1, ct.err_msg: 'Invalid query format. must be a list'}
collection_w.query(default_term_expr, output_fields=fields, check_items=CheckTasks.err_res, check_task=error)
error = {ct.err_code: 0, ct.err_msg: f'Invalid query format. \'output_fields\' must be a list'}
collection_w.query(default_term_expr, output_fields=output_fields, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
def test_query_partition(self):
@ -390,7 +398,7 @@ class TestQueryBase(TestcaseBase):
assert partition_w.num_entities == ct.default_nb
error = {ct.err_code: 1, ct.err_msg: f'collection {collection_w.name} was not loaded into memory'}
collection_w.query(default_term_expr, partition_names=[partition_w.name],
check_items=CheckTasks.err_res, check_task=error)
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_query_default_partition(self):
@ -430,7 +438,7 @@ class TestQueryBase(TestcaseBase):
partition_names = cf.gen_unique_str()
error = {ct.err_code: 1, ct.err_msg: f'PartitonName: {partition_names} not found'}
collection_w.query(default_term_expr, partition_names=[partition_names],
check_items=CheckTasks.err_res, check_task=error)
check_task=CheckTasks.err_res, check_items=error)
class TestQueryOperation(TestcaseBase):