How do I have Django test DB work in azure pipeline.yaml?

Ange 0 Reputation points
2023-07-15T02:22:20.1833333+00:00

I have a Django setup with postgres.

I recently wrote some basic unit tests that exercises the db. Passes in dev.

But when I try to put python manage.py test in azure-pipelines.yml I get something like this:

connection to server at "localhost" (127.0.0.1), port 5432 failed: Connection refused
	Is the server running on that host and accepting TCP/IP connections?

So, it seems in pipeline env there's not a way to have a postgres test db. So I tried to have it connect to my production db instead by changing the env vars for the pipeline. But I just get this:

Connection timed out
	Is the server running on that host and accepting TCP/IP connections?

What's the proper setup in an azure-pipelines.yml so that I can successfully have Django connect to a test server and run my unit tests?

Community Center Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-07-15T04:30:08.71+00:00

    You need to modify your Postgre configuration to allow remote connections to your database

    https://blog.devart.com/configure-postgresql-to-allow-remote-connection.html

    or you can check the following configuration for your pipeline modification

    https://gist.github.com/jefftriplett/d35e120ef9884bcff61c5ade0740f52d?permalink_comment_id=3083831

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.