I'm not 100% clear on the need to dispatch each test suite to a different node but it sounds like something like this should meet your requirements:
hub:
image: selenium/hub:2.53.0
ports:
- "4444:4444"
firefox:
image: selenium/node-chrome:2.53.0
links:
- hub
chrome:
image: selenium/node-chrome:2.53.0
links:
- hub
If you save this in a directory as docker-compose.yml
and then cd
into the directory you can do something like:
docker-compose up -d
docker-compose scale firefox=3 chrome=3
This will give you 3 nodes with each browser and the selenium hub will handle assigning your tests to the nodes such that they are only running a single set of tests at once.
You then tell all of your tests to use a remote webdriver & you are able to control which browser gets used for each set of tests:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote(
command_executor='http://127.0.0.1:4444/wd/hub',
desired_capabilities=DesiredCapabilities.CHROME)
driver.get("http://www.seleniumhq.org/")
Obviously you would need to modify this to use your desired language to write the tests in. I just posted a quick example in python to get you going as you didn't specify a language & that is what I am most familiar with.
EDIT: Possible way of meeting your actual requirement:
hub:
image: selenium/hub:2.53.0
links:
- app
firefox:
image: selenium/node-chrome:2.53.0
links:
- hub
chrome:
image: selenium/node-chrome:2.53.0
links:
- hub
test:
image: your/testimage
links:
- hub
app:
image: your/appimage
You could then start multiple instances of the whole setup by running (in the directory where the docker-compose.yml is):
docker-compose --project-name <identifier> up -d
If you change <identifier>
to something unique for each instance then you can have multiple instances running at one time. You would also probably want to add a volume
to your test container so that you can persist results/logs/screenshots but I don't really know enough about the setup to tell you how to do that.
I would question whether you need the selenium-hub in this case but it does add some convenience so you may still wish to use it.