From 31435ce1e5752376aee63dbef1b27cff88df478e Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 11:31:59 +0000 Subject: [PATCH 1/9] Adding SE_ env vars with fallbacks For Dynamic Grid --- NodeBase/Dockerfile.txt | 35 ++++++++++++++++++++++++----------- README.md | 14 +++++++------- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index 968eee474..11a04630e 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -153,21 +153,34 @@ COPY selenium_grid_logo.png /usr/share/images/fluxbox/ubuntu-light.png #============================ # Some configuration options +# SE_ prefixed variables are declared so they can be easily retrieved +# and passed to Dynamic Grid containers #============================ -ENV SCREEN_WIDTH 1360 -ENV SCREEN_HEIGHT 1020 -ENV SCREEN_DEPTH 24 -ENV SCREEN_DPI 96 -ENV DISPLAY :99.0 -ENV DISPLAY_NUM 99 -ENV START_XVFB true -ENV START_NO_VNC true +ENV SE_SCREEN_WIDTH 1360 +ENV SCREEN_WIDTH=${SE_SCREEN_WIDTH} +ENV SE_SCREEN_HEIGHT 1020 +ENV SCREEN_HEIGHT=${SE_SCREEN_HEIGHT} +ENV SE_SCREEN_DEPTH 24 +ENV SCREEN_DEPTH=${SE_SCREEN_DEPTH} +ENV SE_SCREEN_DPI 96 +ENV SCREEN_DPI=${SE_SCREEN_DPI} +ENV SE_DISPLAY :99.0 +ENV DISPLAY=${SE_DISPLAY} +ENV SE_DISPLAY_NUM 99 +ENV DISPLAY_NUM=${SE_DISPLAY_NUM} +ENV SE_START_XVFB true +ENV START_XVFB=${SE_START_XVFB} +ENV SE_START_NO_VNC true +ENV START_NO_VNC=${SE_START_NO_VNC} # Path to the Configfile -ENV CONFIG_FILE=/opt/selenium/config.toml -ENV GENERATE_CONFIG true +ENV SE_CONFIG_FILE=/opt/selenium/config.toml +ENV CONFIG_FILE=${SE_CONFIG_FILE} +ENV SE_GENERATE_CONFIG true +ENV GENERATE_CONFIG=${SE_GENERATE_CONFIG} # Drain the Node after N sessions. # A value higher than zero enables the feature -ENV DRAIN_AFTER_SESSION_COUNT 0 +ENV SE_DRAIN_AFTER_SESSION_COUNT 0 +ENV DRAIN_AFTER_SESSION_COUNT=${SE_DRAIN_AFTER_SESSION_COUNT} #======================== # Selenium Configuration diff --git a/README.md b/README.md index 2287a7ea4..c6658aa31 100644 --- a/README.md +++ b/README.md @@ -614,11 +614,11 @@ $ docker run -d -e SE_EVENT_BUS_HOST= -e SE_EVENT_B ### Setting Screen Resolution By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96. -These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI` +These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI` environmental variables when starting the container. ``` bash -docker run -d -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 -e SCREEN_DEPTH=24 -e SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 +docker run -d -e SE_SCREEN_WIDTH=1366 -e SE_SCREEN_HEIGHT=768 -e SE_SCREEN_DEPTH=24 -e SE_SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 ``` ### Grid Url and Session Timeout @@ -663,12 +663,12 @@ captured in the same video. [Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome), When using headless mode, there's no need for the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) server to be started. -To avoid starting the server you can set the `START_XVFB` environment variable to `false` +To avoid starting the server you can set the `SE_START_XVFB` environment variable to `false` (or any other value than `true`), for example: ``` bash $ 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 -e START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 + -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SE_START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 ``` For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567). @@ -677,11 +677,11 @@ For more information, see this GitHub [issue](https://github.com/SeleniumHQ/dock In some environments, like Docker Swarm or Kubernetes, it is useful to shut down the Node or Standalone container after N tests have been executed. For example, this can be used in Kubernetes to terminate the -pod and then scale a new one after N sessions. Set the environment variable `DRAIN_AFTER_SESSION_COUNT` to +pod and then scale a new one after N sessions. Set the environment variable `SE_DRAIN_AFTER_SESSION_COUNT` to a value higher than zero to enable this behaviour. ``` bash -$ docker run -e DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 +$ docker run -e SE_DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 ``` With the previous command, the Standalone container will shutdown after 5 sessions have been executed. @@ -970,7 +970,7 @@ or `Message: unknown error: Chrome failed to start: exited abnormally` -The reason _might_ be that you've set the `START_XVFB` environment variable to "false", but forgot to +The reason _might_ be that you've set the `SE_START_XVFB` environment variable to "false", but forgot to actually run Firefox, Chrome or Edge in headless mode. ### Mounting volumes to retrieve downloaded files From 09e5184619c556e64ac633c77a3a9c379395551c Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 11:55:52 +0000 Subject: [PATCH 2/9] Revert "Adding SE_ env vars with fallbacks" This reverts commit 31435ce1e5752376aee63dbef1b27cff88df478e. --- NodeBase/Dockerfile.txt | 35 +++++++++++------------------------ README.md | 14 +++++++------- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index 11a04630e..968eee474 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -153,34 +153,21 @@ COPY selenium_grid_logo.png /usr/share/images/fluxbox/ubuntu-light.png #============================ # Some configuration options -# SE_ prefixed variables are declared so they can be easily retrieved -# and passed to Dynamic Grid containers #============================ -ENV SE_SCREEN_WIDTH 1360 -ENV SCREEN_WIDTH=${SE_SCREEN_WIDTH} -ENV SE_SCREEN_HEIGHT 1020 -ENV SCREEN_HEIGHT=${SE_SCREEN_HEIGHT} -ENV SE_SCREEN_DEPTH 24 -ENV SCREEN_DEPTH=${SE_SCREEN_DEPTH} -ENV SE_SCREEN_DPI 96 -ENV SCREEN_DPI=${SE_SCREEN_DPI} -ENV SE_DISPLAY :99.0 -ENV DISPLAY=${SE_DISPLAY} -ENV SE_DISPLAY_NUM 99 -ENV DISPLAY_NUM=${SE_DISPLAY_NUM} -ENV SE_START_XVFB true -ENV START_XVFB=${SE_START_XVFB} -ENV SE_START_NO_VNC true -ENV START_NO_VNC=${SE_START_NO_VNC} +ENV SCREEN_WIDTH 1360 +ENV SCREEN_HEIGHT 1020 +ENV SCREEN_DEPTH 24 +ENV SCREEN_DPI 96 +ENV DISPLAY :99.0 +ENV DISPLAY_NUM 99 +ENV START_XVFB true +ENV START_NO_VNC true # Path to the Configfile -ENV SE_CONFIG_FILE=/opt/selenium/config.toml -ENV CONFIG_FILE=${SE_CONFIG_FILE} -ENV SE_GENERATE_CONFIG true -ENV GENERATE_CONFIG=${SE_GENERATE_CONFIG} +ENV CONFIG_FILE=/opt/selenium/config.toml +ENV GENERATE_CONFIG true # Drain the Node after N sessions. # A value higher than zero enables the feature -ENV SE_DRAIN_AFTER_SESSION_COUNT 0 -ENV DRAIN_AFTER_SESSION_COUNT=${SE_DRAIN_AFTER_SESSION_COUNT} +ENV DRAIN_AFTER_SESSION_COUNT 0 #======================== # Selenium Configuration diff --git a/README.md b/README.md index c6658aa31..2287a7ea4 100644 --- a/README.md +++ b/README.md @@ -614,11 +614,11 @@ $ docker run -d -e SE_EVENT_BUS_HOST= -e SE_EVENT_B ### Setting Screen Resolution By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96. -These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI` +These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI` environmental variables when starting the container. ``` bash -docker run -d -e SE_SCREEN_WIDTH=1366 -e SE_SCREEN_HEIGHT=768 -e SE_SCREEN_DEPTH=24 -e SE_SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 +docker run -d -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 -e SCREEN_DEPTH=24 -e SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 ``` ### Grid Url and Session Timeout @@ -663,12 +663,12 @@ captured in the same video. [Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome), When using headless mode, there's no need for the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) server to be started. -To avoid starting the server you can set the `SE_START_XVFB` environment variable to `false` +To avoid starting the server you can set the `START_XVFB` environment variable to `false` (or any other value than `true`), for example: ``` bash $ 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 -e SE_START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 + -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 ``` For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567). @@ -677,11 +677,11 @@ For more information, see this GitHub [issue](https://github.com/SeleniumHQ/dock In some environments, like Docker Swarm or Kubernetes, it is useful to shut down the Node or Standalone container after N tests have been executed. For example, this can be used in Kubernetes to terminate the -pod and then scale a new one after N sessions. Set the environment variable `SE_DRAIN_AFTER_SESSION_COUNT` to +pod and then scale a new one after N sessions. Set the environment variable `DRAIN_AFTER_SESSION_COUNT` to a value higher than zero to enable this behaviour. ``` bash -$ docker run -e SE_DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 +$ docker run -e DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 ``` With the previous command, the Standalone container will shutdown after 5 sessions have been executed. @@ -970,7 +970,7 @@ or `Message: unknown error: Chrome failed to start: exited abnormally` -The reason _might_ be that you've set the `SE_START_XVFB` environment variable to "false", but forgot to +The reason _might_ be that you've set the `START_XVFB` environment variable to "false", but forgot to actually run Firefox, Chrome or Edge in headless mode. ### Mounting volumes to retrieve downloaded files From 5eee302c2568779166241641f89ffd8af85bc703 Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 13:58:20 +0000 Subject: [PATCH 3/9] Moving env vars to have the SE_ prefix In preparation to support env vars in Dynamic Grid --- .../start-selenium-grid-distributor.sh | 2 +- EventBus/start-selenium-grid-eventbus.sh | 2 +- Hub/start-selenium-grid-hub.sh | 2 +- NodeBase/Dockerfile.txt | 22 ++++++++------ NodeBase/generate_config | 2 +- NodeBase/start-novnc.sh | 8 ++--- NodeBase/start-selenium-node.sh | 2 +- NodeBase/start-vnc.sh | 8 +++-- NodeBase/start-xvfb.sh | 11 +++++-- NodeDocker/start-selenium-grid-docker.sh | 2 +- README.md | 30 +++++++++---------- Router/start-selenium-grid-router.sh | 2 +- .../start-selenium-grid-session-queue.sh | 2 +- Sessions/start-selenium-grid-sessions.sh | 2 +- Standalone/generate_config | 2 +- Standalone/start-selenium-standalone.sh | 2 +- .../start-selenium-grid-docker.sh | 2 +- Video/Dockerfile | 3 ++ Video/video.sh | 5 ++-- charts/selenium-grid/values.yaml | 10 +++---- 20 files changed, 68 insertions(+), 53 deletions(-) diff --git a/Distributor/start-selenium-grid-distributor.sh b/Distributor/start-selenium-grid-distributor.sh index 275e2c217..9154339d7 100755 --- a/Distributor/start-selenium-grid-distributor.sh +++ b/Distributor/start-selenium-grid-distributor.sh @@ -55,7 +55,7 @@ if [ ! -z "$SE_DISTRIBUTOR_PORT" ]; then fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar distributor \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar distributor \ --sessions-host "${SE_SESSIONS_MAP_HOST}" --sessions-port "${SE_SESSIONS_MAP_PORT}" \ --sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \ --publish-events tcp://"${SE_EVENT_BUS_HOST}":"${SE_EVENT_BUS_PUBLISH_PORT}" \ diff --git a/EventBus/start-selenium-grid-eventbus.sh b/EventBus/start-selenium-grid-eventbus.sh index 14e7a1155..d2644d14a 100755 --- a/EventBus/start-selenium-grid-eventbus.sh +++ b/EventBus/start-selenium-grid-eventbus.sh @@ -19,7 +19,7 @@ if [ ! -z "$SE_OPTS" ]; then echo "Appending Selenium options: ${SE_OPTS}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar event-bus \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar event-bus \ --bind-host ${SE_BIND_HOST} \ ${HOST_CONFIG} \ ${PORT_CONFIG} \ diff --git a/Hub/start-selenium-grid-hub.sh b/Hub/start-selenium-grid-hub.sh index 5398085f4..3dcb30d96 100755 --- a/Hub/start-selenium-grid-hub.sh +++ b/Hub/start-selenium-grid-hub.sh @@ -18,7 +18,7 @@ if [ ! -z "$SE_HUB_PORT" ]; then fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub \ --session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \ --session-retry-interval ${SE_SESSION_RETRY_INTERVAL} \ --relax-checks ${SE_RELAX_CHECKS} \ diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index 968eee474..c8d95bef2 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -154,20 +154,24 @@ COPY selenium_grid_logo.png /usr/share/images/fluxbox/ubuntu-light.png #============================ # Some configuration options #============================ -ENV SCREEN_WIDTH 1360 -ENV SCREEN_HEIGHT 1020 -ENV SCREEN_DEPTH 24 -ENV SCREEN_DPI 96 -ENV DISPLAY :99.0 -ENV DISPLAY_NUM 99 -ENV START_XVFB true -ENV START_NO_VNC true +ENV SE_SCREEN_WIDTH 1360 +ENV SE_SCREEN_HEIGHT 1020 +ENV SE_SCREEN_DEPTH 24 +ENV SE_SCREEN_DPI 96 +ENV SE_DISPLAY :99.0 +ENV SE_DISPLAY_NUM 99 +ENV SE_START_XVFB true +ENV SE_START_NO_VNC true +ENV SE_NO_VNC_PORT 7900 +ENV SE_VNC_PORT 5900 # Path to the Configfile ENV CONFIG_FILE=/opt/selenium/config.toml ENV GENERATE_CONFIG true # Drain the Node after N sessions. # A value higher than zero enables the feature -ENV DRAIN_AFTER_SESSION_COUNT 0 +ENV SE_DRAIN_AFTER_SESSION_COUNT 0 + + #======================== # Selenium Configuration diff --git a/NodeBase/generate_config b/NodeBase/generate_config index 6e70d6cc3..6e8d75b21 100755 --- a/NodeBase/generate_config +++ b/NodeBase/generate_config @@ -46,7 +46,7 @@ fi echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME" echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME" echo "detect-drivers = false" >> "$FILENAME" -echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME" +echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME" echo "max-sessions = ${SE_NODE_MAX_SESSIONS} " >> "$FILENAME" diff --git a/NodeBase/start-novnc.sh b/NodeBase/start-novnc.sh index 48148e1be..9b7984314 100755 --- a/NodeBase/start-novnc.sh +++ b/NodeBase/start-novnc.sh @@ -2,11 +2,11 @@ # # IMPORTANT: Change this file only in directory NodeBase! -if [ "${START_XVFB}" = true ] ; then - if [ "${START_NO_VNC}" = true ] ; then - /opt/bin/noVNC/utils/launch.sh --listen ${NO_VNC_PORT:-7900} --vnc localhost:${VNC_PORT:-5900} +if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then + if [ "${START_NO_VNC:-$SE_START_NO_VNC}" = true ] ; then + /opt/bin/noVNC/utils/launch.sh --listen ${NO_VNC_PORT:-$SE_NO_VNC_PORT} --vnc localhost:${VNC_PORT:-$SE_VNC_PORT} else - echo "noVNC won't start because START_NO_VNC is false." + echo "noVNC won't start because SE_START_NO_VNC is false." fi else echo "noVNC won't start because Xvfb is configured to not start." diff --git a/NodeBase/start-selenium-node.sh b/NodeBase/start-selenium-node.sh index 27672def5..befa3f62f 100755 --- a/NodeBase/start-selenium-node.sh +++ b/NodeBase/start-selenium-node.sh @@ -38,7 +38,7 @@ fi echo "Selenium Grid Node configuration: " cat "$CONFIG_FILE" echo "Starting Selenium Grid Node..." -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \ --bind-host ${SE_BIND_HOST} \ --config "$CONFIG_FILE" \ ${SE_OPTS} diff --git a/NodeBase/start-vnc.sh b/NodeBase/start-vnc.sh index 1f092ab69..21764c7bc 100755 --- a/NodeBase/start-vnc.sh +++ b/NodeBase/start-vnc.sh @@ -2,7 +2,7 @@ # # IMPORTANT: Change this file only in directory NodeBase! -if [ "${START_XVFB}" = true ] ; then +if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then # Centering wallpaper for i in $(seq 1 10) do @@ -14,6 +14,7 @@ if [ "${START_XVFB}" = true ] ; then fi done + VNC_NO_PASSWORD=${VNC_NO_PASSWORD:-$SE_VNC_NO_PASSWORD} if [ ! -z $VNC_NO_PASSWORD ]; then echo "Starting VNC server without password authentication" X11VNC_OPTS= @@ -21,6 +22,7 @@ if [ "${START_XVFB}" = true ] ; then X11VNC_OPTS=-usepw fi + VNC_VIEW_ONLY=${VNC_VIEW_ONLY:-$SE_VNC_VIEW_ONLY} if [ ! -z $VNC_VIEW_ONLY ]; then echo "Starting VNC server with viewonly option" X11VNC_OPTS="${X11VNC_OPTS} -viewonly" @@ -29,14 +31,14 @@ if [ "${START_XVFB}" = true ] ; then for i in $(seq 1 10) do sleep 1 - xdpyinfo -display ${DISPLAY} >/dev/null 2>&1 + xdpyinfo -display ${DISPLAY:-$SE_DISPLAY} >/dev/null 2>&1 if [ $? -eq 0 ]; then break fi echo "Waiting for Xvfb..." done - x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-5900} -rfbportv6 ${VNC_PORT:-5900} -display ${DISPLAY} + x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-$SE_VNC_PORT} -rfbportv6 ${VNC_PORT:-$SE_VNC_PORT} -display ${DISPLAY:-$SE_DISPLAY} else echo "Vnc won't start because Xvfb is configured to not start." fi diff --git a/NodeBase/start-xvfb.sh b/NodeBase/start-xvfb.sh index 669547669..cfbf6baf9 100755 --- a/NodeBase/start-xvfb.sh +++ b/NodeBase/start-xvfb.sh @@ -1,6 +1,11 @@ #!/usr/bin/env bash -if [ "${START_XVFB}" = true ] ; then +SCREEN_WIDTH=${SCREEN_WIDTH:-$SE_SCREEN_WIDTH} +SCREEN_HEIGHT=${SCREEN_HEIGHT:-$SE_SCREEN_HEIGHT} +SCREEN_DEPTH=${SCREEN_HEIGHT:-$SE_SCREEN_DEPTH} +SCREEN_DPI=${SCREEN_DPI:-$SE_SCREEN_DPI} + +if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then export GEOMETRY="${SCREEN_WIDTH}""x""${SCREEN_HEIGHT}""x""${SCREEN_DEPTH}" rm -f /tmp/.X*lock @@ -9,10 +14,10 @@ if [ "${START_XVFB}" = true ] ; then # http://manpages.ubuntu.com/manpages/focal/man1/xvfb-run.1.html # http://manpages.ubuntu.com/manpages/focal/man1/Xvfb.1.html # http://manpages.ubuntu.com/manpages/focal/man1/Xserver.1.html - /usr/bin/xvfb-run --server-num=${DISPLAY_NUM} \ + /usr/bin/xvfb-run --server-num=${DISPLAY_NUM:-$SE_DISPLAY_NUM} \ --listen-tcp \ --server-args="-screen 0 ${GEOMETRY} -fbdir /var/tmp -dpi ${SCREEN_DPI} -listen tcp -noreset -ac +extension RANDR" \ - /usr/bin/fluxbox -display ${DISPLAY} + /usr/bin/fluxbox -display ${DISPLAY:-$SE_DISPLAY} else echo "Xvfb and Fluxbox won't start. Chrome/Firefox/Node can only run in headless mode. Remember to set the 'headless' flag in your test." fi diff --git a/NodeDocker/start-selenium-grid-docker.sh b/NodeDocker/start-selenium-grid-docker.sh index f405df4d5..90be8a5ed 100755 --- a/NodeDocker/start-selenium-grid-docker.sh +++ b/NodeDocker/start-selenium-grid-docker.sh @@ -29,7 +29,7 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -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} \ --bind-host ${SE_BIND_HOST} \ diff --git a/README.md b/README.md index 2287a7ea4..c3f7171d5 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Talk to us at https://www.selenium.dev/support/ * [Kubernetes](#deploying-to-kubernetes) * [Configuring the containers](#configuring-the-containers) + [SE_OPTS Selenium Configuration Options](#se_opts-selenium-configuration-options) - + [JAVA_OPTS Java Environment Options](#java_opts-java-environment-options) + + [SE_JAVA_OPTS Java Environment Options](#se_java_opts-java-environment-options) + [Node configuration options](#node-configuration-options) + [Setting Screen Resolution](#setting-screen-resolution) + [Grid Url and Session Timeout](#grid-url-and-session-timeout) @@ -586,12 +586,12 @@ You can pass `SE_OPTS` variable with additional commandline parameters for start $ docker run -d -p 4444:4444 -e SE_OPTS="--log-level FINE" --name selenium-hub selenium/hub:4.2.2-20220609 ``` -### JAVA_OPTS Java Environment Options +### SE_JAVA_OPTS Java Environment Options -You can pass `JAVA_OPTS` environment variable to java process. +You can pass `SE_JAVA_OPTS` environment variable to java process. ``` bash -$ docker run -d -p 4444:4444 -e JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.2.2-20220609 +$ docker run -d -p 4444:4444 -e SE_JAVA_OPTS=-Xmx512m --name selenium-hub selenium/hub:4.2.2-20220609 ``` ### Node configuration options @@ -614,11 +614,11 @@ $ docker run -d -e SE_EVENT_BUS_HOST= -e SE_EVENT_B ### Setting Screen Resolution By default, nodes start with a screen resolution of 1360 x 1020 with a color depth of 24 bits and a dpi of 96. -These settings can be adjusted by specifying `SCREEN_WIDTH`, `SCREEN_HEIGHT`, `SCREEN_DEPTH`, and/or `SCREEN_DPI` +These settings can be adjusted by specifying `SE_SCREEN_WIDTH`, `SE_SCREEN_HEIGHT`, `SE_SCREEN_DEPTH`, and/or `SE_SCREEN_DPI` environmental variables when starting the container. ``` bash -docker run -d -e SCREEN_WIDTH=1366 -e SCREEN_HEIGHT=768 -e SCREEN_DEPTH=24 -e SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 +docker run -d -e SE_SCREEN_WIDTH=1366 -e SE_SCREEN_HEIGHT=768 -e SE_SCREEN_DEPTH=24 -e SE_SCREEN_DPI=74 selenium/standalone-firefox:4.2.2-20220609 ``` ### Grid Url and Session Timeout @@ -663,12 +663,12 @@ captured in the same video. [Chrome](https://developers.google.com/web/updates/2017/04/headless-chrome), When using headless mode, there's no need for the [Xvfb](https://en.wikipedia.org/wiki/Xvfb) server to be started. -To avoid starting the server you can set the `START_XVFB` environment variable to `false` +To avoid starting the server you can set the `SE_START_XVFB` environment variable to `false` (or any other value than `true`), for example: ``` bash $ 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 -e START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 + -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -e SE_START_XVFB=false --shm-size="2g" selenium/node-chrome:4.2.2-20220609 ``` For more information, see this GitHub [issue](https://github.com/SeleniumHQ/docker-selenium/issues/567). @@ -677,11 +677,11 @@ For more information, see this GitHub [issue](https://github.com/SeleniumHQ/dock In some environments, like Docker Swarm or Kubernetes, it is useful to shut down the Node or Standalone container after N tests have been executed. For example, this can be used in Kubernetes to terminate the -pod and then scale a new one after N sessions. Set the environment variable `DRAIN_AFTER_SESSION_COUNT` to +pod and then scale a new one after N sessions. Set the environment variable `SE_DRAIN_AFTER_SESSION_COUNT` to a value higher than zero to enable this behaviour. ``` bash -$ docker run -e DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 +$ docker run -e SE_DRAIN_AFTER_SESSION_COUNT=5 --shm-size="2g" selenium/standalone-firefox:4.2.2-20220609 ``` With the previous command, the Standalone container will shutdown after 5 sessions have been executed. @@ -883,7 +883,7 @@ The VNC server is listening to port 5900, you can use a VNC client and connect t any free external port that you wish. The internal 5900 port remains the same because that is the configured port for the VNC server running inside the container. -You can override it with the `VNC_PORT` environment variable in case you want to use `--net=host`. +You can override it with the `SE_VNC_PORT` environment variable in case you want to use `--net=host`. Here is an example with the standalone images, the same concept applies to the node images. ``` bash @@ -910,9 +910,9 @@ the posted ones which reconfigures it: RUN x11vnc -storepasswd /home/seluser/.vnc/passwd ``` -If you want to run VNC without password authentication you can set the environment variable `VNC_NO_PASSWORD=1`. +If you want to run VNC without password authentication you can set the environment variable `SE_VNC_NO_PASSWORD=1`. -If you want to run VNC in view-only mode you can set the environment variable `VNC_VIEW_ONLY=1`. +If you want to run VNC in view-only mode you can set the environment variable `SE_VNC_VIEW_ONLY=1`. ### Using your browser (no VNC client is needed) @@ -921,7 +921,7 @@ their browser. This might come handy if you cannot install a VNC client on your noVNC, so you will need to connect to that port with your browser. Similarly to the previous section, feel free to map port 7900 to any free external port that you wish. -You can also override it with the `NO_VNC_PORT` environment variable in case you want to use `--net=host`. +You can also override it with the `SE_NO_VNC_PORT` environment variable in case you want to use `--net=host`. Here is an example with the standalone images, the same concept applies to the node images. ``` bash @@ -970,7 +970,7 @@ or `Message: unknown error: Chrome failed to start: exited abnormally` -The reason _might_ be that you've set the `START_XVFB` environment variable to "false", but forgot to +The reason _might_ be that you've set the `SE_START_XVFB` environment variable to "false", but forgot to actually run Firefox, Chrome or Edge in headless mode. ### Mounting volumes to retrieve downloaded files diff --git a/Router/start-selenium-grid-router.sh b/Router/start-selenium-grid-router.sh index dd1012f09..e089ba92a 100755 --- a/Router/start-selenium-grid-router.sh +++ b/Router/start-selenium-grid-router.sh @@ -49,7 +49,7 @@ if [ ! -z "$SE_ROUTER_PORT" ]; then PORT_CONFIG="--port ${SE_ROUTER_PORT}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar router \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -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}" \ --sessionqueue-host "${SE_SESSION_QUEUE_HOST}" --sessionqueue-port "${SE_SESSION_QUEUE_PORT}" \ diff --git a/SessionQueue/start-selenium-grid-session-queue.sh b/SessionQueue/start-selenium-grid-session-queue.sh index f868352cd..8c41ae4be 100755 --- a/SessionQueue/start-selenium-grid-session-queue.sh +++ b/SessionQueue/start-selenium-grid-session-queue.sh @@ -34,7 +34,7 @@ if [ ! -z "$SE_SESSION_QUEUE_PORT" ]; then PORT_CONFIG="--port ${SE_SESSION_QUEUE_PORT}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessionqueue \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessionqueue \ --publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \ --subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \ --session-request-timeout ${SE_SESSION_REQUEST_TIMEOUT} \ diff --git a/Sessions/start-selenium-grid-sessions.sh b/Sessions/start-selenium-grid-sessions.sh index b286b2605..3b17be930 100755 --- a/Sessions/start-selenium-grid-sessions.sh +++ b/Sessions/start-selenium-grid-sessions.sh @@ -34,7 +34,7 @@ if [ ! -z "$SE_SESSIONS_PORT" ]; then PORT_CONFIG="--port ${SE_SESSIONS_PORT}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar sessions \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -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} \ --bind-host ${SE_BIND_HOST} \ diff --git a/Standalone/generate_config b/Standalone/generate_config index b88f7695e..85169e32f 100755 --- a/Standalone/generate_config +++ b/Standalone/generate_config @@ -26,7 +26,7 @@ fi echo "session-timeout = \"${SE_NODE_SESSION_TIMEOUT}\"" >> "$FILENAME" echo "override-max-sessions = ${SE_NODE_OVERRIDE_MAX_SESSIONS}" >> "$FILENAME" echo "detect-drivers = false" >> "$FILENAME" -echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME" +echo "drain-after-session-count = ${DRAIN_AFTER_SESSION_COUNT:-$SE_DRAIN_AFTER_SESSION_COUNT}" >> "$FILENAME" echo "max-sessions = ${SE_NODE_MAX_SESSIONS} " >> "$FILENAME" diff --git a/Standalone/start-selenium-standalone.sh b/Standalone/start-selenium-standalone.sh index d60103490..ee4b09a7d 100755 --- a/Standalone/start-selenium-standalone.sh +++ b/Standalone/start-selenium-standalone.sh @@ -11,7 +11,7 @@ fi echo "Selenium Grid Standalone configuration: " cat /opt/selenium/config.toml echo "Starting Selenium Grid Standalone..." -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \ --bind-host ${SE_BIND_HOST} \ --config /opt/selenium/config.toml \ ${SE_OPTS} \ No newline at end of file diff --git a/StandaloneDocker/start-selenium-grid-docker.sh b/StandaloneDocker/start-selenium-grid-docker.sh index bf8167744..162e3b737 100755 --- a/StandaloneDocker/start-selenium-grid-docker.sh +++ b/StandaloneDocker/start-selenium-grid-docker.sh @@ -14,7 +14,7 @@ if [ ! -z "$SE_NODE_GRID_URL" ]; then SE_GRID_URL="--grid-url ${SE_NODE_GRID_URL}" fi -java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \ +java ${JAVA_OPTS:-$SE_JAVA_OPTS} -jar /opt/selenium/selenium-server.jar standalone \ --relax-checks ${SE_RELAX_CHECKS} \ --detect-drivers false \ --bind-host ${SE_BIND_HOST} \ diff --git a/Video/Dockerfile b/Video/Dockerfile index 2411f03e0..56c0f27f9 100644 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -32,4 +32,7 @@ RUN mkdir -p /var/run/supervisor /var/log/supervisor /videos ENTRYPOINT ["/opt/bin/entry_point.sh"] CMD ["/opt/bin/entry_point.sh"] +ENV SE_DISPLAY :99.0 +ENV SE_DISPLAY_NUM 99 + EXPOSE 9000 \ No newline at end of file diff --git a/Video/video.sh b/Video/video.sh index 1ab5c94c2..2cf31893a 100755 --- a/Video/video.sh +++ b/Video/video.sh @@ -2,7 +2,8 @@ VIDEO_SIZE=${VIDEO_SIZE:-"1360x1020"} DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-"selenium"} -DISPLAY=${DISPLAY:-"99"} +DISPLAY=${DISPLAY:-$SE_DISPLAY} +DISPLAY_NUM=${DISPLAY_NUM:-$SE_DISPLAY_NUM} FILE_NAME=${FILE_NAME:-"video.mp4"} FRAME_RATE=${FRAME_RATE:-"15"} CODEC=${CODEC:-"libx264"} @@ -23,5 +24,5 @@ until [ $return_code -eq 0 -o $attempts -eq $max_attempts ]; do done # exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal -exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY}.0 -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME" +exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME" diff --git a/charts/selenium-grid/values.yaml b/charts/selenium-grid/values.yaml index df0747e78..5ef65192a 100644 --- a/charts/selenium-grid/values.yaml +++ b/charts/selenium-grid/values.yaml @@ -173,7 +173,7 @@ components: # Custom environment variables for all components extraEnvironmentVariables: - # - name: JAVA_OPTS + # - name: SE_JAVA_OPTS # value: "-Xmx512m" # - name: # valueFrom: @@ -226,7 +226,7 @@ hub: successThreshold: 1 # Custom environment variables for selenium-hub extraEnvironmentVariables: - # - name: JAVA_OPTS + # - name: SE_JAVA_OPTS # value: "-Xmx512m" # - name: SECRET_VARIABLE # valueFrom: @@ -287,7 +287,7 @@ chromeNode: nodeSelector: {} # Custom environment variables for chrome nodes extraEnvironmentVariables: - # - name: JAVA_OPTS + # - name: SE_JAVA_OPTS # value: "-Xmx512m" # - name: # valueFrom: @@ -359,7 +359,7 @@ firefoxNode: cpu: "1" # Custom environment variables for firefox nodes extraEnvironmentVariables: - # - name: JAVA_OPTS + # - name: SE_JAVA_OPTS # value: "-Xmx512m" # - name: # valueFrom: @@ -430,7 +430,7 @@ edgeNode: cpu: "1" # Custom environment variables for edge nodes extraEnvironmentVariables: - # - name: JAVA_OPTS + # - name: SE_JAVA_OPTS # value: "-Xmx512m" # - name: # valueFrom: From 9e5dbdc187da99338a46a365cb8e1a5f989de4cb Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 14:18:39 +0000 Subject: [PATCH 4/9] Moving video env vars to have SE_ prefix --- README.md | 2 +- Video/Dockerfile | 7 +++++++ Video/video.sh | 12 ++++++------ docker-compose-v3-video.yml | 12 ++++++------ tests/docker-compose-v3-test-video.yml | 4 ++-- 5 files changed, 22 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index c3f7171d5..78bcedf70 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ all the information requested on the template. - Video recording tends to use considerable amounts of CPU. Normally you should estimate 1CPU per video container, and 1 CPU per browser container. - Videos are stored in the `/videos` directory inside the video container. Map a local directory to get the videos. -- If you are running more than one video container, be sure to overwrite the video file name through the `FILE_NAME` +- If you are running more than one video container, be sure to overwrite the video file name through the `SE_FILE_NAME` environment variable to avoid unexpected results. This example shows how to start the containers manually: diff --git a/Video/Dockerfile b/Video/Dockerfile index 56c0f27f9..0520fdade 100644 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -34,5 +34,12 @@ CMD ["/opt/bin/entry_point.sh"] ENV SE_DISPLAY :99.0 ENV SE_DISPLAY_NUM 99 +ENV SE_SCREEN_WIDTH 1360 +ENV SE_SCREEN_HEIGHT 1020 +ENV SE_DISPLAY_CONTAINER_NAME selenium +ENV SE_FILE_NAME video.mp4 +ENV SE_FRAME_RATE 15 +ENV SE_CODEC libx264 +ENV SE_PRESET "-preset ultrafast" EXPOSE 9000 \ No newline at end of file diff --git a/Video/video.sh b/Video/video.sh index 2cf31893a..5d9639811 100755 --- a/Video/video.sh +++ b/Video/video.sh @@ -1,13 +1,13 @@ #!/bin/sh -VIDEO_SIZE=${VIDEO_SIZE:-"1360x1020"} -DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-"selenium"} +VIDEO_SIZE="${SE_SCREEN_WIDTH}""x""${SE_SCREEN_HEIGHT}" +DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-$SE_DISPLAY_CONTAINER_NAME} DISPLAY=${DISPLAY:-$SE_DISPLAY} DISPLAY_NUM=${DISPLAY_NUM:-$SE_DISPLAY_NUM} -FILE_NAME=${FILE_NAME:-"video.mp4"} -FRAME_RATE=${FRAME_RATE:-"15"} -CODEC=${CODEC:-"libx264"} -PRESET=${PRESET:-"-preset ultrafast"} +FILE_NAME=${FILE_NAME:-$SE_FILE_NAME} +FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE} +CODEC=${CODEC:-$SE_CODEC} +PRESET=${PRESET:-$SE_PRESET} return_code=1 max_attempts=50 diff --git a/docker-compose-v3-video.yml b/docker-compose-v3-video.yml index 3023dc9dc..94a33939d 100644 --- a/docker-compose-v3-video.yml +++ b/docker-compose-v3-video.yml @@ -40,8 +40,8 @@ services: depends_on: - chrome environment: - - DISPLAY_CONTAINER_NAME=chrome - - FILE_NAME=chrome_video.mp4 + - SE_DISPLAY_CONTAINER_NAME=chrome + - SE_FILE_NAME=chrome_video.mp4 edge_video: image: selenium/video:ffmpeg-4.3.1-20220609 @@ -50,8 +50,8 @@ services: depends_on: - edge environment: - - DISPLAY_CONTAINER_NAME=edge - - FILE_NAME=edge_video.mp4 + - SE_DISPLAY_CONTAINER_NAME=edge + - SE_FILE_NAME=edge_video.mp4 firefox_video: image: selenium/video:ffmpeg-4.3.1-20220609 @@ -60,8 +60,8 @@ services: depends_on: - firefox environment: - - DISPLAY_CONTAINER_NAME=firefox - - FILE_NAME=firefox_video.mp4 + - SE_DISPLAY_CONTAINER_NAME=firefox + - SE_FILE_NAME=firefox_video.mp4 selenium-hub: image: selenium/hub:4.2.2-20220609 diff --git a/tests/docker-compose-v3-test-video.yml b/tests/docker-compose-v3-test-video.yml index dd8597749..33553c431 100644 --- a/tests/docker-compose-v3-test-video.yml +++ b/tests/docker-compose-v3-test-video.yml @@ -22,8 +22,8 @@ services: depends_on: - browser environment: - - DISPLAY_CONTAINER_NAME=browser - - FILE_NAME=${VIDEO_FILE_NAME} + - SE_DISPLAY_CONTAINER_NAME=browser + - SE_FILE_NAME=${VIDEO_FILE_NAME} selenium-hub: image: selenium/hub:${TAG:-test-video} From ab6cdd6cc9aa8d2a87ddbc94be2b89ef49d5e902 Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 14:47:17 +0000 Subject: [PATCH 5/9] Fixing copy&paste error --- NodeBase/start-xvfb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NodeBase/start-xvfb.sh b/NodeBase/start-xvfb.sh index cfbf6baf9..25a350901 100755 --- a/NodeBase/start-xvfb.sh +++ b/NodeBase/start-xvfb.sh @@ -2,7 +2,7 @@ SCREEN_WIDTH=${SCREEN_WIDTH:-$SE_SCREEN_WIDTH} SCREEN_HEIGHT=${SCREEN_HEIGHT:-$SE_SCREEN_HEIGHT} -SCREEN_DEPTH=${SCREEN_HEIGHT:-$SE_SCREEN_DEPTH} +SCREEN_DEPTH=${SCREEN_DEPTH:-$SE_SCREEN_DEPTH} SCREEN_DPI=${SCREEN_DPI:-$SE_SCREEN_DPI} if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then From 642dc3cee1fa8d815756dc7412a283642a1946d6 Mon Sep 17 00:00:00 2001 From: diemol Date: Wed, 15 Jun 2022 15:12:28 +0000 Subject: [PATCH 6/9] Fixing video env vars --- Video/Dockerfile | 1 - Video/video.sh | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Video/Dockerfile b/Video/Dockerfile index 0520fdade..2a5b948ea 100644 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -32,7 +32,6 @@ RUN mkdir -p /var/run/supervisor /var/log/supervisor /videos ENTRYPOINT ["/opt/bin/entry_point.sh"] CMD ["/opt/bin/entry_point.sh"] -ENV SE_DISPLAY :99.0 ENV SE_DISPLAY_NUM 99 ENV SE_SCREEN_WIDTH 1360 ENV SE_SCREEN_HEIGHT 1020 diff --git a/Video/video.sh b/Video/video.sh index 5d9639811..25871bdb1 100755 --- a/Video/video.sh +++ b/Video/video.sh @@ -2,7 +2,6 @@ VIDEO_SIZE="${SE_SCREEN_WIDTH}""x""${SE_SCREEN_HEIGHT}" DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-$SE_DISPLAY_CONTAINER_NAME} -DISPLAY=${DISPLAY:-$SE_DISPLAY} DISPLAY_NUM=${DISPLAY_NUM:-$SE_DISPLAY_NUM} FILE_NAME=${FILE_NAME:-$SE_FILE_NAME} FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE} @@ -14,7 +13,7 @@ max_attempts=50 attempts=0 echo 'Checking if the display is open...' until [ $return_code -eq 0 -o $attempts -eq $max_attempts ]; do - xset -display ${DISPLAY_CONTAINER_NAME}:${DISPLAY} b off > /dev/null 2>&1 + xset -display ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM} b off > /dev/null 2>&1 return_code=$? if [ $return_code -ne 0 ]; then echo 'Waiting before next display check...' @@ -24,5 +23,5 @@ until [ $return_code -eq 0 -o $attempts -eq $max_attempts ]; do done # exec replaces the video.sh process with ffmpeg, this makes easier to pass the process termination signal -exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM} -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME" +exec ffmpeg -y -f x11grab -video_size ${VIDEO_SIZE} -r ${FRAME_RATE} -i ${DISPLAY_CONTAINER_NAME}:${DISPLAY_NUM}.0 -codec:v ${CODEC} ${PRESET} -pix_fmt yuv420p "/videos/$FILE_NAME" From 94a23d321405c49928b02f58751c75734789cb4a Mon Sep 17 00:00:00 2001 From: diemol Date: Thu, 16 Jun 2022 05:20:47 +0000 Subject: [PATCH 7/9] No need to prefix DISPLAY env vars --- NodeBase/Dockerfile.txt | 4 ++-- NodeBase/start-vnc.sh | 4 ++-- NodeBase/start-xvfb.sh | 4 ++-- Video/Dockerfile | 4 ++-- Video/video.sh | 4 ++-- docker-compose-v3-video.yml | 6 +++--- tests/docker-compose-v3-test-video.yml | 2 +- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/NodeBase/Dockerfile.txt b/NodeBase/Dockerfile.txt index c8d95bef2..8f496a3ed 100644 --- a/NodeBase/Dockerfile.txt +++ b/NodeBase/Dockerfile.txt @@ -158,12 +158,12 @@ ENV SE_SCREEN_WIDTH 1360 ENV SE_SCREEN_HEIGHT 1020 ENV SE_SCREEN_DEPTH 24 ENV SE_SCREEN_DPI 96 -ENV SE_DISPLAY :99.0 -ENV SE_DISPLAY_NUM 99 ENV SE_START_XVFB true ENV SE_START_NO_VNC true ENV SE_NO_VNC_PORT 7900 ENV SE_VNC_PORT 5900 +ENV DISPLAY :99.0 +ENV DISPLAY_NUM 99 # Path to the Configfile ENV CONFIG_FILE=/opt/selenium/config.toml ENV GENERATE_CONFIG true diff --git a/NodeBase/start-vnc.sh b/NodeBase/start-vnc.sh index 21764c7bc..7eef6effd 100755 --- a/NodeBase/start-vnc.sh +++ b/NodeBase/start-vnc.sh @@ -31,14 +31,14 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then for i in $(seq 1 10) do sleep 1 - xdpyinfo -display ${DISPLAY:-$SE_DISPLAY} >/dev/null 2>&1 + xdpyinfo -display ${DISPLAY} >/dev/null 2>&1 if [ $? -eq 0 ]; then break fi echo "Waiting for Xvfb..." done - x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-$SE_VNC_PORT} -rfbportv6 ${VNC_PORT:-$SE_VNC_PORT} -display ${DISPLAY:-$SE_DISPLAY} + x11vnc ${X11VNC_OPTS} -forever -shared -rfbport ${VNC_PORT:-$SE_VNC_PORT} -rfbportv6 ${VNC_PORT:-$SE_VNC_PORT} -display ${DISPLAY} else echo "Vnc won't start because Xvfb is configured to not start." fi diff --git a/NodeBase/start-xvfb.sh b/NodeBase/start-xvfb.sh index 25a350901..5e7092a51 100755 --- a/NodeBase/start-xvfb.sh +++ b/NodeBase/start-xvfb.sh @@ -14,10 +14,10 @@ if [ "${START_XVFB:-$SE_START_XVFB}" = true ] ; then # http://manpages.ubuntu.com/manpages/focal/man1/xvfb-run.1.html # http://manpages.ubuntu.com/manpages/focal/man1/Xvfb.1.html # http://manpages.ubuntu.com/manpages/focal/man1/Xserver.1.html - /usr/bin/xvfb-run --server-num=${DISPLAY_NUM:-$SE_DISPLAY_NUM} \ + /usr/bin/xvfb-run --server-num=${DISPLAY_NUM} \ --listen-tcp \ --server-args="-screen 0 ${GEOMETRY} -fbdir /var/tmp -dpi ${SCREEN_DPI} -listen tcp -noreset -ac +extension RANDR" \ - /usr/bin/fluxbox -display ${DISPLAY:-$SE_DISPLAY} + /usr/bin/fluxbox -display ${DISPLAY} else echo "Xvfb and Fluxbox won't start. Chrome/Firefox/Node can only run in headless mode. Remember to set the 'headless' flag in your test." fi diff --git a/Video/Dockerfile b/Video/Dockerfile index 2a5b948ea..31ed03412 100644 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -32,10 +32,10 @@ RUN mkdir -p /var/run/supervisor /var/log/supervisor /videos ENTRYPOINT ["/opt/bin/entry_point.sh"] CMD ["/opt/bin/entry_point.sh"] -ENV SE_DISPLAY_NUM 99 +ENV DISPLAY_NUM 99 +ENV DISPLAY_CONTAINER_NAME selenium ENV SE_SCREEN_WIDTH 1360 ENV SE_SCREEN_HEIGHT 1020 -ENV SE_DISPLAY_CONTAINER_NAME selenium ENV SE_FILE_NAME video.mp4 ENV SE_FRAME_RATE 15 ENV SE_CODEC libx264 diff --git a/Video/video.sh b/Video/video.sh index 25871bdb1..69012a0b2 100755 --- a/Video/video.sh +++ b/Video/video.sh @@ -1,8 +1,8 @@ #!/bin/sh VIDEO_SIZE="${SE_SCREEN_WIDTH}""x""${SE_SCREEN_HEIGHT}" -DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME:-$SE_DISPLAY_CONTAINER_NAME} -DISPLAY_NUM=${DISPLAY_NUM:-$SE_DISPLAY_NUM} +DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME} +DISPLAY_NUM=${DISPLAY_NUM} FILE_NAME=${FILE_NAME:-$SE_FILE_NAME} FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE} CODEC=${CODEC:-$SE_CODEC} diff --git a/docker-compose-v3-video.yml b/docker-compose-v3-video.yml index 94a33939d..db87a2612 100644 --- a/docker-compose-v3-video.yml +++ b/docker-compose-v3-video.yml @@ -40,7 +40,7 @@ services: depends_on: - chrome environment: - - SE_DISPLAY_CONTAINER_NAME=chrome + - DISPLAY_CONTAINER_NAME=chrome - SE_FILE_NAME=chrome_video.mp4 edge_video: @@ -50,7 +50,7 @@ services: depends_on: - edge environment: - - SE_DISPLAY_CONTAINER_NAME=edge + - DISPLAY_CONTAINER_NAME=edge - SE_FILE_NAME=edge_video.mp4 firefox_video: @@ -60,7 +60,7 @@ services: depends_on: - firefox environment: - - SE_DISPLAY_CONTAINER_NAME=firefox + - DISPLAY_CONTAINER_NAME=firefox - SE_FILE_NAME=firefox_video.mp4 selenium-hub: diff --git a/tests/docker-compose-v3-test-video.yml b/tests/docker-compose-v3-test-video.yml index 33553c431..844cfeb01 100644 --- a/tests/docker-compose-v3-test-video.yml +++ b/tests/docker-compose-v3-test-video.yml @@ -22,7 +22,7 @@ services: depends_on: - browser environment: - - SE_DISPLAY_CONTAINER_NAME=browser + - DISPLAY_CONTAINER_NAME=browser - SE_FILE_NAME=${VIDEO_FILE_NAME} selenium-hub: From 333189e97592e9fc347bcc55b6d39974c5464489 Mon Sep 17 00:00:00 2001 From: diemol Date: Thu, 16 Jun 2022 08:01:28 +0000 Subject: [PATCH 8/9] Reverting SE for FILE_NAME in video --- README.md | 2 +- Video/Dockerfile | 2 +- Video/video.sh | 2 +- docker-compose-v3-video.yml | 6 +++--- tests/docker-compose-v3-test-video.yml | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 78bcedf70..c3f7171d5 100644 --- a/README.md +++ b/README.md @@ -347,7 +347,7 @@ all the information requested on the template. - Video recording tends to use considerable amounts of CPU. Normally you should estimate 1CPU per video container, and 1 CPU per browser container. - Videos are stored in the `/videos` directory inside the video container. Map a local directory to get the videos. -- If you are running more than one video container, be sure to overwrite the video file name through the `SE_FILE_NAME` +- If you are running more than one video container, be sure to overwrite the video file name through the `FILE_NAME` environment variable to avoid unexpected results. This example shows how to start the containers manually: diff --git a/Video/Dockerfile b/Video/Dockerfile index 31ed03412..e69bddcd0 100644 --- a/Video/Dockerfile +++ b/Video/Dockerfile @@ -36,9 +36,9 @@ ENV DISPLAY_NUM 99 ENV DISPLAY_CONTAINER_NAME selenium ENV SE_SCREEN_WIDTH 1360 ENV SE_SCREEN_HEIGHT 1020 -ENV SE_FILE_NAME video.mp4 ENV SE_FRAME_RATE 15 ENV SE_CODEC libx264 ENV SE_PRESET "-preset ultrafast" +ENV FILE_NAME video.mp4 EXPOSE 9000 \ No newline at end of file diff --git a/Video/video.sh b/Video/video.sh index 69012a0b2..d764b726c 100755 --- a/Video/video.sh +++ b/Video/video.sh @@ -3,7 +3,7 @@ VIDEO_SIZE="${SE_SCREEN_WIDTH}""x""${SE_SCREEN_HEIGHT}" DISPLAY_CONTAINER_NAME=${DISPLAY_CONTAINER_NAME} DISPLAY_NUM=${DISPLAY_NUM} -FILE_NAME=${FILE_NAME:-$SE_FILE_NAME} +FILE_NAME=${FILE_NAME} FRAME_RATE=${FRAME_RATE:-$SE_FRAME_RATE} CODEC=${CODEC:-$SE_CODEC} PRESET=${PRESET:-$SE_PRESET} diff --git a/docker-compose-v3-video.yml b/docker-compose-v3-video.yml index db87a2612..3023dc9dc 100644 --- a/docker-compose-v3-video.yml +++ b/docker-compose-v3-video.yml @@ -41,7 +41,7 @@ services: - chrome environment: - DISPLAY_CONTAINER_NAME=chrome - - SE_FILE_NAME=chrome_video.mp4 + - FILE_NAME=chrome_video.mp4 edge_video: image: selenium/video:ffmpeg-4.3.1-20220609 @@ -51,7 +51,7 @@ services: - edge environment: - DISPLAY_CONTAINER_NAME=edge - - SE_FILE_NAME=edge_video.mp4 + - FILE_NAME=edge_video.mp4 firefox_video: image: selenium/video:ffmpeg-4.3.1-20220609 @@ -61,7 +61,7 @@ services: - firefox environment: - DISPLAY_CONTAINER_NAME=firefox - - SE_FILE_NAME=firefox_video.mp4 + - FILE_NAME=firefox_video.mp4 selenium-hub: image: selenium/hub:4.2.2-20220609 diff --git a/tests/docker-compose-v3-test-video.yml b/tests/docker-compose-v3-test-video.yml index 844cfeb01..dd8597749 100644 --- a/tests/docker-compose-v3-test-video.yml +++ b/tests/docker-compose-v3-test-video.yml @@ -23,7 +23,7 @@ services: - browser environment: - DISPLAY_CONTAINER_NAME=browser - - SE_FILE_NAME=${VIDEO_FILE_NAME} + - FILE_NAME=${VIDEO_FILE_NAME} selenium-hub: image: selenium/hub:${TAG:-test-video} From fbd191c9ccde83557cf813bf8fe8214c7984a10b Mon Sep 17 00:00:00 2001 From: diemol Date: Thu, 16 Jun 2022 08:25:42 +0000 Subject: [PATCH 9/9] Updating README --- README.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/README.md b/README.md index c3f7171d5..0533ee92b 100644 --- a/README.md +++ b/README.md @@ -550,6 +550,38 @@ Here is an example using a Hub and a Node: [`docker-compose-v3-dynamic-grid.yml`](docker-compose-v3-dynamic-grid.yml) +### Configuring the child containers + +Containers can be further configured through environment variables, such as `SE_NODE_SESSION_TIMEOUT` +and `SE_OPTS`. When a child container is created, all environment variables prefixed with `SE_` will +be forwared and set in the container. You can set the desired environment variables in the +`standalone-docker` or `node-docker` containers. The following example sets the session timeout to +700 seconds for all sessions: + +#### macOS/Linux + +```bash +docker run --rm --name selenium-docker -p 4444:4444 \ + -e SE_NODE_SESSION_TIMEOUT=700 \ + -v ${PWD}/config.toml:/opt/bin/config.toml \ + -v ${PWD}/assets:/opt/selenium/assets \ + -v /var/run/docker.sock:/var/run/docker.sock \ + selenium/standalone-docker:4.2.2-20220609 +``` + +#### Windows PowerShell + +```bash +docker run --rm --name selenium-docker -p 4444:4444 ` + -e SE_NODE_SESSION_TIMEOUT=700 ` + -v ${PWD}/config.toml:/opt/bin/config.toml ` + -v ${PWD}/assets:/opt/selenium/assets ` + -v /var/run/docker.sock:/var/run/docker.sock ` + selenium/standalone-docker:4.2.2-20220609 +``` + + + ### Video recording, screen resolution, and time zones in a Dynamic Grid To record your WebDriver session, you need to add a `se:recordVideo` field set to `true`. You can also set a time zone and a screen resolution,