def test_mysql_opportunistically(self):
        self.useFixture(fixtures.LockFixture('mysql'))
        if not db_test_utils.is_backend_avail('mysql'):
            raise self.skipTest('mysql is not available')

        self.useFixture(fixtures.MySQLConfFixture())
        # Test that table creation on mysql only builds InnoDB tables
        # add this to the global lists to make reset work with it, it's removed
        # automatically in tearDown so no need to clean it up here.
        connect_string = db_test_utils.get_connect_string("mysql")
        engine = sqlalchemy.create_engine(connect_string)
        self.engines["mysqlcitest"] = engine
        self.test_databases["mysqlcitest"] = connect_string

        # build a fully populated mysql database with all the tables
        self._walk_versions(engine)

        connection = engine.connect()
        # sanity check
        total = connection.execute("SELECT count(*) "
                                   "from information_schema.TABLES "
                                   "where TABLE_SCHEMA='openstack_citest'")
        self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")

        noninnodb = connection.execute("SELECT count(*) "
                                       "from information_schema.TABLES "
                                       "where TABLE_SCHEMA='openstack_citest' "
                                       "and ENGINE!='InnoDB' "
                                       "and TABLE_NAME!='alembic_version'")
        count = noninnodb.scalar()
        self.assertEqual(count, 0, "%d non InnoDB tables created" % count)
        connection.close()
Esempio n. 2
0
    def test_mysql_opportunistically(self):
        if not db_test_utils.is_backend_avail('mysql'):
            raise self.skipTest('mysql is not available')

        self.useFixture(fixtures.LockFixture('mysql'))
        self.useFixture(fixtures.MySQLConfFixture())
        # Test that table creation on mysql only builds InnoDB tables
        # add this to the global lists to make reset work with it, it's removed
        # automatically in tearDown so no need to clean it up here.
        connect_string = db_test_utils.get_connect_string("mysql")
        engine = sqlalchemy.create_engine(connect_string)
        self.engines["mysqlcitest"] = engine
        self.test_databases["mysqlcitest"] = connect_string

        # build a fully populated mysql database with all the tables
        self._walk_versions(engine)

        connection = engine.connect()
        # sanity check
        total = connection.execute("SELECT count(*) "
                                   "from information_schema.TABLES "
                                   "where TABLE_SCHEMA='openstack_citest'")
        self.assertTrue(total.scalar() > 0, "No tables found. Wrong schema?")

        noninnodb = connection.execute("SELECT count(*) "
                                       "from information_schema.TABLES "
                                       "where TABLE_SCHEMA='openstack_citest' "
                                       "and ENGINE!='InnoDB' "
                                       "and TABLE_NAME!='alembic_version'")
        count = noninnodb.scalar()
        self.assertEqual(count, 0, "%d non InnoDB tables created" % count)
        connection.close()
    def test_mysql_connect_fail(self):
        """Test graceful mysql connection failure.

        Test that we can trigger a mysql connection failure and we fail
        gracefully to ensure we don't break people without mysql
        """
        if db_test_utils.is_backend_avail('mysql', user="******"):
            self.fail("Shouldn't have connected")
Esempio n. 4
0
    def test_mysql_connect_fail(self):
        """Test graceful mysql connection failure.

        Test that we can trigger a mysql connection failure and we fail
        gracefully to ensure we don't break people without mysql
        """
        if db_test_utils.is_backend_avail('mysql', user="******"):
            self.fail("Shouldn't have connected")
Esempio n. 5
0
 def setUp(self):
     super(TestDatabaseAPI, self).setUp()
     if not db_test_utils.is_backend_avail(self.dialect):
         raise self.skipTest('%s is not available' % self.dialect)
     self.useFixture(fixtures.LockFixture(self.dialect))
     if self.dialect == 'mysql':
         self.useFixture(fixtures.MySQLConfFixture())
     elif self.dialect == 'postgres':
         self.useFixture(fixtures.PostgresConfFixture())
     elif self.dialect == 'sqlite':
         self.useFixture(fixtures.SqliteConfFixture())
     self.useFixture(fixtures.Database())
Esempio n. 6
0
 def setUp(self):
     super(TestDatabaseAPI, self).setUp()
     if not db_test_utils.is_backend_avail(self.dialect):
         raise self.skipTest('%s is not available' % self.dialect)
     self.useFixture(fixtures.LockFixture(self.dialect))
     if self.dialect == 'mysql':
         self.useFixture(fixtures.MySQLConfFixture())
     elif self.dialect == 'postgres':
         self.useFixture(fixtures.PostgresConfFixture())
     elif self.dialect == 'sqlite':
         self.useFixture(fixtures.SqliteConfFixture())
     self.useFixture(fixtures.Database())
Esempio n. 7
0
 def setUp(self):
     super(TestModelsMigrations, self).setUp()
     self.useFixture(fixtures.LockFixture(self.dialect))
     if not db_test_utils.is_backend_avail(self.dialect):
         raise self.skipTest('%s is not available' % self.dialect)
     if self.dialect == 'sqlite':
         raise self.skipException('sqlite skipped because of model sync '
                                  'issue with BigInteger vs Integer')
     if self.dialect == 'mysql':
         self.useFixture(fixtures.MySQLConfFixture())
     elif self.dialect == 'postgres':
         self.useFixture(fixtures.PostgresConfFixture())
     connect_string = db_test_utils.get_connect_string(self.dialect)
     self.engine = sqlalchemy.create_engine(connect_string)
Esempio n. 8
0
 def setUp(self):
     super(TestModelsMigrations, self).setUp()
     self.useFixture(fixtures.LockFixture(self.dialect))
     if not db_test_utils.is_backend_avail(self.dialect):
         raise self.skipTest('%s is not available' % self.dialect)
     if self.dialect == 'sqlite':
         raise self.skipException('sqlite skipped because of model sync '
                                  'issue with BigInteger vs Integer')
     if self.dialect == 'mysql':
         self.useFixture(fixtures.MySQLConfFixture())
     elif self.dialect == 'postgres':
         self.useFixture(fixtures.PostgresConfFixture())
     connect_string = db_test_utils.get_connect_string(self.dialect)
     self.engine = sqlalchemy.create_engine(connect_string)
    def test_postgresql_opportunistically(self):
        # Test postgresql database migration walk
        self.useFixture(fixtures.LockFixture('postgres'))
        if not db_test_utils.is_backend_avail('postgres'):
            raise self.skipTest('postgres is not available')
        self.useFixture(fixtures.PostgresConfFixture())
        # add this to the global lists to make reset work with it, it's removed
        # automatically in tearDown so no need to clean it up here.
        connect_string = db_test_utils.get_connect_string("postgres")
        engine = sqlalchemy.create_engine(connect_string)
        self.engines["postgresqlcitest"] = engine
        self.test_databases["postgresqlcitest"] = connect_string

        # build a fully populated postgresql database with all the tables
        self._walk_versions(engine)
Esempio n. 10
0
    def test_postgresql_opportunistically(self):
        # Test postgresql database migration walk
        if not db_test_utils.is_backend_avail('postgres'):
            raise self.skipTest('postgres is not available')
        self.useFixture(fixtures.LockFixture('postgres'))
        self.useFixture(fixtures.PostgresConfFixture())
        # add this to the global lists to make reset work with it, it's removed
        # automatically in tearDown so no need to clean it up here.
        connect_string = db_test_utils.get_connect_string("postgres")
        engine = sqlalchemy.create_engine(connect_string)
        self.engines["postgresqlcitest"] = engine
        self.test_databases["postgresqlcitest"] = connect_string

        # build a fully populated postgresql database with all the tables
        self._walk_versions(engine)