Skip to content

Commit b34a162

Browse files
authored
Reworking Env Vars (#1139)
* Using Alpha 7 jar * Mapping env vars for Hub * Mapping env vars for Nodes
1 parent c7924e7 commit b34a162

13 files changed

+91
-157
lines changed

Base/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ COPY supervisord.conf /etc
6969
# Selenium & relaxing permissions for OpenShift and other non-sudo environments
7070
#==========
7171
RUN mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor \
72-
&& touch /opt/selenium/config.json \
72+
&& touch /opt/selenium/config.toml \
7373
&& chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd \
74-
&& wget --no-verbose https://github.com/SeleniumHQ/docker-selenium/raw/alpha-jars/selenium-server-4.0.0-alpha-7-e23236a2c9.jar \
74+
&& wget --no-verbose https://github.com/SeleniumHQ/docker-selenium/raw/alpha-jars/selenium-server-4.0.0-alpha-7-4a3bb6d550.jar \
7575
-O /opt/selenium/selenium-server.jar \
7676
# && wget --no-verbose https://selenium-release.storage.googleapis.com/4.0-alpha-6/selenium-server-4.0.0-alpha-6.jar \
7777
# -O /opt/selenium/selenium-server.jar \

Hub/Dockerfile.txt

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,23 @@ EXPOSE 4442
88
EXPOSE 4443
99
EXPOSE 4444
1010

11-
# As integer, maps to "maxSession"
12-
ENV GRID_MAX_SESSION 5
13-
# In milliseconds, maps to "newSessionWaitTimeout"
14-
ENV GRID_NEW_SESSION_WAIT_TIMEOUT -1
15-
# As a boolean, maps to "throwOnCapabilityNotPresent"
16-
ENV GRID_THROW_ON_CAPABILITY_NOT_PRESENT true
17-
# As an integer
18-
ENV GRID_JETTY_MAX_THREADS -1
19-
# In milliseconds, maps to "cleanUpCycle"
20-
ENV GRID_CLEAN_UP_CYCLE 5000
21-
# In seconds, maps to "browserTimeout"
22-
ENV GRID_BROWSER_TIMEOUT 0
23-
# In seconds, maps to "timeout"
24-
ENV GRID_TIMEOUT 1800
25-
# Debug
26-
ENV GRID_DEBUG false
11+
# In seconds, maps to "--session-request-timeout"
12+
ENV SE_SESSION_REQUEST_TIMEOUT 300
13+
# In seconds, maps to "--session-retry-interval"
14+
ENV SE_SESSION_RETRY_INTERVAL 5
15+
# Boolean value, maps "--relax-checks"
16+
ENV SE_RELAX_CHECKS true
2717
# As integer, maps to "port"
28-
ENV GRID_HUB_PORT 4444
18+
ENV SE_HUB_PORT 4444
2919
# As string, maps to "host"
30-
ENV GRID_HUB_HOST "0.0.0.0"
20+
ENV SE_HUB_HOST "0.0.0.0"
21+
# As string, maps to "allow-cors"
22+
ENV SE_ALLOW_CORS false
3123

3224
COPY generate_config \
3325
start-selenium-grid-hub.sh \
3426
/opt/bin/
3527

3628
COPY selenium-grid-hub.conf /etc/supervisor/conf.d/
3729

38-
RUN /opt/bin/generate_config > /opt/selenium/config.json
30+
RUN /opt/bin/generate_config > /opt/selenium/config.toml

Hub/generate_config

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,16 @@
11
#!/usr/bin/env bash
22

33
cat <<_EOF
4-
{
5-
"host": "${GRID_HUB_HOST}",
6-
"port": ${GRID_HUB_PORT},
7-
"role": "hub",
8-
"maxSession": ${GRID_MAX_SESSION},
9-
"newSessionWaitTimeout": ${GRID_NEW_SESSION_WAIT_TIMEOUT},
10-
"capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
11-
"throwOnCapabilityNotPresent": ${GRID_THROW_ON_CAPABILITY_NOT_PRESENT},
12-
"jettyMaxThreads": ${GRID_JETTY_MAX_THREADS},
13-
"cleanUpCycle": ${GRID_CLEAN_UP_CYCLE},
14-
"browserTimeout": ${GRID_BROWSER_TIMEOUT},
15-
"timeout": ${GRID_TIMEOUT},
16-
"debug": ${GRID_DEBUG}
17-
}
4+
[network]
5+
relax-checks = ${SE_RELAX_CHECKS}
6+
7+
[sessionqueue]
8+
session-request-timeout = ${SE_SESSION_REQUEST_TIMEOUT}
9+
session-retry-interval = ${SE_SESSION_RETRY_INTERVAL}
10+
11+
[server]
12+
hostname = "${SE_HUB_HOST}"
13+
port = ${SE_HUB_PORT}
14+
allow-cors = ${SE_ALLOW_CORS}
15+
1816
_EOF

Hub/start-selenium-grid-hub.sh

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,17 @@
33
# set -e: exit asap if a command exits with a non-zero status
44
set -e
55

6-
echo "Starting Selenium Grid Hub..."
6+
CONFIG_TOML_FILE=/opt/selenium/config.toml
7+
8+
/opt/bin/generate_config >${CONFIG_TOML_FILE}
9+
10+
echo "Starting Selenium Grid Hub with configuration: "
11+
cat ${CONFIG_TOML_FILE}
712

813
if [ ! -z "$SE_OPTS" ]; then
914
echo "Appending Selenium options: ${SE_OPTS}"
1015
fi
1116

12-
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub --relax-checks true ${SE_OPTS}
17+
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar hub \
18+
--config ${CONFIG_TOML_FILE} \
19+
${SE_OPTS}

NodeBase/Dockerfile.txt

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -139,26 +139,8 @@ ENV START_XVFB true
139139
#========================
140140
# Selenium Configuration
141141
#========================
142-
# As integer, maps to "maxInstances"
143-
ENV NODE_MAX_INSTANCES 1
144-
# As integer, maps to "maxSession"
145-
ENV NODE_MAX_SESSION 1
146-
# As address, maps to "host"
147-
ENV NODE_HOST 0.0.0.0
148-
# As integer, maps to "port"
149-
ENV NODE_PORT 5555
150-
# In milliseconds, maps to "registerCycle"
151-
ENV NODE_REGISTER_CYCLE 5000
152-
# In milliseconds, maps to "nodePolling"
153-
ENV NODE_POLLING 5000
154-
# In milliseconds, maps to "unregisterIfStillDownAfter"
155-
ENV NODE_UNREGISTER_IF_STILL_DOWN_AFTER 60000
156-
# As integer, maps to "downPollingLimit"
157-
ENV NODE_DOWN_POLLING_LIMIT 2
158-
# As string, maps to "applicationName"
159-
ENV NODE_APPLICATION_NAME ""
160-
# Debug
161-
ENV GRID_DEBUG false
142+
# As integer, maps to "max-concurrent-sessions"
143+
ENV SE_NODE_MAX_CONCURRENT_SESSIONS 1
162144

163145
# Following line fixes https://github.com/SeleniumHQ/docker-selenium/issues/87
164146
ENV DBUS_SESSION_BUS_ADDRESS=/dev/null

NodeBase/start-selenium-node.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#!/bin/bash
22

3-
/opt/bin/generate_config > /opt/selenium/config.json
4-
53
# Start the pulseaudio server
64
pulseaudio -D --exit-idle-time=-1
75

@@ -29,7 +27,13 @@ if [[ -z "${SE_EVENT_BUS_SUBSCRIBE_PORT}" ]]; then
2927
exit 1
3028
fi
3129

30+
CONFIG_TOML_FILE=/opt/selenium/config.toml
31+
32+
/opt/bin/generate_config >${CONFIG_TOML_FILE}
33+
34+
echo "Starting Selenium Grid Node with configuration: "
35+
cat ${CONFIG_TOML_FILE}
36+
3237
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server.jar node \
33-
--publish-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_PUBLISH_PORT} \
34-
--subscribe-events tcp://"${SE_EVENT_BUS_HOST}":${SE_EVENT_BUS_SUBSCRIBE_PORT} \
38+
--config ${CONFIG_TOML_FILE} \
3539
${SE_OPTS}

NodeChrome/Dockerfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,4 @@ RUN if [ -z "$CHROME_DRIVER_VERSION" ]; \
5050
COPY generate_config /opt/bin/generate_config
5151

5252
# Generating a default config during build time
53-
RUN /opt/bin/generate_config > /opt/selenium/config.json
53+
RUN /opt/bin/generate_config > /opt/selenium/config.toml

NodeChrome/generate_config

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
#!/bin/bash
22

3-
CHROME_VERSION=$(/usr/bin/google-chrome -version | awk '{ print $3 }')
3+
# CHROME_VERSION=$(/usr/bin/google-chrome -version | awk '{ print $3 }')
44

55
cat <<_EOF
6-
{
7-
"capabilities": [
8-
{
9-
"version": "$CHROME_VERSION",
10-
"browserName": "chrome",
11-
"maxInstances": $NODE_MAX_INSTANCES,
12-
"seleniumProtocol": "WebDriver",
13-
"applicationName": "$NODE_APPLICATION_NAME"
14-
}
15-
],
16-
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
17-
"maxSession": $NODE_MAX_SESSION,
18-
"host": "$NODE_HOST",
19-
"port": $NODE_PORT,
20-
"register": true,
21-
"registerCycle": $NODE_REGISTER_CYCLE,
22-
"nodePolling": $NODE_POLLING,
23-
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
24-
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT,
25-
"debug": $GRID_DEBUG
26-
}
6+
[node]
7+
max-concurrent-sessions = ${SE_NODE_MAX_CONCURRENT_SESSIONS}
8+
9+
[events]
10+
publish = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}"
11+
subscribe = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}"
12+
2713
_EOF

NodeFirefox/Dockerfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ USER 1200
3535
COPY generate_config /opt/bin/generate_config
3636

3737
# Generating a default config during build time
38-
RUN /opt/bin/generate_config > /opt/selenium/config.json
38+
RUN /opt/bin/generate_config > /opt/selenium/config.toml
3939

4040
#==========
4141
# Relaxing permissions for OpenShift and other non-sudo environments

NodeFirefox/generate_config

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,14 @@
11
#!/bin/bash
22

3-
FIREFOX_VERSION=$( firefox -version | cut -d " " -f 3 )
4-
DRIVER_LOGLEVEL=${DRIVER_LOGLEVEL:-info}
3+
#FIREFOX_VERSION=$( firefox -version | cut -d " " -f 3 )
4+
#DRIVER_LOGLEVEL=${DRIVER_LOGLEVEL:-info}
55

66
cat <<_EOF
7-
{
8-
"capabilities": [
9-
{
10-
"version": "$FIREFOX_VERSION",
11-
"browserName": "firefox",
12-
"maxInstances": $NODE_MAX_INSTANCES,
13-
"seleniumProtocol": "WebDriver",
14-
"applicationName": "$NODE_APPLICATION_NAME",
15-
"moz:firefoxOptions":
16-
{
17-
"log":
18-
{
19-
"level": "$DRIVER_LOGLEVEL"
20-
}
21-
}
22-
}
23-
],
24-
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
25-
"maxSession": $NODE_MAX_SESSION,
26-
"host": "$NODE_HOST",
27-
"port": $NODE_PORT,
28-
"register": true,
29-
"registerCycle": $NODE_REGISTER_CYCLE,
30-
"nodePolling": $NODE_POLLING,
31-
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
32-
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT,
33-
"debug": $GRID_DEBUG
34-
}
7+
[node]
8+
max-concurrent-sessions = ${SE_NODE_MAX_CONCURRENT_SESSIONS}
9+
10+
[events]
11+
publish = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}"
12+
subscribe = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}"
13+
3514
_EOF

NodeOpera/Dockerfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,4 @@ RUN LATEST_VERSION=$(curl -s https://api.github.com/repos/operasoftware/operachr
5555
COPY generate_config /opt/bin/generate_config
5656

5757
# Generating a default config during build time
58-
RUN /opt/bin/generate_config > /opt/selenium/config.json
58+
RUN /opt/bin/generate_config > /opt/selenium/config.toml

NodeOpera/generate_config

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
11
#!/bin/bash
22

3-
OPERA_VERSION=$(opera -version)
3+
# OPERA_VERSION=$(opera -version)
44

55
cat <<_EOF
6-
{
7-
"capabilities": [
8-
{
9-
"version": "$OPERA_VERSION",
10-
"browserName": "operablink",
11-
"maxInstances": $NODE_MAX_INSTANCES,
12-
"seleniumProtocol": "WebDriver",
13-
"applicationName": "$NODE_APPLICATION_NAME"
14-
}
15-
],
16-
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
17-
"maxSession": $NODE_MAX_SESSION,
18-
"host": "$NODE_HOST",
19-
"port": $NODE_PORT,
20-
"register": true,
21-
"registerCycle": $NODE_REGISTER_CYCLE,
22-
"nodePolling": $NODE_POLLING,
23-
"unregisterIfStillDownAfter": $NODE_UNREGISTER_IF_STILL_DOWN_AFTER,
24-
"downPollingLimit": $NODE_DOWN_POLLING_LIMIT,
25-
"debug": $GRID_DEBUG
26-
}
6+
[node]
7+
max-concurrent-sessions = ${SE_NODE_MAX_CONCURRENT_SESSIONS}
8+
9+
[events]
10+
publish = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_PUBLISH_PORT}"
11+
subscribe = "tcp://${SE_EVENT_BUS_HOST}:${SE_EVENT_BUS_SUBSCRIBE_PORT}"
12+
2713
_EOF

docker-compose-v3-full-grid.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
version: "3"
55
services:
66
selenium-event-bus:
7-
image: selenium/event-bus:4.0.0-alpha-7-20201118
7+
image: selenium/event-bus:4.0.0-alpha-7-prerelease-20201009
88
container_name: selenium-event-bus
99
ports:
1010
- "4442:4442"
1111
- "4443:4443"
1212
- "5557:5557"
1313

1414
selenium-sessions:
15-
image: selenium/sessions:4.0.0-alpha-7-20201118
15+
image: selenium/sessions:4.0.0-alpha-7-prerelease-20201009
1616
container_name: selenium-sessions
1717
ports:
1818
- "5556:5556"
@@ -24,7 +24,7 @@ services:
2424
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
2525

2626
selenium-session-queuer:
27-
image: selenium/session-queuer:4.0.0-alpha-7-20201118
27+
image: selenium/session-queuer:4.0.0-alpha-7-prerelease-20201009
2828
container_name: selenium-session-queuer
2929
ports:
3030
- "5559:5559"
@@ -36,7 +36,7 @@ services:
3636
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
3737

3838
selenium-distributor:
39-
image: selenium/distributor:4.0.0-alpha-7-20201118
39+
image: selenium/distributor:4.0.0-alpha-7-prerelease-20201009
4040
container_name: selenium-distributor
4141
ports:
4242
- "5553:5553"
@@ -54,7 +54,7 @@ services:
5454
- SE_SESSION_QUEUER_PORT=5559
5555

5656
selenium-router:
57-
image: selenium/router:4.0.0-alpha-7-20201118
57+
image: selenium/router:4.0.0-alpha-7-prerelease-20201009
5858
container_name: selenium-router
5959
ports:
6060
- "4444:4444"
@@ -71,7 +71,7 @@ services:
7171
- SE_SESSION_QUEUER_PORT=5559
7272

7373
chrome:
74-
image: selenium/node-chrome:4.0.0-alpha-7-20201118
74+
image: selenium/node-chrome:4.0.0-alpha-7-prerelease-20201009
7575
volumes:
7676
- /dev/shm:/dev/shm
7777
depends_on:
@@ -84,7 +84,7 @@ services:
8484
- "6900:5900"
8585

8686
firefox:
87-
image: selenium/node-firefox:4.0.0-alpha-7-20201118
87+
image: selenium/node-firefox:4.0.0-alpha-7-prerelease-20201009
8888
volumes:
8989
- /dev/shm:/dev/shm
9090
depends_on:
@@ -96,15 +96,15 @@ services:
9696
ports:
9797
- "6901:5900"
9898

99-
# opera:
100-
# image: selenium/node-opera:4.0.0-alpha-7-20201118
101-
# volumes:
102-
# - /dev/shm:/dev/shm
103-
# depends_on:
104-
# - selenium-event-bus
105-
# environment:
106-
# - SE_EVENT_BUS_HOST=selenium-event-bus
107-
# - SE_EVENT_BUS_PUBLISH_PORT=4442
108-
# - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
109-
# ports:
110-
# - "6902:5900"
99+
opera:
100+
image: selenium/node-opera:4.0.0-alpha-7-prerelease-20201009
101+
volumes:
102+
- /dev/shm:/dev/shm
103+
depends_on:
104+
- selenium-event-bus
105+
environment:
106+
- SE_EVENT_BUS_HOST=selenium-event-bus
107+
- SE_EVENT_BUS_PUBLISH_PORT=4442
108+
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
109+
ports:
110+
- "6902:5900"

0 commit comments

Comments
 (0)