Cannot bring up postgresql when running make test-unit
See original GitHub issueDescribe the bug
I’m following the instructions in contributing.md
to get a local dbt development setup, and am running into the following error:
$ make test-unit
Unit test run starting...
Creating fishtown-dbt_database_1 ...
Creating fishtown-dbt_database_1 ... error
ERROR: for fishtown-dbt_database_1 Cannot start service database: driver failed programming external connectivity on endpoint fishtown-dbt_database_1 (7e47771a8eca024021670590bc830ca4009cbc09a20294043ccf38127a917c1c): Bind for 0.0.0.0:5432 failed: port is already allocated
ERROR: for database Cannot start service database: driver failed programming external connectivity on endpoint fishtown-dbt_database_1 (7e47771a8eca024021670590bc830ca4009cbc09a20294043ccf38127a917c1c): Bind for 0.0.0.0:5432 failed: port is already allocated
ERROR: Encountered errors while bringing up the project.
Command exited with non-zero status 1
0.54user 0.05system 0:00.85elapsed 69%CPU (0avgtext+0avgdata 56204maxresident)k
0inputs+0outputs (0major+14387minor)pagefaults 0swaps
make: *** [Makefile:14: test-unit] Error 1
Steps To Reproduce
- Follow instructions in
CONTRIBUTING.md
:- Install the recommended tools, including postgres, docker-compose
- Create a venv:
python3 -m venv env && source env/bin/activate
- Run
make test-unit
Expected behavior
The unit tests to run against a local postgres instance.
System information
Which database are you using dbt with?
- postgres
The output of dbt --version
:
$ dbt --version
installed version: 0.18.0-rc1
latest version: 0.17.2
Your version of dbt is ahead of the latest release!
Plugins:
- postgres: 0.18.0rc1
- redshift: 0.18.0rc1
- snowflake: 0.18.0rc1
- bigquery: 0.18.0rc1
The operating system you’re using: Debian 10
The output of python --version
:
Python 3.8.5
Additional context
This error was caused because I already had a postgres instance running in docker. I ran the following commands to find and close the previous instance:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7ede2de7c867 postgres "docker-entrypoint.s…" 17 hours ago Up 17 hours 0.0.0.0:5432->5432/tcp dbt_database_1
(env)
$ docker stop 7ede2de7c867
7ede2de7c867
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Documentation: 15: 33.1. Running the Tests - PostgreSQL
Because this test method runs a temporary server, it will not work if you did the build as the root user, since the...
Read more >Running PostgreSQL in memory only - Stack Overflow
I can't figure out how to run in-memory Postgres database for testing. Is it possible? No, it is not possible. PostgreSQL is implemented...
Read more >pgTAP: Unit Testing for PostgreSQL
pgTAP allows you to really test the database, not only verifying the structure of your schema, but also by exercising any views, procedures,...
Read more >zonkyio/embedded-postgres - GitHub
The library allows embedding PostgreSQL into Java application code with no external dependencies. Excellent for allowing you to unit test with a "real"...
Read more >Postgres and integration testing in Node.js apps - Medium
This article explains one of the testing approaches we use at Geoblink for our integration tests involving Postgres.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I did the search-and-replace of the port number, but now I can’t get docker-compose to bring up Postgres on any port other than 5432. At this point, I’m in favor of just leaving this bug as a breadcrumb for others who run into the same issue and closing it.
No problem! It’s a straightforward change for the search-and-replace. My only concern would be if the GitHub actions are already expecting a Postgres database running on port 5432. However, it looks like a new Postgres instance is brought up each time, so I’m guessing it won’t be a concern.
On Thu, Sep 3, 2020 at 11:24 AM Jeremy Cohen notifications@github.com wrote: