Bug #4981
Django's testrunner fails to destroy test DB
Status: | New | Start date: | 01/24/2014 | |
---|---|---|---|---|
Priority: | Medium | Due date: | ||
Assignee: | - | % Done: | 0% |
|
Category: | - | Spent time: | - | |
Target version: | 0.16 |
Description
Django's testrunner fails to destroy test DB, because connections are held
open because of DB connection pooling. We need to extend Django's
testrunner to close all pooled connections before tearing down databases.
Traceback (most recent call last):
File "/usr/bin/snf-manage", line 9, in <module>
load_entry_point('snf-webproject==0.15rc5-12134-2fb4aff-14402ed', 'console_scripts', 'snf-manage')()
File "/usr/lib/python2.7/dist-packages/synnefo/webproject/manage.py", line 335, in main
mu.execute()
File "/usr/lib/python2.7/dist-packages/synnefo/webproject/manage.py", line 265, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 49, in run_from_argv
super(Command, self).run_from_argv(argv)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/lib/python2.7/dist-packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/usr/lib/python2.7/dist-packages/south/management/commands/test.py", line 8, in handle
super(Command, self).handle(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/django/core/management/commands/test.py", line 72, in handle
failures = test_runner.run_tests(test_labels)
File "/usr/lib/python2.7/dist-packages/django/test/simple.py", line 383, in run_tests
self.teardown_databases(old_config)
File "/usr/lib/python2.7/dist-packages/pithos/api/test/__init__.py", line 155, in teardown_databases
**kwargs)
File "/usr/lib/python2.7/dist-packages/django/test/simple.py", line 351, in teardown_databases
connection.creation.destroy_test_db(old_name, self.verbosity)
File "/usr/lib/python2.7/dist-packages/django/db/backends/creation.py", line 378, in destroy_test_db
new_connection.creation._destroy_test_db(test_database_name, verbosity)
File "/usr/lib/python2.7/dist-packages/django/db/backends/creation.py", line 393, in _destroy_test_db
% self.connection.ops.quote_name(test_database_name))
File "/usr/lib/python2.7/dist-packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: database "test_snf_apps" is being accessed by other users
DETAIL: There are 1 other session(s) using the database.