Parallel Steps Multiple Databases

rails
docker

#1

Hello,

I have a codeship-services.yml with a web and a db service. In my codeship-steps.yml I am running two tests (bundle exec rspec spec/features and bundle exec rspec spec/controllers) in parallel. Both require a running postgres database. Here is what happens: codeships starts up 4 container (2 web/2 db) and executes the commands in parallel. But it is not deterministic which database server is used as both answer to ping db. Due to how rails works with a database.yml oder via ENV variables, the DATABASE_HOST is set to db. That results in very flaky tests and maybe race conditions?

How does codeship ensure that web(1) always talks do db(1)? Is there some kind of network defined only between containers of step 1? Or do I have to define services per step my self? Or should I set the DATABASE_HOST inside the step command definition?

I am curious about a proposed/official solution.


#2

Hey Stephan,

sorry for the (very) slow reply on this topic. The two sets of containers should be separated from each other, and Docker should manage the hostname to IP mapping and make sure that the db hostname on web_1 points to the db_1 container.

That said, I’m going to try to replicate the problem and if you could share a link to one of your builds with me that would be highly appreciated as well.


#3

You could also try to create different networks within the parallel steps. I observed that the local jet cli does not create networks on the fly.