#22420: Postgresql connections not being dropped between tests?
-----------------------------------+--------------------
     Reporter:  bacongobbler       |      Owner:  nobody
         Type:  Uncategorized      |     Status:  new
    Component:  Testing framework  |    Version:  1.6
     Severity:  Normal             |   Keywords:
 Triage Stage:  Unreviewed         |  Has patch:  0
Easy pickings:  0                  |      UI/UX:  0
-----------------------------------+--------------------
 I'm on Django 1.6.2, and ever since we switched to using psql for our
 database, we have been hitting an issue with running the test suite. I
 haven't been able to figure out why this occurs. Logs follow below.

 {{{
 $ make coverage
 coverage run manage.py test --noinput api web
 Creating test database for alias 'default'...
 ...............................................
 ----------------------------------------------------------------------
 Ran 47 tests in 12.388s

 OK
 Destroying test database for alias 'default'...
 Traceback (most recent call last):
   File "manage.py", line 13, in <module>
     execute_from_command_line(sys.argv)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 399, in
 execute_from_command_line
     utility.execute()
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/__init__.py", line 392, in execute
     self.fetch_command(subcommand).run_from_argv(self.argv)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/commands/test.py", line 50, in
 run_from_argv
     super(Command, self).run_from_argv(argv)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/base.py", line 242, in run_from_argv
     self.execute(*args, **options.__dict__)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/commands/test.py", line 71, in execute
     super(Command, self).execute(*args, **options)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/base.py", line 285, in execute
     output = self.handle(*args, **options)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/south/management/commands/test.py", line 8, in handle
     super(Command, self).handle(*args, **kwargs)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/core/management/commands/test.py", line 88, in handle
     failures = test_runner.run_tests(test_labels)
   File
 
"/Users/bacongobbler/git/github.com/opdemand/deis/controller/api/tests/__init__.py",
 line 41, in run_tests
     test_labels, extra_tests, **kwargs)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/test/runner.py", line 147, in run_tests
     self.teardown_databases(old_config)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/test/runner.py", line 122, in teardown_databases
     connection.creation.destroy_test_db(old_name, self.verbosity)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/db/backends/creation.py", line 443, in destroy_test_db
     new_connection.creation._destroy_test_db(test_database_name,
 verbosity)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/db/backends/creation.py", line 457, in _destroy_test_db
     % self.connection.ops.quote_name(test_database_name))
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/db/backends/util.py", line 53, in execute
     return self.cursor.execute(sql, params)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/db/utils.py", line 99, in __exit__
     six.reraise(dj_exc_type, dj_exc_value, traceback)
   File "/Users/bacongobbler/venv/lib/python2.7/site-
 packages/django/db/backends/util.py", line 51, in execute
     return self.cursor.execute(sql)
 OperationalError: database "test_deis" is being accessed by other users
 DETAIL:  There is 1 other session using the database.

 make: *** [coverage] Error 1
 }}}

 To me, it looks like Django is trying to destroy the temporary test
 database, but there are some connections still left over from the previous
 test suite run, which prevents the database from being dropped.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/22420>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.f63e788c6fffa12c2278b7050268dd3b%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to