summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorDan Prince <dprince@redhat.com>2012-05-02 14:48:25 -0400
committerDan Prince <dprince@redhat.com>2012-05-02 21:58:09 -0400
commitee2f6f1bed21a5ef92d84634cd4e949062073d62 (patch)
treebffd019880ea439b6aef60a3c4f8283b9ded5df3 /nova/tests
parente175c5f1c0275ed43648d43e6e46129680fc6d1b (diff)
Compact pre-Folsom database migrations.
Compacts the pre-Folsom database migrations into a single migration (082_essex.py). Pre-Folsom users will need to upgrade to Essex before running any Folsom migrations. Implements blueprint db-migration-cleanup. Testing notes available at: http://wiki.openstack.org/database_migration_testing Change-Id: I64c06a3adcf83d6d723c4c11001544ba97668413
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/__init__.py5
-rw-r--r--nova/tests/test_migrations.py15
2 files changed, 14 insertions, 6 deletions
diff --git a/nova/tests/__init__.py b/nova/tests/__init__.py
index 0e33cd7ac..31e19020c 100644
--- a/nova/tests/__init__.py
+++ b/nova/tests/__init__.py
@@ -50,7 +50,8 @@ def reset_db():
engine = get_engine()
engine.dispose()
conn = engine.connect()
- conn.connection.executescript(_DB)
+ if _DB:
+ conn.connection.executescript(_DB)
else:
shutil.copyfile(os.path.join(FLAGS.state_path, FLAGS.sqlite_clean_db),
os.path.join(FLAGS.state_path, FLAGS.sqlite_db))
@@ -69,7 +70,7 @@ def setup():
from nova.tests import fake_flags
if FLAGS.sql_connection == "sqlite://":
- if migration.db_version() > 1:
+ if migration.db_version() > migration.INIT_VERSION:
return
else:
testdb = os.path.join(FLAGS.state_path, FLAGS.sqlite_db)
diff --git a/nova/tests/test_migrations.py b/nova/tests/test_migrations.py
index 0e36236bc..cdc90a46e 100644
--- a/nova/tests/test_migrations.py
+++ b/nova/tests/test_migrations.py
@@ -33,6 +33,7 @@ from migrate.versioning import repository
import sqlalchemy
import nova.db.sqlalchemy.migrate_repo
+import nova.db.migration as migration
from nova.db.sqlalchemy.migration import versioning_api as migration_api
from nova import log as logging
from nova import test
@@ -253,14 +254,19 @@ class TestMigrations(test.TestCase):
# upgrades successfully.
# Place the database under version control
- migration_api.version_control(engine, TestMigrations.REPOSITORY)
- self.assertEqual(0,
+ migration_api.version_control(engine, TestMigrations.REPOSITORY,
+ migration.INIT_VERSION)
+ self.assertEqual(migration.INIT_VERSION,
migration_api.db_version(engine,
TestMigrations.REPOSITORY))
+ migration_api.upgrade(engine, TestMigrations.REPOSITORY,
+ migration.INIT_VERSION + 1)
+
LOG.debug('latest version is %s' % TestMigrations.REPOSITORY.latest)
- for version in xrange(1, TestMigrations.REPOSITORY.latest + 1):
+ for version in xrange(migration.INIT_VERSION + 2,
+ TestMigrations.REPOSITORY.latest + 1):
# upgrade -> downgrade -> upgrade
self._migrate_up(engine, version)
if snake_walk:
@@ -271,7 +277,8 @@ class TestMigrations(test.TestCase):
# Now walk it back down to 0 from the latest, testing
# the downgrade paths.
for version in reversed(
- xrange(0, TestMigrations.REPOSITORY.latest)):
+ xrange(migration.INIT_VERSION + 1,
+ TestMigrations.REPOSITORY.latest)):
# downgrade -> upgrade -> downgrade
self._migrate_down(engine, version)
if snake_walk: