Docker-selenium: Issues running selenium grid on Docker 1.12 swarm mode cluster

Created on 3 Aug 2016  Â·  12Comments  Â·  Source: SeleniumHQ/docker-selenium

I reported the following issue to Docker while trying to get a selenium grid running on a new docker swarm mode cluster. I'm not sure if this is something you've tried doing yet or not, but any input would be much appreciated. I suspect it's a networking issue related to the hub port being exposed and then expecting communications to/from the Chrome nodes to go over the ingress network, but exposing 5555 for them now causes them all to appear as coming from the same VIP (which I'm gathering is expected behavior for the way they're handling service load balancing).

https://github.com/docker/docker/issues/25311

Most helpful comment

Finally got it working! Works for Chrome and Firefox with 2.53.1-x and 3.0.0-x images.

Got the grid up and running by passing in the -host parameter into the nodes service creation command above and dynamically looking up the host name of the running container and passing it to entry_point.sh as SE_OPTS.

bash -c 'SE_OPTS="-host $HOSTNAME" /opt/bin/entry_point.sh'

All 12 comments

Using a normal Swarm (not swarm mode)
I launch my nodes like this:

    selenium:
        image: selenium/node-firefox-debug
        environment:
            HUB_PORT_4444_TCP_ADDR: "seleniumhub"
            HUB_PORT_4444_TCP_PORT: "4444"
        entrypoint: 'bash -c "REMOTE_HOST=\"http://$$HOSTNAME:5555\" /opt/bin/entry_point.sh"'

It fixes my problem with neworking. I hope it can help you.

@iamluc that definitely got me on the right track. I had to tweak it a little bit, since the hostname is associated with the IP's from both the overlay and gateway bridge networks. This is what I'm currently using that works:

docker network create -d overlay selenium-grid
docker service create --network selenium-grid --name hub -p 4444:4444 selenium/hub
docker service create --network selenium-grid --endpoint-mode dnsrr --name chrome --mount type=bind,source=/dev/shm,target=/dev/shm -e HUB_PORT_4444_TCP_ADDR=hub -e HUB_PORT_4444_TCP_PORT=4444 --replicas 10 selenium/node-chrome bash -c 'HOSTIP=$(ip -4 addr show eth0 | grep -Po "inet \K[\d.]+") REMOTE_HOST=http://$HOSTIP:5555 /opt/bin/entry_point.sh'

It's a little hack-ish to get the right IP for the nodes to register with so the hub can communicate back to them, but I'm going to see if I can come up with a better way and submit a PR, since I'm sure I won't be the only person doing this.

Hi @jalmansor,

I used the command you provided, and it works for chrome, but if I change the image to selenium/node-firefox, it does not work. The firefox nodes can't register to the hub. Do you know why this is happening? Thanks.

OK, after I changed to @iamluc 's suggest. It works for firefox.
thanks.

docker service create --network selenium-grid --endpoint-mode dnsrr --name firefox --mount type=bind,source=/dev/shm,target=/dev/shm -e HUB_PORT_4444_TCP_ADDR=sehub -e HUB_PORT_4444_TCP_PORT=4444 --replicas 10 selenium/node-firefox bash -c 'REMOTE_HOST=http://$HOSTNAME:5555 /opt/bin/entry_point.sh'

@habina I had tried that with chrome and it didn't work without doing the extra for figuring out the IP, but I might have to try again now that docker-selenium has been updated.

@jalmansor thanks for your reply.

Hi @jalmansor, have you been able to setup Selenium Grid in Swarm mode using Docker Engine v1.12.2 and any Selenium image tagged 3.0.0? Your approach above worked with 2.53.1-x, but doesn't seem to work with 3.0.0-x.

Finally got it working! Works for Chrome and Firefox with 2.53.1-x and 3.0.0-x images.

Got the grid up and running by passing in the -host parameter into the nodes service creation command above and dynamically looking up the host name of the running container and passing it to entry_point.sh as SE_OPTS.

bash -c 'SE_OPTS="-host $HOSTNAME" /opt/bin/entry_point.sh'

@testphreak I have my 1.12 Swarm up and running with Selenium hub and containers that can correctly communicate, although I am unable to connect to a selected node from my test client, despite it appearing to select one correctly in the hub's logs. I imagine that maybe the Hub is only acting as a re-direct and not performing a pass through for the communication to the web driver (the test client is not in the network as the nodes and hub are, only the hub's port is exposed). Have you ran into any issues like this?

@c4wrd sorry it took long to reply. I was at a conference last week. In my case the test client is in the same network as the Swarm. Hence I haven't run into the issue you're seeing. See if you can have your test client run tests in the same network. You might see better results.

It actually seemed to be resolved when I rebooted all of the nodes and
recreated the overlay network. It re-appears every now and then, and is
more than likely just due to some networking error in Swarm on long-running
hosts.

On Mon, Dec 5, 2016 at 11:24 PM testphreak notifications@github.com wrote:

@c4wrd https://github.com/c4wrd sorry it took long to reply. I was at a
conference last week. In my case the test client is in the same network as
the Swarm. Hence I haven't run into the issue you're seeing. See if you can
have your test client run tests in the same network. You might see better
results.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/SeleniumHQ/docker-selenium/issues/255#issuecomment-265071216,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AIMnegG10y1sBn5aRvs102ojoVuxqjCeks5rFP-EgaJpZM4JbGxJ
.

thanks for sharing. definitely worth a read!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

testphreak picture testphreak  Â·  3Comments

minhnguyenvan95 picture minhnguyenvan95  Â·  5Comments

westlakem picture westlakem  Â·  5Comments

timmipetit picture timmipetit  Â·  6Comments

matthewsamari picture matthewsamari  Â·  4Comments