Beispiel #1
0
 def test_collection_dup_field(self):
     """
     target: test collection with dup field name
     method: Two FieldSchema have same name
     expected: raise exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     field_one = cf.gen_int64_field()
     field_two = cf.gen_int64_field()
     schema = cf.gen_collection_schema(fields=[field_one, field_two])
     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]
Beispiel #2
0
 def test_query_expr_non_primary_field(self):
     """
     target: test query on non-primary field
     method: query on non-primary int field
     expected: raise exception
     """
     fields = [cf.gen_int64_field(), cf.gen_int64_field(name='int2', is_primary=True), cf.gen_float_vec_field()]
     schema = cf.gen_collection_schema(fields)
     collection_w = self.init_collection_wrap(name=cf.gen_unique_str(prefix), schema=schema)
     nb = 100
     data = [[i for i in range(nb)], [i for i in range(nb)], cf.gen_vectors(nb, ct.default_dim)]
     collection_w.insert(data)
     assert collection_w.num_entities == nb
     assert collection_w.primary_field.name == 'int2'
     error = {ct.err_code: 1, ct.err_msg: "column is not primary key"}
     collection_w.query(default_term_expr, check_task=CheckTasks.err_res, check_items=error)
Beispiel #3
0
 def test_collection_dup_name_new_schema(self):
     """
     target: test collection with dup name and new schema
     method: 1.create collection with default schema
             2. collection with dup name and new schema
     expected: raise exception
     """
     self._connect()
     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()]
     schema = cf.gen_collection_schema(fields=fields)
     error = {
         ct.err_code:
         1,
         ct.err_msg:
         "The collection already exist, but the schema isnot the same as the "
         "passed in"
     }
     self.collection_wrap.init_collection(c_name,
                                          schema=schema,
                                          check_task=CheckTasks.err_res,
                                          check_items=error)
Beispiel #4
0
 def test_collection_without_vectors(self):
     """
     target: test collection without vectors
     method: create collection only with int field
     expected: raise exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     schema = cf.gen_collection_schema([cf.gen_int64_field()])
     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)
Beispiel #5
0
 def test_collection_without_vectors(self):
     """
     target: test collection without vectors
     method: create collection only with int field
     expected: raise exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     schema = cf.gen_collection_schema([cf.gen_int64_field()])
     ex, _ = self.collection.collection_init(c_name, schema=schema)
     assert "must" in str(ex)
Beispiel #6
0
 def test_collection_primary_inconsistent(self):
     """
     target: test collection with different primary field setting
     method: 1. set A field is_primary 2. set primary_field is B
     expected: raise exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     int_field = cf.gen_int64_field(name="int", is_primary=True)
     float_vec_field = cf.gen_float_vec_field(name="vec")
     schema = cf.gen_collection_schema(fields=[int_field, float_vec_field], primary_field="vec")
     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)
Beispiel #7
0
 def test_collection_multi_primary_fields(self):
     """
     target: test collection with multi primary
     method: collection with two primary fields
     expected: raise exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     int_field = cf.gen_int64_field(is_primary=True)
     float_vec_field = cf.gen_float_vec_field(is_primary=True)
     schema = cf.gen_collection_schema(fields=[int_field, float_vec_field])
     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)
Beispiel #8
0
 def test_collection_field_primary_false(self):
     """
     target: test collection with primary false
     method: define field with is_primary false
     expected: no exception
     """
     self._connect()
     c_name = cf.gen_unique_str(prefix)
     int_field = cf.gen_int64_field(name="int")
     float_vec_field = cf.gen_float_vec_field()
     schema = cf.gen_collection_schema(fields=[int_field, float_vec_field])
     self.collection_wrap.init_collection(c_name, schema=schema)
     assert self.collection_wrap.primary_field is None
     assert self.collection_wrap.schema.auto_id
Beispiel #9
0
 def test_collection_dup_name_new_schema(self):
     """
     target: test collection with dup name and new schema
     method: 1.create collection with default schema
             2. collection with dup name and new schema
     expected: raise exception
     """
     self._connect()
     c_name, collection = self._collection()
     assert_default_collection(collection, c_name)
     fields = [cf.gen_int64_field()]
     schema = cf.gen_collection_schema(fields=fields)
     ex, _ = self.collection.collection_init(c_name, schema=schema)
     assert "The collection already exist, but the schema isnot the same as the passed in" in str(
         ex)