update cases for primary_field and auto_id (#5952)

Signed-off-by: ThreadDao <yufen.zong@zilliz.com>
pull/5960/head
ThreadDao 2021-06-22 11:04:08 +08:00 committed by GitHub
parent c863a193de
commit cdc89648cf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 166 additions and 132 deletions

View File

@ -25,9 +25,9 @@ def gen_str_by_length(length=8):
return "".join(random.choice(string.ascii_letters + string.digits) for _ in range(length))
def gen_int64_field(name=ct.default_int64_field_name, is_primary=False, description=ct.default_desc):
def gen_int64_field(name=ct.default_int64_field_name, description=ct.default_desc, is_primary=False, **kwargs):
int64_field, _ = ApiFieldSchemaWrapper().init_field_schema(name=name, dtype=DataType.INT64, description=description,
is_primary=is_primary)
is_primary=is_primary, **kwargs)
return int64_field
@ -53,16 +53,16 @@ def gen_binary_vec_field(name=ct.default_binary_vec_field_name, is_primary=False
return binary_vec_field
def gen_default_collection_schema(description=ct.default_desc, primary_field=ct.default_int64_field_name):
def gen_default_collection_schema(description=ct.default_desc, primary_field=ct.default_int64_field_name, auto_id=False):
fields = [gen_int64_field(), gen_float_field(), gen_float_vec_field()]
schema, _ = ApiCollectionSchemaWrapper().init_collection_schema(fields=fields, description=description,
primary_field=primary_field)
primary_field=primary_field, auto_id=auto_id)
return schema
def gen_collection_schema(fields, primary_field=None, description=ct.default_desc):
def gen_collection_schema(fields, primary_field=None, description=ct.default_desc, auto_id=False):
schema, _ = ApiCollectionSchemaWrapper().init_collection_schema(fields=fields, primary_field=primary_field,
description=description)
description=description, auto_id=auto_id)
return schema

View File

@ -21,7 +21,7 @@ class TestCollectionParams(TestcaseBase):
""" Test case of collection interface """
@pytest.fixture(scope="function", params=ct.get_invalid_strs)
def get_invalid_type_schema(self, request):
def get_none_removed_invalid_strings(self, request):
if request.param is None:
pytest.skip("None schema is valid")
yield request.param
@ -98,6 +98,7 @@ class TestCollectionParams(TestcaseBase):
check_items=error)
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.xfail(reason="issue #5947")
def test_collection_dup_name(self):
"""
target: test collection with dup name
@ -115,6 +116,7 @@ class TestCollectionParams(TestcaseBase):
assert collection_w.name, _ in self.utility_wrap.list_collections()[0]
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #5947")
def test_collection_dup_name_with_desc(self):
"""
target: test collection with dup name
@ -144,14 +146,13 @@ class TestCollectionParams(TestcaseBase):
c_name = cf.gen_unique_str(prefix)
self.init_collection_wrap(name=c_name, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: default_schema})
fields = [cf.gen_int64_field()]
fields = [cf.gen_int64_field(is_primary=True)]
schema = cf.gen_collection_schema(fields=fields)
error = {ct.err_code: 0, ct.err_msg: "The collection already exist, but the schema isnot the same as the "
"schema passed in"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
# @pytest.mark.xfail(reason="issue #5873")
def test_collection_dup_name_new_primary(self):
"""
target: test collection with dup name and new primary_field schema
@ -197,8 +198,8 @@ class TestCollectionParams(TestcaseBase):
dim = collection_w.schema.fields[-1].params['dim']
assert dim == ct.default_dim
@pytest.mark.tags(CaseLabel.L1)
def test_collection_dup_name_invalid_schema_type(self, get_invalid_type_schema):
@pytest.mark.tags(CaseLabel.L2)
def test_collection_dup_name_invalid_schema_type(self, get_none_removed_invalid_strings):
"""
target: test collection with dup name and invalid schema
method: 1. default schema 2. invalid schema
@ -209,12 +210,13 @@ class TestCollectionParams(TestcaseBase):
collection_w = self.init_collection_wrap(name=c_name, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: default_schema})
error = {ct.err_code: 0, ct.err_msg: "Schema type must be schema.CollectionSchema"}
schema = get_invalid_type_schema
schema = get_none_removed_invalid_strings
self.collection_wrap.init_collection(collection_w.name, schema=schema,
check_task=CheckTasks.err_res, check_items=error)
assert collection_w.name == c_name
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="#5947")
def test_collection_dup_name_same_schema(self):
"""
target: test collection with dup name and same schema
@ -244,7 +246,7 @@ class TestCollectionParams(TestcaseBase):
self.collection_wrap.init_collection(c_name, schema=None, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
def test_collection_invalid_type_schema(self, get_invalid_type_schema):
def test_collection_invalid_type_schema(self, get_none_removed_invalid_strings):
"""
target: test collection with invalid schema
method: create collection with non-CollectionSchema type schema
@ -253,7 +255,7 @@ class TestCollectionParams(TestcaseBase):
self._connect()
c_name = cf.gen_unique_str(prefix)
error = {ct.err_code: 1, ct.err_msg: "schema type must be schema.CollectionSchema"}
self.collection_wrap.init_collection(c_name, schema=get_invalid_type_schema,
self.collection_wrap.init_collection(c_name, schema=get_none_removed_invalid_strings,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@ -291,7 +293,7 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field, _ = self.field_schema_wrap.init_field_schema(name=name, dtype=5)
field, _ = self.field_schema_wrap.init_field_schema(name=name, dtype=5, is_primary=True)
vec_field = cf.gen_float_vec_field()
schema = cf.gen_collection_schema(fields=[field, vec_field])
error = {ct.err_code: 1, ct.err_msg: "expected one of: bytes, unicode"}
@ -307,7 +309,7 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field, _ = self.field_schema_wrap.init_field_schema(name=name, dtype=5)
field, _ = self.field_schema_wrap.init_field_schema(name=name, dtype=DataType.INT64, is_primary=True)
vec_field = cf.gen_float_vec_field()
schema = cf.gen_collection_schema(fields=[field, vec_field])
error = {ct.err_code: 1, ct.err_msg: "Invalid field name"}
@ -322,7 +324,7 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field, _ = self.field_schema_wrap.init_field_schema(name=None, dtype=5)
field, _ = self.field_schema_wrap.init_field_schema(name=None, dtype=DataType.INT64, is_primary=True)
schema = cf.gen_collection_schema(fields=[field, cf.gen_float_vec_field()])
error = {ct.err_code: 1, ct.err_msg: "You should specify the name of field"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@ -337,9 +339,10 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
error = {ct.err_code: 0, ct.err_msg: "Field type must be of DataType"}
self.field_schema_wrap.init_field_schema(name="test", dtype=dtype,
self.field_schema_wrap.init_field_schema(name="test", dtype=dtype, is_primary=True,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L2)
def test_collection_field_dtype_float_value(self):
"""
target: test collection with float type
@ -348,12 +351,13 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_int64_field_name, dtype=5.0)
field, _ = self.field_schema_wrap.init_field_schema(name=ct.default_int64_field_name, dtype=5.0, is_primary=True)
schema = cf.gen_collection_schema(fields=[field, cf.gen_float_vec_field()])
error = {ct.err_code: 0, ct.err_msg: "Field type must be of DataType"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.xfail(reason="#5918")
def test_collection_empty_fields(self):
"""
target: test collection with empty fields
@ -362,7 +366,7 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
schema = cf.gen_collection_schema(fields=[])
schema = cf.gen_collection_schema(fields=[], primary_field=ct.default_int64_field_name)
error = {ct.err_code: 0, ct.err_msg: "The field of the schema cannot be empty"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@ -375,30 +379,26 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field_one = cf.gen_int64_field()
field_one = cf.gen_int64_field(is_primary=True)
field_two = cf.gen_int64_field()
schema = cf.gen_collection_schema(fields=[field_one, field_two])
schema = cf.gen_collection_schema(fields=[field_one, field_two, cf.gen_float_vec_field()])
error = {ct.err_code: 0, ct.err_msg: "duplicated field name"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
assert not self.utility_wrap.has_collection(c_name)[0]
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for required int primary field")
@pytest.mark.parametrize("field", [cf.gen_float_vec_field(), cf.gen_binary_vec_field()])
def test_collection_only_vector(self, field):
def test_collection_only_vector_field(self, field):
"""
target: test collection just with vec field
method: create with float-vec fields
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
schema = cf.gen_collection_schema(fields=[field])
error = {ct.err_code: 0, ct.err_msg: "Field type must be of DataType"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
error = {ct.err_code: 0, ct.err_msg: "Must be have a primary key field"}
self.collection_schema_wrap.init_collection_schema([field], check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for required int primary field")
def test_collection_multi_float_vectors(self):
"""
target: test collection with multi float vectors
@ -407,13 +407,12 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
fields = [cf.gen_float_vec_field(), cf.gen_float_vec_field(name="tmp")]
schema = cf.gen_collection_schema(fields=fields)
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_vec_field(), cf.gen_float_vec_field(name="tmp")]
schema = cf.gen_collection_schema(fields=fields, auto_id=True)
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: schema})
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for required int primary field")
def test_collection_mix_vectors(self):
"""
target: test collection with mix vectors
@ -422,8 +421,8 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
fields = [cf.gen_float_vec_field(), cf.gen_binary_vec_field()]
schema = cf.gen_collection_schema(fields=fields)
fields = [cf.gen_int64_field(is_primary=True), cf.gen_float_vec_field(), cf.gen_binary_vec_field()]
schema = cf.gen_collection_schema(fields=fields, auto_id=True)
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: schema})
@ -436,12 +435,11 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
schema = cf.gen_collection_schema([cf.gen_int64_field()])
schema = cf.gen_collection_schema([cf.gen_int64_field(is_primary=True)])
error = {ct.err_code: 0, ct.err_msg: "The schema must have vector column"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for debugging")
@pytest.mark.tags(CaseLabel.L1)
def test_collection_without_primary_field(self):
"""
target: test collection without primary field
@ -449,16 +447,14 @@ class TestCollectionParams(TestcaseBase):
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
int_fields, _ = self.field_schema_wrap.init_field_schema(name=ct.default_int64_field_name, dtype=DataType.INT64)
vec_fields, _ = self.field_schema_wrap.init_field_schema(name=ct.default_float_vec_field_name,
dtype=DataType.FLOAT_VECTOR)
schema, _ = self.collection_schema_wrap.init_collection_schema([int_fields, vec_fields])
error = {ct.err_code: 0, ct.err_msg: "primary field is required"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
dtype=DataType.FLOAT_VECTOR, dim=ct.default_dim)
error = {ct.err_code: 0, ct.err_msg: "Must be have a primary key field"}
self.collection_schema_wrap.init_collection_schema([int_fields, vec_fields],
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
def test_collection_is_primary_false(self):
"""
target: test collection with all is_primary false
@ -466,15 +462,12 @@ class TestCollectionParams(TestcaseBase):
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
fields = [cf.gen_int64_field(is_primary=False), cf.gen_float_field(is_primary=False),
cf.gen_float_vec_field(is_primary=False)]
schema, _ = self.collection_schema_wrap.init_collection_schema(fields)
error = {ct.err_code: 0, ct.err_msg: "primary field is required"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
error = {ct.err_code: 0, ct.err_msg: "Must be have a primary key field"}
self.collection_schema_wrap.init_collection_schema(fields, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
@pytest.mark.parametrize("is_primary", ct.get_invalid_strs)
def test_collection_invalid_is_primary(self, is_primary):
"""
@ -489,7 +482,7 @@ class TestCollectionParams(TestcaseBase):
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
@pytest.mark.xfail(reason="#5918")
@pytest.mark.parametrize("primary_field", ["12-s", "12 s", "(mn)", "中文", "%$#", "a".join("a" for i in range(256))])
def test_collection_invalid_primary_field(self, primary_field):
"""
@ -499,13 +492,12 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
fields = [cf.gen_int64_field(), cf.gen_float_vec_field()]
schema = cf.gen_collection_schema(fields, primary_field=primary_field)
error = {ct.err_code: 0, ct.err_msg: "invalid primary field"}
self.collection_wrap.init_collection(cf.gen_unique_str(prefix), schema=schema,
check_task=CheckTasks.err_res, check_items=error)
self.collection_schema_wrap.init_collection_schema(fields=fields, primary_field=primary_field,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
@pytest.mark.xfail(reason="#5918")
@pytest.mark.parametrize("primary_field", [[], 1, [1, "2", 3], (1,), {1: 1}, None])
def test_collection_non_string_primary_field(self, primary_field):
"""
@ -515,13 +507,12 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
fields = [cf.gen_int64_field(), cf.gen_float_vec_field()]
schema = cf.gen_collection_schema(fields, primary_field=primary_field)
error = {ct.err_code: 0, ct.err_msg: "invalid primary field"}
self.collection_wrap.init_collection(cf.gen_unique_str(prefix), schema=schema,
check_task=CheckTasks.err_res, check_items=error)
self.collection_schema_wrap.init_collection_schema(fields, primary_field=primary_field,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
@pytest.mark.xfail(reason="#5918")
def test_collection_not_existed_primary_field(self):
"""
target: test collection with not exist primary field
@ -530,10 +521,11 @@ class TestCollectionParams(TestcaseBase):
"""
self._connect()
fake_field = cf.gen_unique_str()
schema = cf.gen_default_collection_schema(primary_field=fake_field)
fields = [cf.gen_int64_field(), cf.gen_float_vec_field()]
error = {ct.err_code: 0, ct.err_msg: "not existed field"}
self.collection_wrap.init_collection(cf.gen_unique_str(prefix), schema=schema,
check_task=CheckTasks.err_res, check_items=error)
self.collection_schema_wrap.init_collection_schema(fields, primary_field=fake_field,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
def test_collection_primary_in_schema(self):
@ -569,12 +561,11 @@ class TestCollectionParams(TestcaseBase):
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
field = get_unsupported_primary_field
vec_field = cf.gen_float_vec_field(name="vec")
schema = cf.gen_collection_schema(fields=[field, vec_field], primary_field=field.name)
error = {ct.err_code: 1, ct.err_msg: "the data type of primary key should be int64"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
error = {ct.err_code: 1, ct.err_msg: "Primary key type must be DataType.INT64."}
self.collection_schema_wrap.init_collection_schema(fields=[field, vec_field], primary_field=field.name,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_collection_multi_primary_fields(self):
@ -584,12 +575,11 @@ class TestCollectionParams(TestcaseBase):
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
int_field_one = cf.gen_int64_field(is_primary=True)
int_field_two = cf.gen_int64_field(name="int2", is_primary=True)
schema = cf.gen_collection_schema(fields=[int_field_one, int_field_two])
error = {ct.err_code: 0, ct.err_msg: "there are more than one primary key"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
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],
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
def test_collection_primary_inconsistent(self):
@ -599,15 +589,14 @@ class TestCollectionParams(TestcaseBase):
expected: raise exception
"""
self._connect()
c_name = cf.gen_unique_str(prefix)
int_field_one = cf.gen_int64_field(is_primary=True)
int_field_two = cf.gen_int64_field(name="int2")
schema = cf.gen_collection_schema(fields=[int_field_one, int_field_two, cf.gen_float_vec_field()], primary_field=int_field_two.name)
error = {ct.err_code: 0, ct.err_msg: "there are more than one primary key"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
fields = [int_field_one, int_field_two, cf.gen_float_vec_field()]
error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one"}
self.collection_schema_wrap.init_collection_schema(fields, primary_field=int_field_two.name,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for debugging")
def test_collection_primary_consistent(self):
"""
target: test collection with both collection schema and field schema
@ -623,88 +612,87 @@ class TestCollectionParams(TestcaseBase):
check_items={exp_name: c_name, exp_schema: schema})
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for auto_id")
def test_collection_auto_id_in_field_schema(self):
@pytest.mark.xfail(reason="#5918")
@pytest.mark.parametrize("auto_id", [True, False])
def test_collection_auto_id_in_field_schema(self, auto_id):
"""
target: test collection with auto_id in field schema
method: specify auto_id True in field schema
expected: todo
expected: verify schema's auto_id
"""
pass
self._connect()
c_name = cf.gen_unique_str(prefix)
int_field = cf.gen_int64_field(is_primary=True, auto_id=auto_id)
log.debug(f'int_field auto_id: {int_field.auto_id}')
vec_field = cf.gen_float_vec_field(name='vec')
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field])
assert schema.auto_id == auto_id
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: schema})
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for auto_id")
def test_collection_auto_id_in_collection_schema(self):
@pytest.mark.parametrize("auto_id", [True, False])
def test_collection_auto_id_in_collection_schema(self, auto_id):
"""
target: test collection with auto_id in collection schema
method: specify auto_id True in collection schema
expected: todo
expected: verify schema auto_id and collection schema
"""
# self._connect()
# c_name = cf.gen_unique_str(prefix)
# schema = cf.gen_default_collection_schema(auto_id=True)
# self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
# check_items={exp_name: c_name, exp_schema: schema})
pass
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for auto_id")
def test_collection_auto_id_false_in_schema(self):
"""
target: test collection with auto_id false
method: set auto_id False in collection schema
expected: verify primary field values
"""
pass
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for auto_id")
def test_collection_auto_id_false_in_field(self):
"""
target: test collection with false auto_id in is_primary field
method: set auto_id False in primary field
expected: verify primary field values
"""
# self._connect()
# c_name = cf.gen_unique_str(prefix)
# int_field_one = cf.gen_int64_field(is_primary=True, auto_id=False)
# schema = cf.gen_collection_schema(fields=[int_field_one, cf.gen_float_vec_field()],)
# self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
# check_items={exp_name: c_name, exp_schema: schema})
pass
self._connect()
c_name = cf.gen_unique_str(prefix)
int_field = cf.gen_int64_field(is_primary=True)
vec_field = cf.gen_float_vec_field(name='vec')
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=auto_id)
assert schema.auto_id == auto_id
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.check_collection_property,
check_items={exp_name: c_name, exp_schema: schema})
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.xfail(reason="#5918")
def test_collection_auto_id_non_primary_field(self):
"""
target: test collection set auto_id in non-primary field
method: set auto_id=True in non-primary field
expected: raise exception
"""
pass
self._connect()
int_field_one = cf.gen_int64_field(is_primary=True)
int_field_two = cf.gen_int64_field(auto_id=True)
fields = [int_field_one, int_field_two, cf.gen_float_vec_field()]
error = {ct.err_code: 0, ct.err_msg: "auto_id can only be specified on the primary key field"}
self.collection_schema_wrap.init_collection_schema(fields, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.xfail(reason="#5918")
def test_collection_auto_id_false_non_primary(self):
"""
target: test collection set auto_id in non-primary field
method: set auto_id=True in non-primary field
expected: todo
expected: verify schema auto_id is False
"""
pass
self._connect()
int_field_one = cf.gen_int64_field(is_primary=True)
int_field_two = cf.gen_int64_field(name='int2', auto_id=False)
fields = [int_field_one, int_field_two, cf.gen_float_vec_field()]
schema, _ = self.collection_schema_wrap.init_collection_schema(fields)
assert not schema.auto_id
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.xfail(reason="#5943")
def test_collection_auto_id_inconsistent(self):
"""
target: test collection auto_id with both collection schema and field schema
method: 1.set primary field auto_id=True in field schema 2.set auto_id=False in collection schema
expected: raise exception
"""
pass
self._connect()
int_field = cf.gen_int64_field(is_primary=True, auto_id=True)
vec_field = cf.gen_float_vec_field(name='vec')
error = {ct.err_code: 0, ct.err_msg: "Primary key field can only be one"}
self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=False,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.parametrize("auto_id", [True, False])
def test_collection_auto_id_consistent(self, auto_id):
"""
@ -712,28 +700,71 @@ class TestCollectionParams(TestcaseBase):
method: set auto_id=True/False both field and schema
expected: verify auto_id
"""
pass
self._connect()
int_field = cf.gen_int64_field(is_primary=True, auto_id=auto_id)
vec_field = cf.gen_float_vec_field(name='vec')
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=auto_id)
assert schema.auto_id == auto_id
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.parametrize("auto_id", ct.get_invalid_strs)
def test_collection_invalid_is_primary(self, auto_id):
@pytest.mark.xfail(reason="#5945")
def test_collection_auto_id_none_in_field(self):
"""
target: test collection with auto_id is None
method: set auto_id=None
expected: todo
"""
self._connect()
int_field = cf.gen_int64_field(is_primary=True, auto_id=None)
vec_field = cf.gen_float_vec_field(name='vec')
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field])
log.debug(schema.auto_id)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="#5945")
def test_collection_auto_id_none_in_schema(self):
"""
target: test collection with auto_id=None in collection schema
method: set auto_id=None in collection schema
expected: todo
"""
self._connect()
int_field = cf.gen_int64_field(is_primary=True)
vec_field = cf.gen_float_vec_field(name='vec')
schema, _ = self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=None)
log.debug(schema.auto_id)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.todo(reason="if #5945 throw exception, then remove test_collection_auto_id_none_in_schema")
def test_collection_invalid_auto_id(self, get_none_removed_invalid_strings):
"""
target: test collection with invalid auto_id
method: define field with auto_id=non-bool
expected: raise exception
"""
pass
self._connect()
int_field = cf.gen_int64_field(is_primary=True)
vec_field = cf.gen_float_vec_field(name='vec')
auto_id = get_none_removed_invalid_strings
error = {ct.err_code: 0, ct.err_msg: "Param auto_id must be bool type"}
self.collection_schema_wrap.init_collection_schema([int_field, vec_field], auto_id=auto_id,
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.skip(reason="waiting for auto_id")
@pytest.mark.xfail(reason="#5933")
def test_collection_multi_fields_auto_id(self):
"""
target: test collection auto_id with multi fields
method: specify auto_id=True for multi int64 fields
expected: todo raise exception
"""
pass
self._connect()
int_field_one = cf.gen_int64_field(is_primary=True, auto_id=True)
int_field_two = cf.gen_int64_field(name="int", auto_id=True)
vec_field = cf.gen_float_vec_field(name='vec')
error = {ct.err_code: 0, ct.err_msg: "auto_id can only be specified on the primary key field"}
self.collection_schema_wrap.init_collection_schema([int_field_one, int_field_two, vec_field],
check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L0)
@pytest.mark.parametrize("dtype", [DataType.FLOAT_VECTOR, DataType.BINARY_VECTOR])
@ -746,11 +777,12 @@ class TestCollectionParams(TestcaseBase):
self._connect()
c_name = cf.gen_unique_str(prefix)
float_vec_field, _ = self.field_schema_wrap.init_field_schema(name="vec", dtype=dtype)
schema = cf.gen_collection_schema(fields=[float_vec_field])
schema = cf.gen_collection_schema(fields=[cf.gen_int64_field(is_primary=True), float_vec_field])
error = {ct.err_code: 0, ct.err_msg: "dimension is not defined in field type params"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail("5950")
def test_collection_vector_invalid_dim(self, get_invalid_dim):
"""
target: test collection with invalid dimension
@ -760,7 +792,7 @@ class TestCollectionParams(TestcaseBase):
self._connect()
c_name = cf.gen_unique_str(prefix)
float_vec_field = cf.gen_float_vec_field(dim=get_invalid_dim)
schema = cf.gen_collection_schema(fields=[float_vec_field])
schema = cf.gen_collection_schema(fields=[cf.gen_int64_field(is_primary=True), float_vec_field])
error = {ct.err_code: 0, ct.err_msg: "dim must be of int"}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@ -775,7 +807,7 @@ class TestCollectionParams(TestcaseBase):
self._connect()
c_name = cf.gen_unique_str(prefix)
float_vec_field = cf.gen_float_vec_field(dim=dim)
schema = cf.gen_collection_schema(fields=[float_vec_field])
schema = cf.gen_collection_schema(fields=[cf.gen_int64_field(is_primary=True), float_vec_field])
error = {ct.err_code: 0, ct.err_msg: "invalid dimension: {}. should be in range 1 ~ 32768".format(dim)}
self.collection_wrap.init_collection(c_name, schema=schema, check_task=CheckTasks.err_res, check_items=error)
@ -879,7 +911,7 @@ class TestCollectionOperation(TestcaseBase):
check_task=CheckTasks.err_res, check_items=error)
assert self.collection_wrap.collection is None
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.tags(CaseLabel.L2)
def test_collection_multi_create_drop(self):
"""
target: test cycle creation and deletion of multiple collections
@ -897,6 +929,7 @@ class TestCollectionOperation(TestcaseBase):
assert c_name, _ not in self.utility_wrap.list_collections()
@pytest.mark.tags(CaseLabel.L1)
@pytest.mark.xfail(reason="issue #5947")
def test_collection_dup_name_drop(self):
"""
target: test collection with dup name, and drop
@ -932,6 +965,7 @@ class TestCollectionOperation(TestcaseBase):
assert self.utility_wrap.has_collection(c_name)[0]
@pytest.mark.skip(reason="waiting for debug")
class TestCollectionDataframe(TestcaseBase):
"""
******************************************************************