Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Pipeline database service is not ready

Daniel Degasperi January 5, 2018

Hi,

I've encountered a issue using a database service and running my unit tests. The tests started before the database service was ready and due this the unit tests failed.

Has anybody else had similar behaviors?

1 answer

1 accepted

0 votes
Answer accepted
lassian
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 30, 2018

Hi Daniel,

There are a number of ways you can wait for a service to be ready before executing your test command in pipelines but it all depends on how your service is determined to be ready.

This question from the community has a bash script that awaits mariadb/mysql to be ready by testing if a TCP connection can be established to the databases port, you can tweak this port for your service aswell if its not one of those databases :) 

Waiting for dependant services

Whilst that script may work for databases it only awaits it to be ready for connections if you also require waiting for schema changes or data imports you will have to write your own custom bash scripts for this behaviour but the logic will be much the same poll checking (waiting) for the condition you are after.

Also feel free in the meantime to watch the following open feature request for this to be added to pipelines :)

Wait until services are ready

Regards

Daniel Degasperi February 1, 2018

Hi Nathan,

thank you for your answer. I will try the solution with the shell script and hope this functionality will be implemented someday in bitbucket pipelines.  :)

Regards,

Daniel

slmt February 13, 2018

hope this functionality will be implemented someday in bitbucket pipelines.  :)

 

Until Docker implements a standard event in which all containers can notify interested parties that they are truly ready (and every image honours it), Bitbucket Pipelines won't be able to wait for databases to be ready in any sort of standard way.

You'll need to health-check in a loop, e.g.

until docker run --rm --link my_db_container:pg --net my_db_network postgres pg_isready -U postgres -h pg > /dev/null 2>&1; do sleep 1; done

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events