From f45db5e754cd30461f47fe1b65f8cf3681d05874 Mon Sep 17 00:00:00 2001 From: Jay Pipes Date: Thu, 15 Sep 2011 18:49:40 -0400 Subject: [PATCH] Fixes Bug #851216 Fixes a recurring issue with tests that were decorated with the @runs_sql decorator where the file-based SQLite registry database used in those tests was not being properly cleaned up, which was causing some random-looking failures when python setup.py test was run for the DEB builders on Jenkins. According to Monty, files needed in testing do indeed need to be in MANIFEST.in, so I added the test_migrations.conf file to that. Sorry, BrianW! Change-Id: I6535b999921d159de5d957f6b70df3c13310e449 --- MANIFEST.in | 1 + glance/tests/functional/__init__.py | 7 +++++++ glance/tests/unit/test_migrations.py | 7 ++++--- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/MANIFEST.in b/MANIFEST.in index 04821731ce..e10de99d4a 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,6 +4,7 @@ include MANIFEST.in pylintrc include run_tests.py include glance/registry/db/migrate_repo/migrate.cfg include glance/registry/db/migrate_repo/versions/*.sql +include glance/tests/unit/test_migrations.conf graft doc graft etc graft tools diff --git a/glance/tests/functional/__init__.py b/glance/tests/functional/__init__.py index 4afdf39d38..2137c419f6 100644 --- a/glance/tests/functional/__init__.py +++ b/glance/tests/functional/__init__.py @@ -472,6 +472,13 @@ def stop_servers(self): if os.path.exists(self.test_dir): shutil.rmtree(self.test_dir) + # We do this here because the @runs_sql decorator above + # actually resets the registry server's sql_connection + # to the original (usually memory-based SQLite connection) + # and this block of code is run *before* the finally: + # block in that decorator... + self._reset_database(self.registry_server.sql_connection) + def run_sql_cmd(self, sql): """ Provides a crude mechanism to run manual SQL commands for backend diff --git a/glance/tests/unit/test_migrations.py b/glance/tests/unit/test_migrations.py index 0b60051b86..0ab47554a2 100644 --- a/glance/tests/unit/test_migrations.py +++ b/glance/tests/unit/test_migrations.py @@ -67,10 +67,11 @@ def setUp(self): for key, value in defaults.items(): TestMigrations.TEST_DATABASES[key] = value except ConfigParser.ParsingError, e: - print ("Failed to read test_migrations.conf config file. " - "Got error: %s" % e) + self.fail("Failed to read test_migrations.conf config " + "file. Got error: %s" % e) else: - self.fail("Unable to find test_migrations.conf") + self.fail("Failed to find test_migrations.conf config " + "file.") self.engines = {} for key, value in TestMigrations.TEST_DATABASES.items():