Tests for database migrations. This test case reads the configuration file test_migrations.conf for database connection settings to use in the tests. For each connection found in the config file, the test case runs a series of test cases to ensure that migrations work properly both upgrading and downgrading, and that no data loss occurs if possible.
There are also “opportunistic” tests for both mysql and postgresql in here, which allows testing against all 3 databases (sqlite in memory, mysql, pg) in a properly configured unit test environment.
For the opportunistic testing you need to set up a db named ‘openstack_citest’ with user ‘openstack_citest’ and password ‘openstack_citest’ on localhost. The test will then use that db and u/p combo to run the tests.
For postgres on Ubuntu this can be done with the following commands:
sudo -u postgres psql postgres=# create user openstack_citest with createdb login password
‘openstack_citest’;
postgres=# create database openstack_citest with owner openstack_citest;
Bases: nova.test.TestCase
Base class fort testing migrations and migration utils.
Bases: object
These tests are shared between TestNovaMigrations and TestBaremetalMigrations.
BaseMigrationTestCase is effectively an abstract class, meant to be derived from and not directly tested against; that’s why these test_ methods need to be on a Mixin, so that they won’t be picked up as valid tests for BaseMigrationTestCase.
Test that we can trigger a mysql connection failure and we fail gracefully to ensure we don’t break people without mysql
Test that we can trigger a postgres connection failure and we fail gracefully to ensure we don’t break people without postgres
Bases: nova.tests.test_migrations.BaseMigrationTestCase, nova.tests.test_migrations.CommonTestsMixIn
Test sqlalchemy-migrate migrations.
Bases: nova.tests.test_migrations.BaseMigrationTestCase, nova.tests.test_migrations.CommonTestsMixIn
Test sqlalchemy-migrate migrations.
Returns an sqlalchemy table dynamically from db.
Needed because the models don’t work for us in migrations as models will be far out of sync with the current data.