arquillian / arquillian-cube

Control (docker, kubernetes, openshift) containers in your tests with ease!
http://arquillian.org/arquillian-cube/
121 stars 98 forks source link

Can I use waiting strategies in docker-compose.yml case? #254

Closed smiklosovic closed 8 years ago

smiklosovic commented 8 years ago

I have Docker compose YAML and I want to use that one but when I do, it fails to start containers because of timeout. So I wanted to use some polling strategy and I can not pass it to docker-compose.yml as they seem to be ignored.

I tried mixed approach - I put them into dockerContainers property but that obviously does not do anything since I have COMPOSE definition format.

Am I forced to ignore my docker-compose.yml completely and construct something very similar in dockerContainers property where polling strategies can be used successfully?

aslakknutsen commented 8 years ago

We were discussing this scenario at some conference, and added support for among others multipe files you can include.. but I forget what the specific fix to this issue is, @lordofthejars ?

lordofthejars commented 8 years ago

I think it is not possible. By default it uses ss command. Maybe we should be able to extract some properties outside the orchestration without affecting all the instances but only the chosen ones.

aslakknutsen commented 8 years ago

@lordofthejars yea, this is where we need to be able to enrich the docker-compose configuraton with Cube specific options.. somehow.

smiklosovic commented 8 years ago

Maybe this is offtopic but the reason I am asking is that "normal" waiting strategies are not enough in my case. I have MySQL server in Docker and I am doing some initialization in RUN /my/script.sh when I am setting priviledges to the mysql database, loading sql scripts and so on to the temporary database which is running at port 3307 and once I am done, I kill that instance and I restart that server, now on port 3306.

Cube has in arquillian.xml mysql Docker descriptor in CUBE format and I am exposing 3306 and I am doing port binding as well..

The thing is that when Cube is checking if 3306 is open, it seems to me that it checks the output of the "ss" command executed in container and even that port is really in that ss output (i debugged this intensively), you can not connect to it by mysql client - the fact that it is portforwarded and in ss command output does not say anything about the fact that underlying service is fully up and running - in my case I am doing additional checks e.g. I am trying to create java.sql.Connection to the server from my side to be sure that it is really accessible.

So my guess is that when Docker (or whoever) does that port binding / exposing ports (sorry I am mixing these, it seems to me basically the same thing), it just exposes them, they appear in that output of the ss command but it does not matter it is there because the service which is going to listen to that port is not started yet.

I noticed this after playing with mysql little bit, Tomcat is so fast to start that you just do not notice this stuff. I am also starting MongoDB and it is really fast to start as well so once you are going to execute some tests, you can be very sure that it is running - but that is only because you were lucky.

Maybe you should think about pluggable waiting strategies ...