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
This commit is contained in:
Jay Pipes 2011-09-15 18:49:40 -04:00
parent 7268f2c991
commit f45db5e754
3 changed files with 12 additions and 3 deletions

View File

@ -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

View File

@ -472,6 +472,13 @@ class FunctionalTest(unittest.TestCase):
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

View File

@ -67,10 +67,11 @@ class TestMigrations(unittest.TestCase):
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():