def _check_231(self, engine, data): self.assertColumnExists(engine, 'instances', 'ephemeral_key_uuid') instances = oslodbutils.get_table(engine, 'instances') self.assertIsInstance(instances.c.ephemeral_key_uuid.type, sqlalchemy.types.String) self.assertTrue(db_utils.check_shadow_table(engine, 'instances'))
def test_create_shadow_table_not_supported_type(self): if 'sqlite' in self.engines: table_name = 'test_create_shadow_table_not_supported_type' engine = self.engines['sqlite'] meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', CustomType)) table.create() # reflection of custom types has been fixed upstream if SA_VERSION < (0, 9, 0): self.assertRaises(exception.NovaException, utils.create_shadow_table, engine, table_name=table_name) shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column( 'a', CustomType())) self.assertTrue(utils.check_shadow_table(engine, table_name)) table.drop() shadow_table.drop()
def test_check_shadow_table(self): table_name = 'abc' for key, engine in self.engines.items(): meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', String(256))) table.create() #check missing shadow table self.assertRaises(NoSuchTableError, utils.check_shadow_table, engine, table_name) shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, meta, Column('id', Integer), Column('a', Integer)) shadow_table.create() # check missing column self.assertRaises(exception.NovaException, utils.check_shadow_table, engine, table_name) # check when all is ok c = Column('c', String(256)) shadow_table.create_column(c) self.assertTrue(utils.check_shadow_table(engine, table_name)) # check extra column d = Column('d', Integer) shadow_table.create_column(d) self.assertRaises(exception.NovaException, utils.check_shadow_table, engine, table_name)
def test_check_shadow_table(self): table_name = 'test_check_shadow_table' table = Table(table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', String(256))) table.create() # check missing shadow table self.assertRaises(NoSuchTableError, utils.check_shadow_table, self.engine, table_name) shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, self.meta, Column('id', Integer), Column('a', Integer)) shadow_table.create() # check missing column self.assertRaises(exception.NovaException, utils.check_shadow_table, self.engine, table_name) # check when all is ok c = Column('c', String(256)) shadow_table.create_column(c) self.assertTrue(utils.check_shadow_table(self.engine, table_name)) # check extra column d = Column('d', Integer) shadow_table.create_column(d) self.assertRaises(exception.NovaException, utils.check_shadow_table, self.engine, table_name)
def test_create_shadow_table_by_table_instance(self): table_name = 'test_create_shadow_table_by_table_instance' table = Table(table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('b', String(256))) table.create() utils.create_shadow_table(self.engine, table=table) self.assertTrue(utils.check_shadow_table(self.engine, table_name))
def test_create_shadow_table_by_table_instance(self): table_name = 'abc' for key, engine in self.engines.items(): meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('b', String(256))) table.create() utils.create_shadow_table(engine, table=table) self.assertTrue(utils.check_shadow_table(engine, table_name))
def test_create_shadow_table_not_supported_type(self): table_name = 'test_create_shadow_table_not_supported_type' table = Table(table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', CustomType)) table.create() utils.create_shadow_table(self.engine, table_name=table_name, a=Column('a', CustomType())) self.assertTrue(utils.check_shadow_table(self.engine, table_name))
def test_check_shadow_table_with_unsupported_sqlite_type(self): table_name = 'test_check_shadow_table_with_unsupported_sqlite_type' table = Table(table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) table.create() shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) shadow_table.create() self.assertTrue(utils.check_shadow_table(self.engine, table_name))
def test_create_shadow_table_not_supported_type(self): if "sqlite" in self.engines: table_name = "test_create_shadow_table_not_supported_type" engine = self.engines["sqlite"] meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column("id", Integer, primary_key=True), Column("a", CustomType)) table.create() self.assertRaises(exception.NovaException, utils.create_shadow_table, engine, table_name=table_name) shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column("a", CustomType())) self.assertTrue(utils.check_shadow_table(engine, table_name)) table.drop() shadow_table.drop()
def test_check_shadow_table_with_unsupported_type(self): table_name = 'abc' engine = self.engines['sqlite'] meta = MetaData(bind=engine) table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) table.create() shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) shadow_table.create() self.assertTrue(utils.check_shadow_table(engine, table_name))
def test_create_shadow_table_not_supported_type(self): table_name = 'abc' engine = self.engines['sqlite'] meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', CustomType)) table.create() self.assertRaises(exception.NovaException, utils.create_shadow_table, engine, table_name=table_name) utils.create_shadow_table(engine, table_name=table_name, a=Column('a', CustomType())) self.assertTrue(utils.check_shadow_table(engine, table_name))
def test_create_shadow_table_not_supported_type(self): table_name = 'test_create_shadow_table_not_supported_type' table = Table(table_name, self.meta, Column('id', Integer, primary_key=True), Column('a', CustomType)) table.create() # reflection of custom types has been fixed upstream if SA_VERSION < (0, 9, 0): self.assertRaises(oslodbutils.ColumnError, utils.create_shadow_table, self.engine, table_name=table_name) utils.create_shadow_table(self.engine, table_name=table_name, a=Column('a', CustomType())) self.assertTrue(utils.check_shadow_table(self.engine, table_name))
def test_create_shadow_table_not_supported_type(self): if "sqlite" in self.engines: table_name = "test_create_shadow_table_not_supported_type" engine = self.engines["sqlite"] meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column("id", Integer, primary_key=True), Column("a", CustomType)) table.create() # reflection of custom types has been fixed upstream if SA_VERSION < (0, 9, 0): self.assertRaises(oslodbutils.ColumnError, utils.create_shadow_table, engine, table_name=table_name) shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column("a", CustomType())) self.assertTrue(utils.check_shadow_table(engine, table_name)) table.drop() shadow_table.drop()
def test_create_shadow_table_by_table_instance(self): table_name = "test_create_shadow_table_by_table_instance" for key, engine in self.engines.items(): meta = MetaData() meta.bind = engine table = Table( table_name, meta, Column("id", Integer, primary_key=True), Column("a", Integer), Column("b", String(256)), ) table.create() shadow_table = utils.create_shadow_table(engine, table=table) self.assertTrue(utils.check_shadow_table(engine, table_name)) table.drop() shadow_table.drop()
def test_check_shadow_table_with_unsupported_sqlite_type(self): if 'sqlite' not in self.engines: self.skipTest('sqlite is not configured') table_name = 'test_check_shadow_table_with_unsupported_sqlite_type' engine = self.engines['sqlite'] meta = MetaData(bind=engine) table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) table.create() shadow_table = Table(db._SHADOW_TABLE_PREFIX + table_name, meta, Column('id', Integer, primary_key=True), Column('a', Integer), Column('c', CustomType)) shadow_table.create() self.assertTrue(utils.check_shadow_table(engine, table_name)) shadow_table.drop()
def test_check_shadow_table_with_unsupported_sqlite_type(self): if "sqlite" not in self.engines: self.skipTest("sqlite is not configured") table_name = "test_check_shadow_table_with_unsupported_sqlite_type" engine = self.engines["sqlite"] meta = MetaData(bind=engine) table = Table( table_name, meta, Column("id", Integer, primary_key=True), Column("a", Integer), Column("c", CustomType) ) table.create() shadow_table = Table( db._SHADOW_TABLE_PREFIX + table_name, meta, Column("id", Integer, primary_key=True), Column("a", Integer), Column("c", CustomType), ) shadow_table.create() self.assertTrue(utils.check_shadow_table(engine, table_name)) shadow_table.drop()
def test_check_shadow_table(self): table_name = "test_check_shadow_table" for key, engine in self.engines.items(): meta = MetaData() meta.bind = engine table = Table( table_name, meta, Column("id", Integer, primary_key=True), Column("a", Integer), Column("c", String(256)), ) table.create() # check missing shadow table self.assertRaises(NoSuchTableError, utils.check_shadow_table, engine, table_name) shadow_table = Table( db._SHADOW_TABLE_PREFIX + table_name, meta, Column("id", Integer), Column("a", Integer) ) shadow_table.create() # check missing column self.assertRaises(exception.NovaException, utils.check_shadow_table, engine, table_name) # check when all is ok c = Column("c", String(256)) shadow_table.create_column(c) self.assertTrue(utils.check_shadow_table(engine, table_name)) # check extra column d = Column("d", Integer) shadow_table.create_column(d) self.assertRaises(exception.NovaException, utils.check_shadow_table, engine, table_name) table.drop() shadow_table.drop()
def test_create_shadow_table_not_supported_type(self): if 'sqlite' in self.engines: table_name = 'test_create_shadow_table_not_supported_type' engine = self.engines['sqlite'] meta = MetaData() meta.bind = engine table = Table(table_name, meta, Column('id', Integer, primary_key=True), Column('a', CustomType)) table.create() # reflection of custom types has been fixed upstream if SA_VERSION < (0, 9, 0): self.assertRaises(exception.NovaException, utils.create_shadow_table, engine, table_name=table_name) shadow_table = utils.create_shadow_table(engine, table_name=table_name, a=Column('a', CustomType()) ) self.assertTrue(utils.check_shadow_table(engine, table_name)) table.drop() shadow_table.drop()
def _post_downgrade_231(self, engine): self.assertColumnNotExists(engine, 'instances', 'ephemeral_key_uuid') self.assertTrue(db_utils.check_shadow_table(engine, 'instances'))