Closed viduls closed 7 years ago
First of all, I do not see any reason why you would do that. Could you explain in some more detail what are the reasons for trying this?
But assuming you really need it. The obvious part: You can’t bind two containers on the same host port. What you would do is binding each container to some ports on your host eg:
container1 – 4445 container2 – 4446
and use some kind of reverse proxy on port 4444 (eg Nginx) to route requests to a proper container. In a selenium context there is a good proxy called ggr (https://github.com/aerokube/ggr) which allows you to route requests to different selenium hubs. We are using this combination to run multiple Zalenium instances on DIFFERENT machines while still be able to have one single address to test against and also having some load balancing between the instances.
Great answer @iMbaundso . I believe @diemol implemented support for running more than one Zalenium on the same host but I don't see using this feature is a good idea. I agree ggr
is the way to go in this use case.
I guess the use case would be something like having a Jenkins host, and running several concurrents jobs in it with different UI tests, and then each set of tests could have its own Zalenium.
This should work straightforward, but we don't test it a lot since it is not an important feature for us.
Just try the following:
Start one with the name zalenium_1, mapping port 4444, and with different mapped folders.
docker run --rm -ti --name zalenium_1 -p 4444:4444 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos_1:/home/seluser/videos \
--privileged dosel/zalenium start
And then another one with the name zalenium_2, mapping port 4455
docker run --rm -ti --name zalenium_2 -p 4455:4444 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /tmp/videos_2:/home/seluser/videos \
--privileged dosel/zalenium start
Then just go to http://localhost:4444/grid/console and http://localhost:4455/grid/console and point your tests properly.
That's it.
Thanks @iMbaundso @diemol for your replies. @iMbaundso , When talking about use cases, we have different testsuites in our regression(as mentioned by @diemol). We prefer to have dedicated containers for some of these suites, so these can be monitored and tracked separately.
@diemol, I was actually trying the way you mentioned prior posting this question, only concern would be, How can we view test execution on Zalenium dashboard, using http://localhost:4444/grid/admin/live doesn't seems to work if I change the port to http://localhost:4445/grid/admin/live
@viduls It also works, you just have the wrong port in the url, instead of 4455, you have 4445.
http://localhost:4444/grid/admin/live http://localhost:4455/grid/admin/live
I can confirm that you can have multiple zalenium containers running on the same host. I do this for the reason @diemol mentions above -- multiple job running from Jenkins. I determine which ports are free starting from 4444 and move up from there, (including free ports for VNC, noVNC, etc). The directories for videos are also different, etc. The container name is also different. This all works reliably.
Wow thanks for the feedback @borisivan you are a Zalenium pro!
Thanks for confirming @borisivan! I'll close the issue since a solution was provided.
Feel free to reopen in case a related problem shows up.
Sorry to comment on closed issue. I was able to run two instances of Zalenium on a single host. Howerver, if I tried to run more than three instances, the only the first two spawned the child containers.
UPDATE: After pulling the latest image, I was able to run more than three Zalenium instances including child containers.
@yamamoo can you please help me on did you configure your tests to run on multiple zalenium containers? I want to run my 300 + tests across 10 containers so that I can get the results as quick as I can. looking forward to hear on what you did?
@jandialrajiv , it's been a while since I tested this, but I think what I did was to create four copies of docker-compose files (copied from Zalenium repo's docker/docker-compose-test.yaml) to get 4 Zalenium stacks. I gave unique values in each yaml file.
If you just need 10 Selenium containers, is may be simpler to use one docker compose file with --maxDockerSeleniumContainers parameter set to 10.
thanks so much @yamamoo . How do you direct your tests to multiple containers? I run the below command to start 5 containers on my docker host, and it starts 5 containers , however the tests are running only in 1 container. docker run --rm -ti --name zalenium2 -p 4445:4444 -v /var/run/docker.sock:/var/run/docker.sock -v --videoRecordingEnabled=false --privileged dosel/zalenium start --desiredContainers 5
Once you have 5 containers up and running, then it works as the same way as a Selenium Grid + 5 Selenium Nodes. Your test can request multiple remote web drivers against a Zalenium hub's URL and Zalenium will automatically dispatch the command from each driver to any available node. However, if you are running your test in single-thread mode, it will only use one Zalanium container and all the tests will run serially. In that case, you need to run your tests in parallel. If you are using TestNG, you can try setting parallel and thread-count parameters.
the Zalenium is spinning up 3 containers and running 3 tests in parallel but each container is running 1 tests only and shutting down the containers. Do you know why? I tried --maxTestSessions to 5 but that did not help either.
@diemol the Zalenium we have set up is spinning up 3 containers and running 3 tests in parallel but each container is running 1 tests only and shutting down the containers. Do you know why? I tried --maxTestSessions to 5 but that did not help either.
No clue, based on what you write it should work. Probably it is easier if you join the #zalenium channel at Slack where the community can help you as well.
I guess the use case would be something like having a Jenkins host, and running several concurrents jobs in it with different UI tests, and then each set of tests could have its own Zalenium.
This should work straightforward, but we don't test it a lot since it is not an important feature for us.
Just try the following:
- Start one with the name zalenium_1, mapping port 4444, and with different mapped folders.
docker run --rm -ti --name zalenium_1 -p 4444:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /tmp/videos_1:/home/seluser/videos \ --privileged dosel/zalenium start
- And then another one with the name zalenium_2, mapping port 4455
docker run --rm -ti --name zalenium_2 -p 4455:4444 \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /tmp/videos_2:/home/seluser/videos \ --privileged dosel/zalenium start
Then just go to http://localhost:4444/grid/console and http://localhost:4455/grid/console and point your tests properly.
That's it.
When I start zalenium_2. it kills all the nodes of zalenium_1 which were having port 40000, 40001. Zalenium_2 nodes gets heses ports assignned to themselves (40000, 40001). After that zalnium_1 nodes registered again with new ports.
Zalenium_1 04:42:33.794 [Thread-10] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.3:40000 04:42:37.764 [Thread-11] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.4:40001
Now start Zalenium_2 zalnium_1 logs - 04:43:11.276 [http://172.17.0.4:40001] INFO d.z.e.z.p.DockerSeleniumRemoteProxy - Marking node down. 04:43:11.328 [http://172.17.0.3:40000] INFO d.z.e.z.p.DockerSeleniumRemoteProxy - Marking node down.
04:43:38.865 [Thread-12] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.4:40002 04:43:45.056 [Thread-13] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.7:40003
zalnum_2 logs- 04:43:35.636 [Thread-10] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.3:40000 04:43:41.123 [Thread-11] INFO d.z.e.z.registry.ZaleniumRegistry - Registered a node http://172.17.0.6:40001
So when I start zalenium_2 all the test cases in run by zalenium_1 will get failed. This is the common usecase if we set up jobs in TeamCity or any other buils tool to run test cases.
Hello, Do we have any port dependancy for
4444
on host/container binding? Just wondering can we run multiple zalenium containers on same host machine?