Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--with-docker unable to connect to local postgres when running integration tests #1486

Open
agware opened this issue Aug 21, 2023 · 2 comments

Comments

@agware
Copy link

agware commented Aug 21, 2023

Expected behaviour

Integration tests run with the --with-docker flag should connect to a postgres instance and run the tests

Actual behaviour

Failure to connect to database as root role

E       sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: FATAL:  role "root" does not exist
E       
E       (Background on this error at: https://sqlalche.me/e/14/e3q8)

/usr/local/lib/python3.10/dist-packages/psycopg2/__init__.py:122: OperationalError

Steps to reproduce the behaviour

  1. Follow the setup guide for postgres
  2. Run ./check-code.sh --with-docker integration_tests

Environment information

python == 3.11.4 <- in venv, 3.10.12 <- global
pytest == 7.4.0

Open Data Cube core, version 1.8.16.dev4+g24b046e7
Ubuntu 22.04.3 LTS

Additional Information

A temporary fix is mounting the datacube_information.conf file and changing the db_user to postgres, i.e.

In check_code.sh:

exec docker run $ti \
         -e SKIP_STYLE_CHECK="${SKIP_STYLE_CHECK:-no}" \
         -v $(pwd):/code \
         --mount type=bind,source="${HOME}"/.datacube_integration.conf,target=/root/.datacube_integration.conf,readonly \
         opendatacube/datacube-tests:latest \
         $0 $@

and in .datacube_integration.conf

db_username: postgres

Note: Stale issues will be automatically closed after a period of six months with no activity.
To ensure critical issues are not closed, tag them with the Github pinned tag.
If you are a community member and not a maintainer please escalate this issue to maintainers via
GIS StackExchange or Slack.

@Ariana-B
Copy link
Contributor

Ariana-B commented Sep 7, 2023

Hi, are you sure you set up your postgres users correctly? Were you able to run sudo -u postgres createuser --superuser $USER successfully?

@agware
Copy link
Author

agware commented Dec 6, 2024

Hi Ariana, thank you for the reply.

Isn't the point of running check_code.sh with the --with-docker flag to bypass the local setup of postgres and instead use the provided container with a pre-configured option? So in this case, I don't believe that part of the set up doc is relevant. Happy to discuss further though.

Referring to your docs:
Alternatively one can use the opendatacube/datacube-tests docker image to run tests. This docker includes database server pre-configured for running integration tests. Add --with-docker command line option as a first argument to ./check-code.sh script.

./check-code.sh --with-docker integration_tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants