Skip to content
This repository was archived by the owner on Oct 15, 2024. It is now read-only.
This repository was archived by the owner on Oct 15, 2024. It is now read-only.

Heroku CI does not work with in-dyno databases #17

@ddahan

Description

@ddahan

When running Heroku CI with in-dyno Postgres database, I got a django.db.utils.ProgrammingError: role "postgres" does not exist error.

Here is my app.json

{
  "buildpacks": [
    {
      "url": "heroku/python"
    }
  ],
  "environments": {
    "test": {
      "formation": {
        "test": {
          "quantity": 1,
          "size": "performance-m"
        }
      },
      "scripts": {
        "test": "flake8 fugoproj && python fugoproj/manage.py test fugoproj"
      },
      "addons": [
        "heroku-postgresql:in-dyno"
      ]
    }
  }
}

Here is the heroku test setup log (succeed)

-----> Fetching https://github.com/heroku/heroku-buildpack-ci-postgresql buildpack...
       buildpack downloaded
-----> Fetching heroku/python buildpack...
       buildpack downloaded
-----> postgresql app detected
       Using postgresql version: 10.1
       Using stack version: heroku-16
-----> Fetching and vendoring postgresql into slug
-----> Initializing database
       The files belonging to this database system will be owned by user "u36536".
       This user must also own the server process.
       
       The database cluster will be initialized with locale "en_US.UTF-8".
       The default text search configuration will be set to "english".
       
       Data page checksums are disabled.
       
       creating directory /app/vendor/postgresql/data ... ok
       creating subdirectories ... ok
       selecting default max_connections ... 100
       selecting default shared_buffers ... 128MB
       selecting dynamic shared memory implementation ... posix
       creating configuration files ... ok
       running bootstrap script ... ok
       performing post-bootstrap initialization ... ok
       syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
       
       Success. You can now start the database server using:
       
           pg_ctl -D /app/vendor/postgresql/data -l logfile start
       
       waiting for server to start.... done
       server started
       CREATE ROLE
-----> Copying .profile.d/pg.sh to add postgresql binaries to PATH
-----> postgresql done
-----> Python app detected
       Skipping installation, as Pipfile.lock hasn't changed since last deploy.
-----> No test-setup command provided. Skipping.

Here is the heroku test log (fails)

-----> Running test command `flake8 fugoproj && python fugoproj/manage.py test fugoproj`...
/app/.heroku/python/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
  """)
Using existing test database for alias 'default'...
System check identified no issues (0 silenced).
..........................................................................................................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 314 tests in 50.910s
OK
Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
psycopg2.ProgrammingError: role "postgres" does not exist
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
  File "fugoproj/manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 356, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 29, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 283, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 330, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/test.py", line 62, in handle
    failures = test_runner.run_tests(test_labels)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/test/runner.py", line 604, in run_tests
    self.teardown_databases(old_config)
  File "/app/.heroku/python/lib/python3.6/site-packages/django_heroku/core.py", line 41, in teardown_databases
    self._wipe_tables(connection)
  File "/app/.heroku/python/lib/python3.6/site-packages/django_heroku/core.py", line 33, in _wipe_tables
    """
  File "/app/.heroku/python/lib/python3.6/site-packages/raven/contrib/django/client.py", line 127, in execute
    return real_execute(self, sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 62, in execute
    return self.cursor.execute(sql)
django.db.utils.ProgrammingError: role "postgres" does not exist
-----> test command `flake8 fugoproj && python fugoproj/manage.py test fugoproj` failed with exit status 1

Additional note

  • I'm configuring DATABASE with ssl_require=False, otherwise it does not work at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions