#24791 closed Bug (fixed)
Cannot run tests without access to postgres database
Reported by: | Daniel Hahler | Owned by: | nobody |
---|---|---|---|
Component: | Testing framework | Version: | 1.8 |
Severity: | Release blocker | Keywords: | |
Cc: | django@… | Triage Stage: | Ready for checkin |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The change for ticket #16969 prevents Django from being able to run tests on Heroku,
here you are not allowed to connect to the "postgres" database, at least with the free tier.
Would it be an option to use an explicitly configured
DATABASES['default']['TEST']['NAME']
setting, instead of 'postgres' here?
Or could there be a new setting, like
DATABASES['default']['TEST']['CONNECT_NAME']
?
The traceback, for reference (Django 1.8.1):
.heroku/python/lib/python2.7/site-packages/pytest_django/fixtures.py:53: > db_cfg = setup_databases(verbosity=0, interactive=False) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .heroku/python/lib/python2.7/site-packages/django/test/runner.py:370: in setup_databases serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True), .heroku/python/lib/python2.7/site-packages/django/db/backends/base/creation.py:354: in create_test_db self._create_test_db(verbosity, autoclobber, keepdb) .heroku/python/lib/python2.7/site-packages/django/db/backends/base/creation.py:447: in _create_test_db with self._nodb_connection.cursor() as cursor: .heroku/python/lib/python2.7/site-packages/django/db/backends/base/base.py:164: in cursor cursor = self.make_cursor(self._cursor()) .heroku/python/lib/python2.7/site-packages/django/db/backends/base/base.py:135: in _cursor self.ensure_connection() .heroku/python/lib/python2.7/site-packages/django/db/backends/base/base.py:130: in ensure_connection self.connect() .heroku/python/lib/python2.7/site-packages/django/db/utils.py:97: in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) .heroku/python/lib/python2.7/site-packages/django/db/backends/base/base.py:130: in ensure_connection self.connect() .heroku/python/lib/python2.7/site-packages/django/db/backends/base/base.py:119: in connect self.connection = self.get_new_connection(conn_params) .heroku/python/lib/python2.7/site-packages/django/db/backends/postgresql_psycopg2/base.py:172: in get_new_connection connection = Database.connect(**conn_params) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ... if dsn is None: if not items: raise TypeError('missing dsn and no parameters') else: dsn = " ".join(["%s=%s" % (k, _param_escape(str(v))) for (k, v) in items]) > conn = _connect(dsn, connection_factory=connection_factory, async=async) E OperationalError: FATAL: permission denied for database "postgres" E DETAIL: User does not have CONNECT privilege. .heroku/python/lib/python2.7/site-packages/psycopg2/__init__.py:164: OperationalError
Change History (9)
comment:1 by , 10 years ago
Cc: | added |
---|
comment:2 by , 10 years ago
comment:3 by , 10 years ago
#16969 has been resolved on the assumption that PostgreSQL users always have access to the postgres
database (read https://code.djangoproject.com/ticket/16969#comment:4).
Now either the bug is on Heroku's side and they should grant at least the CONNECT privilege to all of their users, or we decide that our assumption was wrong and we should at least partially revert our patch, or find a workaround. Thoughts?
comment:5 by , 10 years ago
Has patch: | set |
---|
In this PR, I tried to fallback to the database of the current connection when the 'postgres' db isn't available. Might be an acceptable path...
comment:6 by , 10 years ago
Triage Stage: | Accepted → Ready for checkin |
---|
#24795 was closed as a duplicate (affecting PostGIS user).