summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-05-03 21:00:11 +0000
committerGerrit Code Review <review@openstack.org>2012-05-03 21:00:11 +0000
commit0d64caa6834886f572b785306e2aa0651e22c92a (patch)
tree3ebc81912e6b6683e44a21da913c7d9e434d8c0d /nova/tests
parente3837c632ac9038f316d956a3b55a42842ad9d8e (diff)
parentee2f6f1bed21a5ef92d84634cd4e949062073d62 (diff)
Merge "Compact pre-Folsom database migrations."
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: