Skip to content

Commit

Permalink
Fixes Bug #851216
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jaypipes committed Sep 16, 2011
1 parent 7268f2c commit f45db5e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions glance/tests/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions glance/tests/unit/test_migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit f45db5e

Please sign in to comment.