diff --git a/.gitignore b/.gitignore index 8abc9ed7b3..86b5181b14 100644 --- a/.gitignore +++ b/.gitignore @@ -8,12 +8,12 @@ node_modules/ *.swp # Ignoring generated files during the build process -Node*Debug/selenium-debug.conf -Node*Debug/start-*.sh StandaloneC*/selenium.conf StandaloneF*/selenium.conf +StandaloneO*/selenium.conf StandaloneC*/start-*.sh StandaloneF*/start-*.sh +StandaloneO*/start-*.sh # Created by https://www.gitignore.io/api/virtualenv diff --git a/Base/Dockerfile b/Base/Dockerfile index 8a80964118..c8e1889a4b 100644 --- a/Base/Dockerfile +++ b/Base/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:bionic-20200630 +FROM ubuntu:bionic-20200807 LABEL authors="Selenium " #================================================ @@ -71,8 +71,10 @@ COPY supervisord.conf /etc RUN mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor \ && touch /opt/selenium/config.json \ && chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd \ - && wget --no-verbose https://selenium-release.storage.googleapis.com/4.0-alpha-6/selenium-server-4.0.0-alpha-6.jar \ + && wget --no-verbose https://github.com/SeleniumHQ/docker-selenium/raw/alpha-jars/selenium-server-4.0.0-alpha-7.jar \ -O /opt/selenium/selenium-server.jar \ +# && wget --no-verbose https://selenium-release.storage.googleapis.com/4.0-alpha-6/selenium-server-4.0.0-alpha-6.jar \ +# -O /opt/selenium/selenium-server.jar \ && chgrp -R 0 /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor \ && chmod -R g=u /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor diff --git a/Distributor/Dockerfile b/Distributor/Dockerfile index 7bc15dc22f..9c2d0b9c27 100644 --- a/Distributor/Dockerfile +++ b/Distributor/Dockerfile @@ -8,38 +8,12 @@ LABEL authors=SeleniumHQ USER 1200 #======================== -# Selenium Configuration +# Selenium Distributor Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 -EXPOSE 4444 +EXPOSE 5553 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-distributor.sh \ +COPY start-selenium-grid-distributor.sh \ /opt/bin/ COPY selenium-grid-distributor.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Distributor/Dockerfile.txt b/Distributor/Dockerfile.txt index 761222e269..7ef2f4ea56 100644 --- a/Distributor/Dockerfile.txt +++ b/Distributor/Dockerfile.txt @@ -1,38 +1,12 @@ USER 1200 #======================== -# Selenium Configuration +# Selenium Distributor Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 -EXPOSE 4444 +EXPOSE 5553 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-distributor.sh \ +COPY start-selenium-grid-distributor.sh \ /opt/bin/ COPY selenium-grid-distributor.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Distributor/generate_config b/Distributor/generate_config deleted file mode 100755 index c248c88372..0000000000 --- a/Distributor/generate_config +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cat <<_EOF -{ - "host": "${GRID_HUB_HOST}", - "port": ${GRID_HUB_PORT}, - "role": "hub", - "maxSession": ${GRID_MAX_SESSION}, - "newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT}, - "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", - "throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT}, - "jettyMaxThreads": ${GRID_JETTY_MAX_THREADS}, - "cleanUpCycle": ${GRID_CLEAN_UP_CYCLE}, - "browserTimeout": ${GRID_BROWSER_TIMEOUT}, - "timeout": ${GRID_TIMEOUT}, - "debug": ${GRID_DEBUG} -} -_EOF diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index 614414469f..21437cccf4 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -5,4 +5,38 @@ set -e echo "Starting Selenium Grid Distributor..." -java -jar /opt/selenium/selenium-server.jar distributor +if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then + echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_PUBLISH_PORT}" ]]; then + echo "SE_EVENT_BUS_PUBLISH_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then + echo "SE_EVENT_BUS_SUBSCRIBE_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_SESSIONS_MAP_HOST}" ]]; then + echo "SE_SESSIONS_MAP_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_SESSIONS_MAP_PORT}" ]]; then + echo "SE_SESSIONS_MAP_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [ ! -z "$SE_OPTS" ]; then + echo "Appending Selenium options: ${SE_OPTS}" +fi + +java -jar /opt/selenium/selenium-server.jar distributor \ + --sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port ${SE_SESSIONS_MAP_PORT} \ + --publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \ + --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \ + --bind-bus false \ + ${SE_OPTS} diff --git a/EventBus/Dockerfile b/EventBus/Dockerfile new file mode 100644 index 0000000000..d787d66869 --- /dev/null +++ b/EventBus/Dockerfile @@ -0,0 +1,24 @@ +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED. +# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE +# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +FROM selenium/base:4.0.0-alpha-6-20200730 +LABEL authors=SeleniumHQ + +USER 1200 + +#================================= +# Selenium Event Bus Configuration +#================================= + +# Port where events are published +EXPOSE 4442 +# Port where to subscribe for events +EXPOSE 4443 +# Event Bus port +EXPOSE 5557 + +COPY start-selenium-grid-eventbus.sh \ + /opt/bin/ + +COPY selenium-grid-eventbus.conf /etc/supervisor/conf.d/ diff --git a/EventBus/Dockerfile.txt b/EventBus/Dockerfile.txt new file mode 100644 index 0000000000..0e062d37fd --- /dev/null +++ b/EventBus/Dockerfile.txt @@ -0,0 +1,17 @@ +USER 1200 + +#================================= +# Selenium Event Bus Configuration +#================================= + +# Port where events are published +EXPOSE 4442 +# Port where to subscribe for events +EXPOSE 4443 +# Event Bus port +EXPOSE 5557 + +COPY start-selenium-grid-eventbus.sh \ + /opt/bin/ + +COPY selenium-grid-eventbus.conf /etc/supervisor/conf.d/ diff --git a/EventBus/generate.sh b/EventBus/generate.sh new file mode 100755 index 0000000000..fdbf1a7b23 --- /dev/null +++ b/EventBus/generate.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +VERSION=$1 +NAMESPACE=$2 +AUTHORS=$3 + +echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" > ./Dockerfile +echo "# NOTE: DO *NOT* EDIT THIS FILE. IT IS GENERATED." >> ./Dockerfile +echo "# PLEASE UPDATE Dockerfile.txt INSTEAD OF THIS FILE" >> ./Dockerfile +echo "# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" >> ./Dockerfile +echo FROM ${NAMESPACE}/base:${VERSION} >> ./Dockerfile +echo LABEL authors="$AUTHORS" >> ./Dockerfile +echo "" >> ./Dockerfile +cat ./Dockerfile.txt >> ./Dockerfile diff --git a/EventBus/selenium-grid-eventbus.conf b/EventBus/selenium-grid-eventbus.conf new file mode 100644 index 0000000000..3e12c746f8 --- /dev/null +++ b/EventBus/selenium-grid-eventbus.conf @@ -0,0 +1,15 @@ +; Documentation of this file format -> http://supervisord.org/configuration.html + +[program:selenium-grid-eventbus] + +priority=0 +command=/opt/bin/start-selenium-grid-eventbus.sh +autostart=true +autorestart=false +startsecs=0 +startretries=0 + +;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs" +redirect_stderr=true +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 diff --git a/EventBus/start-selenium-grid-eventbus.sh b/EventBus/start-selenium-grid-eventbus.sh new file mode 100755 index 0000000000..847948c255 --- /dev/null +++ b/EventBus/start-selenium-grid-eventbus.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +# set -e: exit asap if a command exits with a non-zero status +set -e + +echo "Starting Selenium Grid EventBus..." + +java -jar /opt/selenium/selenium-server.jar event-bus ${SE_OPTS} diff --git a/Hub/Dockerfile b/Hub/Dockerfile index 0839501ab9..353a48d104 100644 --- a/Hub/Dockerfile +++ b/Hub/Dockerfile @@ -8,7 +8,7 @@ LABEL authors=SeleniumHQ USER 1200 #======================== -# Selenium Configuration +# Selenium Hub Configuration #======================== EXPOSE 4442 diff --git a/Hub/Dockerfile.txt b/Hub/Dockerfile.txt index a4a39ac516..82b00684b4 100644 --- a/Hub/Dockerfile.txt +++ b/Hub/Dockerfile.txt @@ -1,7 +1,7 @@ USER 1200 #======================== -# Selenium Configuration +# Selenium Hub Configuration #======================== EXPOSE 4442 diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index 7dd2cfd530..964958431f 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -5,4 +5,8 @@ set -e echo "Starting Selenium Grid Hub..." -java -jar /opt/selenium/selenium-server.jar hub +if [ ! -z "$SE_OPTS" ]; then + echo "Appending Selenium options: ${SE_OPTS}" +fi + +java -jar /opt/selenium/selenium-server.jar hub ${SE_OPTS} diff --git a/Makefile b/Makefile index b7a4d74837..de5d70a0ef 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,14 @@ MAJOR := $(word 1,$(subst ., ,$(TAG_VERSION))) MINOR := $(word 2,$(subst ., ,$(TAG_VERSION))) MAJOR_MINOR_PATCH := $(word 1,$(subst -, ,$(TAG_VERSION))) -all: hub distributor router sessions chrome firefox opera standalone_chrome standalone_firefox standalone_opera +all: hub distributor router sessions event_bus chrome firefox opera standalone_chrome standalone_firefox standalone_opera generate_all: \ generate_hub \ generate_distributor \ generate_router \ generate_sessions \ + generate_event_bus \ generate_node_base \ generate_chrome \ generate_firefox \ @@ -57,6 +58,12 @@ generate_sessions: sessions: base generate_sessions cd ./Sessions && docker build $(BUILD_ARGS) -t $(NAME)/sessions:$(TAG_VERSION) . +generate_event_bus: + cd ./EventBus && ./generate.sh $(TAG_VERSION) $(NAMESPACE) $(AUTHORS) + +event_bus: base generate_event_bus + cd ./EventBus && docker build $(BUILD_ARGS) -t $(NAME)/event-bus:$(TAG_VERSION) . + generate_node_base: cd ./NodeBase && ./generate.sh $(TAG_VERSION) $(NAMESPACE) $(AUTHORS) @@ -119,6 +126,7 @@ tag_latest: docker tag $(NAME)/distributor:$(TAG_VERSION) $(NAME)/distributor:latest docker tag $(NAME)/router:$(TAG_VERSION) $(NAME)/router:latest docker tag $(NAME)/sessions:$(TAG_VERSION) $(NAME)/sessions:latest + docker tag $(NAME)/event-bus:$(TAG_VERSION) $(NAME)/event-bus:latest docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:latest docker tag $(NAME)/node-chrome:$(TAG_VERSION) $(NAME)/node-chrome:latest docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:latest @@ -133,6 +141,7 @@ release_latest: docker push $(NAME)/distributor:latest docker push $(NAME)/router:latest docker push $(NAME)/sessions:latest + docker push $(NAME)/event-bus:latest docker push $(NAME)/node-base:latest docker push $(NAME)/node-chrome:latest docker push $(NAME)/node-firefox:latest @@ -147,6 +156,7 @@ tag_major_minor: docker tag $(NAME)/distributor:$(TAG_VERSION) $(NAME)/distributor:$(MAJOR) docker tag $(NAME)/router:$(TAG_VERSION) $(NAME)/router:$(MAJOR) docker tag $(NAME)/sessions:$(TAG_VERSION) $(NAME)/sessions:$(MAJOR) + docker tag $(NAME)/event-bus:$(TAG_VERSION) $(NAME)/event-bus:$(MAJOR) docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:$(MAJOR) docker tag $(NAME)/node-chrome:$(TAG_VERSION) $(NAME)/node-chrome:$(MAJOR) docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:$(MAJOR) @@ -159,6 +169,7 @@ tag_major_minor: docker tag $(NAME)/distributor:$(TAG_VERSION) $(NAME)/distributor:$(MAJOR).$(MINOR) docker tag $(NAME)/router:$(TAG_VERSION) $(NAME)/router:$(MAJOR).$(MINOR) docker tag $(NAME)/sessions:$(TAG_VERSION) $(NAME)/sessions:$(MAJOR).$(MINOR) + docker tag $(NAME)/event-bus:$(TAG_VERSION) $(NAME)/event-bus:$(MAJOR).$(MINOR) docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:$(MAJOR).$(MINOR) docker tag $(NAME)/node-chrome:$(TAG_VERSION) $(NAME)/node-chrome:$(MAJOR).$(MINOR) docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:$(MAJOR).$(MINOR) @@ -171,6 +182,7 @@ tag_major_minor: docker tag $(NAME)/distributor:$(TAG_VERSION) $(NAME)/distributor:$(MAJOR_MINOR_PATCH) docker tag $(NAME)/router:$(TAG_VERSION) $(NAME)/router:$(MAJOR_MINOR_PATCH) docker tag $(NAME)/sessions:$(TAG_VERSION) $(NAME)/sessions:$(MAJOR_MINOR_PATCH) + docker tag $(NAME)/event-bus:$(TAG_VERSION) $(NAME)/event-bus:$(MAJOR_MINOR_PATCH) docker tag $(NAME)/node-base:$(TAG_VERSION) $(NAME)/node-base:$(MAJOR_MINOR_PATCH) docker tag $(NAME)/node-chrome:$(TAG_VERSION) $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH) docker tag $(NAME)/node-firefox:$(TAG_VERSION) $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH) @@ -185,6 +197,7 @@ release: tag_major_minor @if ! docker images $(NAME)/distributor | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/distributor version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @if ! docker images $(NAME)/router | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/router version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @if ! docker images $(NAME)/sessions | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/sessions version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi + @if ! docker images $(NAME)/event-bus | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/event-bus version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @if ! docker images $(NAME)/node-base | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/node-base version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @if ! docker images $(NAME)/node-chrome | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/node-chrome version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @if ! docker images $(NAME)/node-firefox | awk '{ print $$2 }' | grep -q -F $(TAG_VERSION); then echo "$(NAME)/node-firefox version $(TAG_VERSION) is not yet built. Please run 'make build'"; false; fi @@ -197,6 +210,7 @@ release: tag_major_minor docker push $(NAME)/distributor:$(TAG_VERSION) docker push $(NAME)/router:$(TAG_VERSION) docker push $(NAME)/sessions:$(TAG_VERSION) + docker push $(NAME)/event-bus:$(TAG_VERSION) docker push $(NAME)/node-base:$(TAG_VERSION) docker push $(NAME)/node-chrome:$(TAG_VERSION) docker push $(NAME)/node-firefox:$(TAG_VERSION) @@ -209,6 +223,7 @@ release: tag_major_minor docker push $(NAME)/distributor:$(MAJOR) docker push $(NAME)/router:$(MAJOR) docker push $(NAME)/sessions:$(MAJOR) + docker push $(NAME)/event-bus:$(MAJOR) docker push $(NAME)/node-base:$(MAJOR) docker push $(NAME)/node-chrome:$(MAJOR) docker push $(NAME)/node-firefox:$(MAJOR) @@ -221,6 +236,7 @@ release: tag_major_minor docker push $(NAME)/distributor:$(MAJOR).$(MINOR) docker push $(NAME)/router:$(MAJOR).$(MINOR) docker push $(NAME)/sessions:$(MAJOR).$(MINOR) + docker push $(NAME)/event-bus:$(MAJOR).$(MINOR) docker push $(NAME)/node-base:$(MAJOR).$(MINOR) docker push $(NAME)/node-chrome:$(MAJOR).$(MINOR) docker push $(NAME)/node-firefox:$(MAJOR).$(MINOR) @@ -233,6 +249,7 @@ release: tag_major_minor docker push $(NAME)/distributor:$(MAJOR_MINOR_PATCH) docker push $(NAME)/router:$(MAJOR_MINOR_PATCH) docker push $(NAME)/sessions:$(MAJOR_MINOR_PATCH) + docker push $(NAME)/event-bus:$(MAJOR_MINOR_PATCH) docker push $(NAME)/node-base:$(MAJOR_MINOR_PATCH) docker push $(NAME)/node-chrome:$(MAJOR_MINOR_PATCH) docker push $(NAME)/node-firefox:$(MAJOR_MINOR_PATCH) @@ -280,6 +297,7 @@ test_opera_standalone: generate_distributor \ generate_router \ generate_sessions \ + generate_event_bus \ generate_node_base \ generate_chrome \ generate_firefox \ @@ -291,6 +309,7 @@ test_opera_standalone: distributor \ router \ sessions \ + event_bus \ node_base \ release \ standalone_chrome \ diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 040535af40..958d281f0f 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -14,5 +14,22 @@ pacmd set-default-source v1.monitor rm -f /tmp/.X*lock -java -jar /opt/selenium/selenium-server.jar node --publish-events tcp://"$HUB_HOST":4442 \ - --subscribe-events tcp://"$HUB_HOST":4443 +if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then + echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_PUBLISH_PORT}" ]]; then + echo "SE_EVENT_BUS_PUBLISH_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then + echo "SE_EVENT_BUS_SUBSCRIBE_PORT not set, exiting!" 1>&2 + exit 1 +fi + +java -jar /opt/selenium/selenium-server.jar node \ + --publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \ + --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \ + ${SE_OPTS} diff --git a/README.md b/README.md index c1604ac473..0f6a4e6784 100644 --- a/README.md +++ b/README.md @@ -1,255 +1,142 @@ -# Selenium Docker +# Docker images for the Selenium Grid Server -The project is made possible by volunteer contributors who have put in thousands of hours of their own time, and made the source code freely available under the [Apache License 2.0](LICENSE.md). +The project is made possible by volunteer contributors who have put in thousands of hours of their own time, +and made the source code freely available under the [Apache License 2.0](LICENSE.md). -## Community +![Build & test](https://github.com/SeleniumHQ/docker-selenium/workflows/Build%20&%20test/badge.svg?branch=trunk) +![Deployments](https://github.com/SeleniumHQ/docker-selenium/workflows/Deploys/badge.svg) -### [SeleniumHQ Slack](https://seleniumhq.herokuapp.com/) +## Community -### IRC (#selenium at Freenode) +Do you need help using these Docker images? +Here are all the contact points for the different Selenium projects: +https://www.selenium.dev/support/ -## Docker images for Selenium Grid with Chrome, Firefox and Opera -![Build & test](https://github.com/SeleniumHQ/docker-selenium/workflows/Build%20&%20test/badge.svg?branch=trunk) +## Quick start -Images included: -- __selenium/base__: Base image which includes Java runtime and Selenium Server JAR file -- __selenium/hub__: Image for running a Grid Hub -- __selenium/distributor__: Image for running a Grid Distributor -- __selenium/router__: Image for running a Grid Router -- __selenium/sessions__: Image for running a Grid Sessions -- __selenium/node-base__: Base image for Grid Nodes which includes a virtual desktop environment -- __selenium/node-chrome__: Grid Node with Chrome installed, needs to be connected to a Grid Hub -- __selenium/node-firefox__: Grid Node with Firefox installed, needs to be connected to a Grid Hub -- __selenium/node-opera__: Grid Node with Opera installed, needs to be connected to a Grid Hub -- __selenium/standalone-chrome__: Selenium Standalone with Chrome installed -- __selenium/standalone-firefox__: Selenium Standalone with Firefox installed -- __selenium/standalone-opera__: Selenium Standalone with Opera installed - -## - -## Running the images -:exclamation: When executing `docker run` for an image that contains a browser please either mount `-v /dev/shm:/dev/shm` or use the -flag `--shm-size=2g` to use the host's shared memory. - -:exclamation: Always use a tag with an element suffix to pin a specific browser version. -See [Tagging Conventions](https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention) for details. +1. Start a Docker container with Firefox -Chrome ``` bash -$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-alpha-6-20200730 -# OR -$ docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome:4.0.0-alpha-6-20200730 -``` -Firefox -``` bash -$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-alpha-6-20200730 -# OR $ docker run -d -p 4444:4444 --shm-size 2g selenium/standalone-firefox:4.0.0-alpha-6-20200730 -``` -Opera -``` bash -$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-opera:4.0.0-alpha-6-20200730 # OR -$ docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-opera:4.0.0-alpha-6-20200730 +$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-alpha-6-20200730 ``` -This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for +2. Point your WebDriver tests to http://localhost:4444/wd/hub + +3. That's it! + +To inspect visually the browser activity, see the [Debugging](#debugging) section for details. + +:point_up: When executing `docker run` for an image that contains a browser please either mount + `-v /dev/shm:/dev/shm` or use the flag `--shm-size=2g` to use the host's shared memory. + +> Why is `-v /dev/shm:/dev/shm` or `--shm-size 2g` necessary? +> This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for [Chrome](https://code.google.com/p/chromium/issues/detail?id=519952) and [Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10). The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended to tune this value according to your needs. Along the examples `-v /dev/shm:/dev/shm` will be used, but both are known to work. +:point_up: Always use a tag with an element suffix to pin a specific browser version. +See [Tagging Conventions](https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention) for details. + +___ -### Standalone Chrome, Firefox and Opera +## Standalone +![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_24x24.png) Firefox ``` bash -$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-alpha-6-20200730 -# OR $ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:4.0.0-alpha-6-20200730 -# OR +``` + +![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_24x24.png) Chrome +``` bash +$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:4.0.0-alpha-6-20200730 +``` + +![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_24x24.png) Opera +``` bash $ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-opera:4.0.0-alpha-6-20200730 ``` -_Note: Only one Standalone container can run on port_ `4444` _at a time._ +_Note: Only one Standalone container can run on port_ `4444` _at the same time._ -To inspect visually what the browser is doing, see the [Debugging](#debugging) section for details. +___ -### Selenium Grid Hub and Nodes -There are different ways to run the images and create a grid, check the following options. +## Selenium Grid Hub and Nodes -#### Using docker networking -With this option, the hub and nodes will be created in the same network and they will recognize each other by their container name. -A docker [network](https://docs.docker.com/engine/reference/commandline/network_create/) needs to be created as a first step. +There are different ways to run the images and create a Grid with a Hub and Nodes, check the following options. + +### Docker networking +The Hub and Nodes will be created in the same network and they will recognize each other by their container name. +A Docker [network](https://docs.docker.com/engine/reference/commandline/network_create/) needs to be created as a first step. ``` bash $ docker network create grid -$ docker run -d -p 4444:4444 --net grid --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 -$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-alpha-6-20200730 -$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-firefox:4.0.0-alpha-6-20200730 -$ docker run -d --net grid -e HUB_HOST=selenium-hub -v /dev/shm:/dev/shm selenium/node-opera:4.0.0-alpha-6-20200730 +$ docker run -d -p 4442-4444:4442-4444 --net grid --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 +$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /dev/shm:/dev/shm selenium/node-chrome:4.0.0-alpha-6-20200730 +$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /dev/shm:/dev/shm selenium/node-firefox:4.0.0-alpha-6-20200730 +$ docker run -d --net grid -e SE_EVENT_BUS_HOST=selenium-hub -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /dev/shm:/dev/shm selenium/node-opera:4.0.0-alpha-6-20200730 ``` -When you are done using the grid and the containers have exited, the network can be removed with the following command: +When you are done using the Grid and the containers have exited, the network can be removed with the following command: ``` bash -# Remove all unused networks -$ docker network prune -# OR # Removes the grid network $ docker network rm grid ``` -#### Via docker-compose -The most simple way to start a grid is with [docker-compose](https://docs.docker.com/compose/overview/), use the following -snippet as your `docker-compose.yaml`, save it locally and in the same folder run `docker-compose up`. - -##### Version 2 -```yaml -# To execute this docker-compose yml file use `docker-compose -f up` -# Add the `-d` flag at the end for detached execution -version: '2' -services: - chrome: - image: selenium/node-chrome:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - HUB_HOST: selenium-hub - - firefox: - image: selenium/node-firefox:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - HUB_HOST: selenium-hub - - opera: - image: selenium/node-opera:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - HUB_HOST: selenium-hub - - selenium-hub: - image: selenium/hub:4.0.0-alpha-6-20200730 - ports: - - "4444:4444" -``` - -##### Version 3 -```yaml -# To execute this docker-compose yml file use `docker-compose -f up` -# Add the `-d` flag at the end for detached execution -version: "3" -services: - selenium-hub: - image: selenium/hub:4.0.0-alpha-6-20200730 - container_name: selenium-hub - ports: - - "4444:4444" - - chrome: - image: selenium/node-chrome:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - - HUB_HOST=selenium-hub - - firefox: - image: selenium/node-firefox:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - - HUB_HOST=selenium-hub - - opera: - image: selenium/node-opera:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - depends_on: - - selenium-hub - environment: - - HUB_HOST=selenium-hub -``` - -To stop the grid and cleanup the created containers, run `docker-compose down`. - -##### Version 3 with Swarm support (:exclamation: not tested yet) - -```yaml -# To start Docker in Swarm mode, you need to run `docker swarm init` -# To deploy the Grid, `docker stack deploy -c docker-compose.yml grid` -# Stop with `docker stack rm grid` - -version: '3.7' - -services: - selenium-hub: - image: selenium/hub:4.0.0-alpha-6-20200730 - ports: - - "4444:4444" - - chrome: - image: selenium/node-chrome:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - environment: - HUB_HOST: selenium-hub - deploy: - replicas: 1 - entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh' - - firefox: - image: selenium/node-firefox:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - environment: - HUB_HOST: selenium-hub - deploy: - replicas: 1 - entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh' - - opera: - image: selenium/node-opera:4.0.0-alpha-6-20200730 - volumes: - - /dev/shm:/dev/shm - environment: - HUB_HOST: selenium-hub - deploy: - replicas: 1 - entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh' -``` - -### Deploying to Kubernetes (:exclamation: not tested yet) +### Docker Compose +[Docker Compose](https://docs.docker.com/compose/) is the most simple way to start a Grid. Use the +linked resources below, save them locally, and check the execution instructions on top of each file. + +#### Version 2 +[`docker-compose-v2.yml`](docker-compose-v2.yml) + +#### Version 3 +[`docker-compose-v3.yml`](docker-compose-v3.yml) + +To stop the Grid and cleanup the created containers, run `docker-compose down`. + +#### Version 3 with Swarm support + +[`docker-compose-v3-swarm.yml`](docker-compose-v3-swarm.yml) + +___ + +## Selenium Grid - Router, Distributor, EventBus, SessionMap and Nodes + +It is possible to start a Selenium Grid with its five components apart. For simplicity, only an +example with docker-compose will be provided. Save the file locally, and check the execution +instructions on top of it. + +[`docker-compose-v3-full-grid.yml`](docker-compose-v3-full-grid.yml) + +___ + +## Deploying to Kubernetes (:warning: not tested yet with Selenium 4 images) Check out [the Kubernetes examples](https://github.com/kubernetes/examples/tree/master/staging/selenium) on how to deploy selenium hub and nodes on a Kubernetes cluster. +___ + ## Configuring the containers -### JAVA_OPTS Java Environment Options +### SE_OPTS Selenium Configuration Options -You can pass `JAVA_OPTS` environment variable to java process. +You can pass `SE_OPTS` variable with additional commandline parameters for starting a hub or a node. ``` bash -$ docker run -d -p 4444:4444 -e JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 +$ docker run -d -p 4444:4444 -e SE_OPTS="-debug" --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 ``` -### SE_OPTS Selenium Configuration Options +### JAVA_OPTS Java Environment Options -You can pass `SE_OPTS` variable with additional commandline parameters for starting a hub or a node. +You can pass `JAVA_OPTS` environment variable to java process. ``` bash -$ docker run -d -p 4444:4444 -e SE_OPTS="-debug" --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 +$ docker run -d -p 4444:4444 -e JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.0.0-alpha-6-20200730 ``` ### JAVA_CLASSPATH Java classpath diff --git a/Router/Dockerfile b/Router/Dockerfile index c3bff5b39b..820053e4c1 100644 --- a/Router/Dockerfile +++ b/Router/Dockerfile @@ -8,38 +8,12 @@ LABEL authors=SeleniumHQ USER 1200 #======================== -# Selenium Configuration +# Selenium Router Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 EXPOSE 4444 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-router.sh \ +COPY start-selenium-grid-router.sh \ /opt/bin/ COPY selenium-grid-router.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Router/Dockerfile.txt b/Router/Dockerfile.txt index a851ba307e..8eae595f09 100644 --- a/Router/Dockerfile.txt +++ b/Router/Dockerfile.txt @@ -1,38 +1,12 @@ USER 1200 #======================== -# Selenium Configuration +# Selenium Router Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 EXPOSE 4444 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-router.sh \ +COPY start-selenium-grid-router.sh \ /opt/bin/ COPY selenium-grid-router.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Router/generate_config b/Router/generate_config deleted file mode 100755 index c248c88372..0000000000 --- a/Router/generate_config +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cat <<_EOF -{ - "host": "${GRID_HUB_HOST}", - "port": ${GRID_HUB_PORT}, - "role": "hub", - "maxSession": ${GRID_MAX_SESSION}, - "newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT}, - "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", - "throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT}, - "jettyMaxThreads": ${GRID_JETTY_MAX_THREADS}, - "cleanUpCycle": ${GRID_CLEAN_UP_CYCLE}, - "browserTimeout": ${GRID_BROWSER_TIMEOUT}, - "timeout": ${GRID_TIMEOUT}, - "debug": ${GRID_DEBUG} -} -_EOF diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index 1203fa1e2c..2cde5d00aa 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -5,4 +5,31 @@ set -e echo "Starting Selenium Grid Router..." -java -jar /opt/selenium/selenium-server.jar router +if [[ -z "${SE_SESSIONS_MAP_HOST}" ]]; then + echo "SE_SESSIONS_MAP_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_SESSIONS_MAP_PORT}" ]]; then + echo "SE_SESSIONS_MAP_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_DISTRIBUTOR_HOST}" ]]; then + echo "DISTRIBUTOR_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_DISTRIBUTOR_PORT}" ]]; then + echo "DISTRIBUTOR_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [ ! -z "$SE_OPTS" ]; then + echo "Appending Selenium options: ${SE_OPTS}" +fi + +java -jar /opt/selenium/selenium-server.jar router \ + --sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port ${SE_SESSIONS_MAP_PORT} \ + --distributor-host "${SE_DISTRIBUTOR_HOST}" --distributor-port ${SE_DISTRIBUTOR_PORT} \ + ${SE_OPTS} diff --git a/Sessions/Dockerfile b/Sessions/Dockerfile index 653a3b854d..42975cf37a 100644 --- a/Sessions/Dockerfile +++ b/Sessions/Dockerfile @@ -8,38 +8,12 @@ LABEL authors=SeleniumHQ USER 1200 #======================== -# Selenium Configuration +# Selenium SessionMap Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 -EXPOSE 4444 +EXPOSE 5556 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-sessions.sh \ +COPY start-selenium-grid-sessions.sh \ /opt/bin/ COPY selenium-grid-sessions.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Sessions/Dockerfile.txt b/Sessions/Dockerfile.txt index c0ac3651da..866f9042d6 100644 --- a/Sessions/Dockerfile.txt +++ b/Sessions/Dockerfile.txt @@ -1,38 +1,12 @@ USER 1200 #======================== -# Selenium Configuration +# Selenium SessionMap Configuration #======================== -EXPOSE 4442 -EXPOSE 4443 -EXPOSE 4444 +EXPOSE 5556 -# As integer, maps to "maxSession" -ENV GRID_MAX_SESSION 5 -# In milliseconds, maps to "newSessionWaitTimeout" -ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1 -# As a boolean, maps to "throwOnCapabilityNotPresent" -ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true -# As an integer -ENV GRID_JETTY_MAX_THREADS -1 -# In milliseconds, maps to "cleanUpCycle" -ENV GRID_CLEAN_UP_CYCLE 5000 -# In seconds, maps to "browserTimeout" -ENV GRID_BROWSER_TIMEOUT 0 -# In seconds, maps to "timeout" -ENV GRID_TIMEOUT 1800 -# Debug -ENV GRID_DEBUG false -# As integer, maps to "port" -ENV GRID_HUB_PORT 4444 -# As string, maps to "host" -ENV GRID_HUB_HOST "0.0.0.0" - -COPY generate_config \ - start-selenium-grid-sessions.sh \ +COPY start-selenium-grid-sessions.sh \ /opt/bin/ COPY selenium-grid-sessions.conf /etc/supervisor/conf.d/ - -RUN /opt/bin/generate_config > /opt/selenium/config.json diff --git a/Sessions/generate_config b/Sessions/generate_config deleted file mode 100755 index c248c88372..0000000000 --- a/Sessions/generate_config +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -cat <<_EOF -{ - "host": "${GRID_HUB_HOST}", - "port": ${GRID_HUB_PORT}, - "role": "hub", - "maxSession": ${GRID_MAX_SESSION}, - "newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT}, - "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher", - "throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT}, - "jettyMaxThreads": ${GRID_JETTY_MAX_THREADS}, - "cleanUpCycle": ${GRID_CLEAN_UP_CYCLE}, - "browserTimeout": ${GRID_BROWSER_TIMEOUT}, - "timeout": ${GRID_TIMEOUT}, - "debug": ${GRID_DEBUG} -} -_EOF diff --git a/Sessions/start-selenium-grid-sessions.sh b/Sessions/start-selenium-grid-sessions.sh index 1bd2a580b0..546b732fc7 100755 --- a/Sessions/start-selenium-grid-sessions.sh +++ b/Sessions/start-selenium-grid-sessions.sh @@ -5,4 +5,26 @@ set -e echo "Starting Selenium Grid Sessions..." -java -jar /opt/selenium/selenium-server.jar sessions +if [[ -z "${SE_EVENT_BUS_HOST}" ]]; then + echo "SE_EVENT_BUS_HOST not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_PUBLISH_PORT}" ]]; then + echo "SE_EVENT_BUS_PUBLISH_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then + echo "SE_EVENT_BUS_SUBSCRIBE_PORT not set, exiting!" 1>&2 + exit 1 +fi + +if [ ! -z "$SE_OPTS" ]; then + echo "Appending Selenium options: ${SE_OPTS}" +fi + +java -jar /opt/selenium/selenium-server.jar sessions \ + --publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \ + --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \ + ${SE_OPTS} diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index 33df5ef025..cd5c22808c 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -2,4 +2,4 @@ # # IMPORTANT: Change this file only in directory Standalone! -java -jar /opt/selenium/selenium-server.jar standalone +java -jar /opt/selenium/selenium-server.jar standalone ${SE_OPTS} diff --git a/StandaloneOpera/selenium.conf b/StandaloneOpera/selenium.conf deleted file mode 100644 index 055e2155c7..0000000000 --- a/StandaloneOpera/selenium.conf +++ /dev/null @@ -1,73 +0,0 @@ -; Documentation of this file format -> http://supervisord.org/configuration.html - -; Priority 0 - xvfb, 5 - fluxbox, 10 - x11vnc, 15 - selenium-node - -[program:xvfb] -priority=0 -command=/opt/bin/start-xvfb.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/xvfb-stdout.log -stderr_logfile=/var/log/supervisor/xvfb-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:fluxbox] -priority=5 -command=/opt/bin/start-fluxbox.sh -autostart=true -autorestart=unexpected -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/fluxbox-stdout.log -stderr_logfile=/var/log/supervisor/fluxbox-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:vnc] -priority=10 -command=/opt/bin/start-vnc.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs -redirect_stderr=false -stdout_logfile=/var/log/supervisor/vnc-stdout.log -stderr_logfile=/var/log/supervisor/vnc-stderr.log -stdout_logfile_maxbytes=50MB -stderr_logfile_maxbytes=50MB -stdout_logfile_backups=5 -stderr_logfile_backups=5 -stdout_capture_maxbytes=50MB -stderr_capture_maxbytes=50MB - -[program:selenium-standalone] -priority=15 -command=/opt/bin/start-selenium-standalone.sh -autostart=true -autorestart=false -startsecs=0 -startretries=0 - -;Logs (all Hub activity redirected to stdout so it can be seen through "docker logs" -redirect_stderr=true -stdout_logfile=/dev/stdout -stdout_logfile_maxbytes=0 diff --git a/StandaloneOpera/start-selenium-standalone.sh b/StandaloneOpera/start-selenium-standalone.sh deleted file mode 100755 index 33df5ef025..0000000000 --- a/StandaloneOpera/start-selenium-standalone.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -# -# IMPORTANT: Change this file only in directory Standalone! - -java -jar /opt/selenium/selenium-server.jar standalone diff --git a/docker-compose-v2.yml b/docker-compose-v2.yml new file mode 100644 index 0000000000..bcb9b4ed1d --- /dev/null +++ b/docker-compose-v2.yml @@ -0,0 +1,44 @@ +# To execute this docker-compose yml file use `docker-compose -f docker-compose-v2.yml up` +# Add the `-d` flag at the end for detached execution +# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v2.yml down` +version: '2' +services: + chrome: + image: selenium/node-chrome:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + firefox: + image: selenium/node-firefox:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + opera: + image: selenium/node-opera:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + selenium-hub: + image: selenium/hub:4.0.0-alpha-6-20200730 + ports: + - "4442:4442" + - "4443:4443" + - "4444:4444" diff --git a/docker-compose-v3-full-grid.yml b/docker-compose-v3-full-grid.yml new file mode 100644 index 0000000000..4d559d8482 --- /dev/null +++ b/docker-compose-v3-full-grid.yml @@ -0,0 +1,86 @@ +# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3-full-grid.yml up` +# Add the `-d` flag at the end for detached execution +# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3-full-grid.yml down` +version: "3" +services: + selenium-event-bus: + image: selenium/event-bus:4.0.0-alpha-6-20200730 + container_name: selenium-event-bus + ports: + - "4442:4442" + - "4443:4443" + - "5557:5557" + + selenium-sessions: + image: selenium/sessions:4.0.0-alpha-6-20200730 + container_name: selenium-sessions + ports: + - "5556:5556" + depends_on: + - selenium-event-bus + environment: + - SE_EVENT_BUS_HOST=selenium-event-bus + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + selenium-distributor: + image: selenium/distributor:4.0.0-alpha-6-20200730 + container_name: selenium-distributor + ports: + - "5553:5553" + depends_on: + - selenium-event-bus + - selenium-sessions + environment: + - SE_EVENT_BUS_HOST=selenium-event-bus + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + - SE_SESSIONS_MAP_HOST=selenium-sessions + - SE_SESSIONS_MAP_PORT=5556 + + selenium-router: + image: selenium/router:4.0.0-alpha-6-20200730 + container_name: selenium-router + ports: + - "4444:4444" + depends_on: + - selenium-distributor + - selenium-sessions + environment: + - SE_DISTRIBUTOR_HOST=selenium-distributor + - SE_DISTRIBUTOR_PORT=5553 + - SE_SESSIONS_MAP_HOST=selenium-sessions + - SE_SESSIONS_MAP_PORT=5556 + + chrome: + image: selenium/node-chrome:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-event-bus + environment: + - SE_EVENT_BUS_HOST=selenium-event-bus + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + firefox: + image: selenium/node-firefox:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-event-bus + environment: + - SE_EVENT_BUS_HOST=selenium-event-bus + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + opera: + image: selenium/node-opera:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-event-bus + environment: + - SE_EVENT_BUS_HOST=selenium-event-bus + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 diff --git a/docker-compose-v3-swarm.yml b/docker-compose-v3-swarm.yml new file mode 100644 index 0000000000..577d07cc6a --- /dev/null +++ b/docker-compose-v3-swarm.yml @@ -0,0 +1,50 @@ +# To start Docker in Swarm mode, you need to run `docker swarm init` +# To deploy the Grid, `docker stack deploy -c docker-compose-v3-swarm.yml grid` +# Stop with `docker stack rm grid` +# Stop swarm mode `docker swarm leave --force` + +version: '3.7' + +services: + chrome: + image: selenium/node-chrome:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + deploy: + replicas: 1 + entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh' + + firefox: + image: selenium/node-firefox:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + deploy: + replicas: 1 + entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh' + + opera: + image: selenium/node-opera:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + deploy: + replicas: 1 + entrypoint: bash -c 'SE_OPTS="--host $$HOSTNAME" /opt/bin/entry_point.sh' + + selenium-hub: + image: selenium/hub:4.0.0-alpha-6-20200730 + ports: + - "4442:4442" + - "4443:4443" + - "4444:4444" diff --git a/docker-compose-v3.yml b/docker-compose-v3.yml new file mode 100644 index 0000000000..dc033612e1 --- /dev/null +++ b/docker-compose-v3.yml @@ -0,0 +1,45 @@ +# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3.yml up` +# Add the `-d` flag at the end for detached execution +# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3.yml down` +version: "3" +services: + chrome: + image: selenium/node-chrome:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + firefox: + image: selenium/node-firefox:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + opera: + image: selenium/node-opera:4.0.0-alpha-6-20200730 + volumes: + - /dev/shm:/dev/shm + depends_on: + - selenium-hub + environment: + - SE_EVENT_BUS_HOST=selenium-hub + - SE_EVENT_BUS_PUBLISH_PORT=4442 + - SE_EVENT_BUS_SUBSCRIBE_PORT=4443 + + selenium-hub: + image: selenium/hub:4.0.0-alpha-6-20200730 + container_name: selenium-hub + ports: + - "4442:4442" + - "4443:4443" + - "4444:4444" diff --git a/tests/test.py b/tests/test.py index 3f18685796..220a87b29c 100644 --- a/tests/test.py +++ b/tests/test.py @@ -114,7 +114,9 @@ def launch_container(container, **kwargs): 'http_proxy': http_proxy, 'https_proxy': https_proxy, 'no_proxy': no_proxy, - 'HUB_HOST': 'selenium-hub' + 'SE_EVENT_BUS_HOST': 'selenium-hub', + 'SE_EVENT_BUS_PUBLISH_PORT': 4442, + 'SE_EVENT_BUS_SUBSCRIBE_PORT': 4443 } container_id = client.containers.run("%s/%s:%s" % (NAMESPACE, IMAGE_NAME_MAP[container], VERSION), detach=True,