question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot bring up postgresql when running make test-unit

See original GitHub issue

Describe 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:closed
  • Created 3 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
heisencodercommented, Sep 3, 2020

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.

0reactions
heisencodercommented, Sep 3, 2020

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:

So, overall, I think to avoid contention with default PostgreSQL installs, dbt tests should pick a different port than 5432.

This seems reasonable to me! Is this a change you’d be interested in contributing @heisencoder https://github.com/heisencoder?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/fishtown-analytics/dbt/issues/2738#issuecomment-686638500, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADA3XFBWEWTA7RIZCID5YLSD7GORANCNFSM4QTF46BA .

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found