예제 #1
0
    def _check_006(self, engine, data):
        ports = db_utils.get_table(engine, 'ports')
        self.assertTrue(isinstance(ports.c.uuid.type, sqlalchemy.types.String))

        nodes = db_utils.get_table(engine, 'nodes')
        nodes_data = {
            'id': 1,
            'uuid': 'uuu-111',
            'driver': 'driver1',
            'driver_info': 'info1',
            'task_state': 'state1',
            'extra': 'extra1'
        }
        nodes.insert().values(nodes_data).execute()

        ports_data = {
            'address': 'address0',
            'node_id': 1,
            'uuid': 'uuu-222',
            'extra': 'extra2'
        }
        ports.insert().values(ports_data).execute()
        self.assertRaises(
            sqlalchemy.exc.IntegrityError,
            ports.insert().execute, {
                'address': 'address1',
                'node_id': 1,
                'uuid': 'uuu-222',
                'extra': 'extra3'
            })
예제 #2
0
    def _check_001(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        nodes_col = {
            'id': 'Integer', 'uuid': 'String', 'power_info': 'Text',
            'cpu_arch': 'String', 'cpu_num': 'Integer', 'memory': 'Integer',
            'local_storage_max': 'Integer', 'task_state': 'String',
            'image_path': 'String', 'instance_uuid': 'String',
            'instance_name': 'String', 'extra': 'Text',
            'created_at': 'DateTime', 'updated_at': 'DateTime'
        }
        for col, coltype in nodes_col.items():
            self.assertTrue(isinstance(nodes.c[col].type,
                                       getattr(sqlalchemy.types, coltype)))

        ifaces = db_utils.get_table(engine, 'ifaces')
        ifaces_col = {
            'id': 'Integer', 'address': 'String', 'node_id': 'Integer',
            'extra': 'Text', 'created_at': 'DateTime', 'updated_at': 'DateTime'
        }
        for col, coltype in ifaces_col.items():
            self.assertTrue(isinstance(ifaces.c[col].type,
                                       getattr(sqlalchemy.types, coltype)))

        fkey, = ifaces.c.node_id.foreign_keys
        self.assertEqual(nodes.c.id.name, fkey.column.name)
        self.assertEqual(fkey.column.table.name, 'nodes')
예제 #3
0
 def _check_005(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     col_names = [column.name for column in nodes.c]
     self.assertFalse('deploy_driver' in col_names)
     self.assertFalse('deploy_info' in col_names)
     self.assertTrue('driver' in col_names)
     self.assertTrue('driver_info' in col_names)
예제 #4
0
 def _check_005(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     col_names = [column.name for column in nodes.c]
     self.assertFalse('deploy_driver' in col_names)
     self.assertFalse('deploy_info' in col_names)
     self.assertTrue('driver' in col_names)
     self.assertTrue('driver_info' in col_names)
예제 #5
0
 def _check_007(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     new_col = {'extra': 'Text', 'created_at': 'DateTime',
                'updated_at': 'DateTime'}
     for col, coltype in new_col.items():
         self.assertTrue(isinstance(chassis.c[col].type,
                                    getattr(sqlalchemy.types, coltype)))
예제 #6
0
 def _check_011(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     chassis_data = {'uuid': 'uuu-111-222', 'extra': 'extra1'}
     chassis.insert().values(chassis_data).execute()
     self.assertRaises(sqlalchemy.exc.IntegrityError,
                       chassis.insert().execute,
                       {'uuid': 'uuu-111-222', 'extra': 'extra2'})
예제 #7
0
 def _check_3bea56f25597(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     instance_uuid = 'aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee'
     data = {'driver': 'fake',
             'uuid': utils.generate_uuid(),
             'instance_uuid': instance_uuid}
     nodes.insert().values(data).execute()
     data['uuid'] = utils.generate_uuid()
     self.assertRaises(sqlalchemy.exc.IntegrityError,
                       nodes.insert().execute, data)
예제 #8
0
    def _check_3cb628139ea4(self, engine, data):
        nodes = db_utils.get_table(engine, "nodes")
        col_names = [column.name for column in nodes.c]

        self.assertIn("console_enabled", col_names)
        # in some backends bool type is integer
        self.assertTrue(
            isinstance(nodes.c.console_enabled.type, sqlalchemy.types.Boolean)
            or isinstance(nodes.c.console_enabled.type, sqlalchemy.types.Integer)
        )
예제 #9
0
    def _check_3cb628139ea4(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        col_names = [column.name for column in nodes.c]

        self.assertIn('console_enabled', col_names)
        # in some backends bool type is integer
        self.assertTrue(
            isinstance(nodes.c.console_enabled.type, sqlalchemy.types.Boolean)
            or isinstance(nodes.c.console_enabled.type,
                          sqlalchemy.types.Integer))
예제 #10
0
 def _check_007(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     new_col = {
         'extra': 'Text',
         'created_at': 'DateTime',
         'updated_at': 'DateTime'
     }
     for col, coltype in new_col.items():
         self.assertTrue(
             isinstance(chassis.c[col].type,
                        getattr(sqlalchemy.types, coltype)))
예제 #11
0
    def _check_013(self, engine, col_names_pre):
        nodes = db_utils.get_table(engine, 'nodes')
        col_names = set(column.name for column in nodes.c)

        # didn't lose any columns in the migration
        self.assertEqual(col_names_pre, col_names.intersection(col_names_pre))

        # only added one 'last_error' column
        self.assertEqual(len(col_names_pre), len(col_names) - 1)
        self.assertTrue(isinstance(nodes.c['last_error'].type,
                                   getattr(sqlalchemy.types, 'Text')))
예제 #12
0
    def _check_001(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        nodes_col = {
            'id': 'Integer',
            'uuid': 'String',
            'power_info': 'Text',
            'cpu_arch': 'String',
            'cpu_num': 'Integer',
            'memory': 'Integer',
            'local_storage_max': 'Integer',
            'task_state': 'String',
            'image_path': 'String',
            'instance_uuid': 'String',
            'instance_name': 'String',
            'extra': 'Text',
            'created_at': 'DateTime',
            'updated_at': 'DateTime'
        }
        for col, coltype in nodes_col.items():
            self.assertTrue(
                isinstance(nodes.c[col].type, getattr(sqlalchemy.types,
                                                      coltype)))

        ifaces = db_utils.get_table(engine, 'ifaces')
        ifaces_col = {
            'id': 'Integer',
            'address': 'String',
            'node_id': 'Integer',
            'extra': 'Text',
            'created_at': 'DateTime',
            'updated_at': 'DateTime'
        }
        for col, coltype in ifaces_col.items():
            self.assertTrue(
                isinstance(ifaces.c[col].type,
                           getattr(sqlalchemy.types, coltype)))

        fkey, = ifaces.c.node_id.foreign_keys
        self.assertEquals(nodes.c.id.name, fkey.column.name)
        self.assertEquals(fkey.column.table.name, 'nodes')
예제 #13
0
    def _check_006(self, engine, data):
        ports = db_utils.get_table(engine, 'ports')
        self.assertTrue(isinstance(ports.c.uuid.type, sqlalchemy.types.String))

        nodes = db_utils.get_table(engine, 'nodes')
        nodes_data = {
             'id': 1, 'uuid': 'uuu-111', 'driver': 'driver1',
             'driver_info': 'info1', 'task_state': 'state1',
             'extra': 'extra1'
            }
        nodes.insert().values(nodes_data).execute()

        ports_data = {
                'address': 'address0', 'node_id': 1, 'uuid': 'uuu-222',
                'extra': 'extra2'
            }
        ports.insert().values(ports_data).execute()
        self.assertRaises(
            sqlalchemy.exc.IntegrityError,
            ports.insert().execute,
            {'address': 'address1', 'node_id': 1, 'uuid': 'uuu-222',
             'extra': 'extra3'})
예제 #14
0
    def _check_009(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        col_names = [column.name for column in nodes.c]

        self.assertFalse('task_start' in col_names)
        self.assertFalse('task_state' in col_names)

        new_col = {'power_state': 'String',
                   'target_power_state': 'String',
                   'provision_state': 'String',
                   'target_provision_state': 'String'}
        for col, coltype in new_col.items():
            self.assertTrue(isinstance(nodes.c[col].type,
                                       getattr(sqlalchemy.types, coltype)))
예제 #15
0
    def _check_002(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        new_col = {
            'chassis_id': 'Integer', 'task_start': 'DateTime',
            'properties': 'Text', 'control_driver': 'String',
            'control_info': 'Text', 'deploy_driver': 'String',
            'deploy_info': 'Text', 'reservation': 'String'
        }
        for col, coltype in new_col.items():
            self.assertTrue(isinstance(nodes.c[col].type,
                                       getattr(sqlalchemy.types, coltype)))

        deleted_cols = ['power_info', 'cpu_arch', 'cpu_num', 'memory',
                        'local_storage_max', 'image_path', 'instance_name']
        for column in nodes.c:
            self.assertFalse(column.name in deleted_cols)
예제 #16
0
    def _check_009(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        col_names = [column.name for column in nodes.c]

        self.assertFalse('task_start' in col_names)
        self.assertFalse('task_state' in col_names)

        new_col = {
            'power_state': 'String',
            'target_power_state': 'String',
            'provision_state': 'String',
            'target_provision_state': 'String'
        }
        for col, coltype in new_col.items():
            self.assertTrue(
                isinstance(nodes.c[col].type, getattr(sqlalchemy.types,
                                                      coltype)))
예제 #17
0
 def _check_014(self, engine, data):
     if engine.name == 'sqlite':
         ports = db_utils.get_table(engine, 'ports')
         ports_data = {'address': 'BB:BB:AA:AA:AA:AA', 'extra': 'extra1'}
         ports.insert().values(ports_data).execute()
         self.assertRaises(sqlalchemy.exc.IntegrityError,
                           ports.insert().execute,
                           {'address': 'BB:BB:AA:AA:AA:AA',
                            'extra': 'extra2'})
         # test recreate old UC
         ports_data = {
                       'address': 'BB:BB:AA:AA:AA:BB',
                       'uuid': '1be26c0b-03f2-4d2e-ae87-c02d7f33c781',
                       'extra': 'extra2'}
         ports.insert().values(ports_data).execute()
         self.assertRaises(sqlalchemy.exc.IntegrityError,
                           ports.insert().execute,
                           {'address': 'CC:BB:AA:AA:AA:CC',
                            'uuid': '1be26c0b-03f2-4d2e-ae87-c02d7f33c781',
                            'extra': 'extra3'})
예제 #18
0
    def _check_012(self, engine, data):
        self.assertTrue(engine.dialect.has_table(engine.connect(),
                                                 'conductors'))
        conductor = db_utils.get_table(engine, 'conductors')
        conductor_data = {'hostname': 'test-host'}
        conductor.insert().values(conductor_data).execute()
        self.assertRaises(sqlalchemy.exc.IntegrityError,
                          conductor.insert().execute,
                          conductor_data)

        # NOTE(deva): different backends raise different error here.
        if isinstance(engine.dialect,
                sqlalchemy.dialects.sqlite.pysqlite.SQLiteDialect_pysqlite):
            self.assertRaises(sqlalchemy.exc.IntegrityError,
                          conductor.insert().execute,
                          {'hostname': None})
        if isinstance(engine.dialect,
                sqlalchemy.dialects.mysql.pymysql.MySQLDialect_pymysql):
            self.assertRaises(sqlalchemy.exc.OperationalError,
                          conductor.insert().execute,
                          {'hostname': None})
예제 #19
0
    def _check_002(self, engine, data):
        nodes = db_utils.get_table(engine, 'nodes')
        new_col = {
            'chassis_id': 'Integer',
            'task_start': 'DateTime',
            'properties': 'Text',
            'control_driver': 'String',
            'control_info': 'Text',
            'deploy_driver': 'String',
            'deploy_info': 'Text',
            'reservation': 'String'
        }
        for col, coltype in new_col.items():
            self.assertTrue(
                isinstance(nodes.c[col].type, getattr(sqlalchemy.types,
                                                      coltype)))

        deleted_cols = [
            'power_info', 'cpu_arch', 'cpu_num', 'memory', 'local_storage_max',
            'image_path', 'instance_name'
        ]
        for column in nodes.c:
            self.assertFalse(column.name in deleted_cols)
예제 #20
0
 def _check_008(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     self.assertTrue(isinstance(chassis.c.description.type,
                                sqlalchemy.types.String))
예제 #21
0
 def _check_31baaf680d2b(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     col_names = [column.name for column in nodes.c]
     self.assertIn('instance_info', col_names)
     self.assertIsInstance(nodes.c.instance_info.type,
                           sqlalchemy.types.TEXT)
예제 #22
0
 def _check_003(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     self.assertTrue(isinstance(chassis.c.id.type,
                                sqlalchemy.types.Integer))
     self.assertTrue(isinstance(chassis.c.uuid.type,
                                sqlalchemy.types.String))
예제 #23
0
 def _check_008(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     self.assertTrue(
         isinstance(chassis.c.description.type, sqlalchemy.types.String))
예제 #24
0
 def _check_21b331f883ef(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     col_names = [column.name for column in nodes.c]
     self.assertIn('provision_updated_at', col_names)
     self.assertIsInstance(nodes.c.provision_updated_at.type,
                           sqlalchemy.types.DateTime)
예제 #25
0
    def _pre_upgrade_013(self, engine):
        nodes = db_utils.get_table(engine, 'nodes')
        col_names = set(column.name for column in nodes.c)

        self.assertFalse('last_error' in col_names)
        return col_names
예제 #26
0
 def _check_003(self, engine, data):
     chassis = db_utils.get_table(engine, 'chassis')
     self.assertTrue(isinstance(chassis.c.id.type,
                                sqlalchemy.types.Integer))
     self.assertTrue(
         isinstance(chassis.c.uuid.type, sqlalchemy.types.String))
예제 #27
0
 def _check_31baaf680d2b(self, engine, data):
     nodes = db_utils.get_table(engine, 'nodes')
     col_names = [column.name for column in nodes.c]
     self.assertIn('instance_info', col_names)
     self.assertIsInstance(nodes.c.instance_info.type,
                           sqlalchemy.types.TEXT)
예제 #28
0
 def _check_21b331f883ef(self, engine, data):
     nodes = db_utils.get_table(engine, "nodes")
     col_names = [column.name for column in nodes.c]
     self.assertIn("provision_updated_at", col_names)
     self.assertIsInstance(nodes.c.provision_updated_at.type, sqlalchemy.types.DateTime)