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?
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 :)
Regards
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.