Skip to content

Commit 7b35e92

Browse files
committed
Adjusting images to Selenium Grid 4 Alpha
Using temporal jar for CI testing
1 parent bbf83bb commit 7b35e92

File tree

12 files changed

+104
-122
lines changed

12 files changed

+104
-122
lines changed

Base/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ COPY supervisord.conf /etc
6767
RUN mkdir -p /opt/selenium /var/run/supervisor /var/log/supervisor \
6868
&& touch /opt/selenium/config.json \
6969
&& chmod -R 777 /opt/selenium /var/run/supervisor /var/log/supervisor /etc/passwd \
70-
&& wget --no-verbose https://selenium-release.storage.googleapis.com/3.141/selenium-server-standalone-3.141.59.jar \
71-
-O /opt/selenium/selenium-server-standalone.jar \
70+
&& wget --no-verbose https://github.com/diemol/demos/releases/download/test/selenium_server_deploy.jar \
71+
-O /opt/selenium/selenium-server.jar \
7272
&& chgrp -R 0 /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor \
7373
&& chmod -R g=u /opt/selenium ${HOME} /var/run/supervisor /var/log/supervisor
7474

Hub/Dockerfile.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ USER seluser
44
# Selenium Configuration
55
#========================
66

7+
EXPOSE 4442
8+
EXPOSE 4443
79
EXPOSE 4444
810

911
# As integer, maps to "maxSession"
@@ -26,7 +28,7 @@ ENV GRID_DEBUG false
2628
ENV GRID_HUB_PORT 4444
2729
# As string, maps to "host"
2830
ENV GRID_HUB_HOST "0.0.0.0"
29-
31+
3032
COPY generate_config \
3133
start-selenium-hub.sh \
3234
/opt/bin/

Hub/start-selenium-hub.sh

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

6-
ROOT=/opt/selenium
7-
CONF=${ROOT}/config.json
6+
echo "Starting Selenium Hub..."
87

9-
/opt/bin/generate_config >${CONF}
10-
11-
echo "Starting Selenium Hub with configuration:"
12-
cat ${CONF}
13-
14-
if [ ! -z "$SE_OPTS" ]; then
15-
echo "Appending Selenium options: ${SE_OPTS}"
16-
fi
17-
18-
java ${JAVA_OPTS} -cp ${JAVA_CLASSPATH:-"/opt/selenium/*:."} org.openqa.grid.selenium.GridLauncherV3 \
19-
-role hub \
20-
-hubConfig ${CONF} \
21-
${SE_OPTS}
8+
java -jar /opt/selenium/selenium-server.jar hub

Makefile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -184,9 +184,6 @@ test: test_chrome \
184184
test_chrome:
185185
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeChrome
186186

187-
test_chrome_debug:
188-
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeChromeDebug
189-
190187
test_chrome_standalone:
191188
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh StandaloneChrome
192189

NodeBase/start-selenium-node.sh

Lines changed: 2 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22

33
/opt/bin/generate_config > /opt/selenium/config.json
44

5-
if [ ! -e /opt/selenium/config.json ]; then
6-
echo No Selenium Node configuration file, the node-base image is not intended to be run directly. 1>&2
7-
exit 1
8-
fi
9-
105
# Start the pulseaudio server
116
pulseaudio -D --exit-idle-time=-1
127

@@ -17,38 +12,7 @@ pacmd set-default-sink v1
1712
# set the monitor of v1 sink to be the default source
1813
pacmd set-default-source v1.monitor
1914

20-
# In the long term the idea is to remove $HUB_PORT_4444_TCP_ADDR and $HUB_PORT_4444_TCP_PORT and only work with
21-
# $HUB_HOST and $HUB_PORT
22-
if [ ! -z "$HUB_HOST" ]; then
23-
HUB_PORT_PARAM=4444
24-
if [ ! -z "$HUB_PORT" ]; then
25-
HUB_PORT_PARAM=${HUB_PORT}
26-
fi
27-
echo "Connecting to the Hub using the host ${HUB_HOST} and port ${HUB_PORT_PARAM}"
28-
HUB_PORT_4444_TCP_ADDR=${HUB_HOST}
29-
HUB_PORT_4444_TCP_PORT=${HUB_PORT_PARAM}
30-
fi
31-
32-
if [ -z "$HUB_PORT_4444_TCP_ADDR" ]; then
33-
echo "Not linked with a running Hub container" 1>&2
34-
exit 1
35-
fi
36-
37-
REMOTE_HOST_PARAM=""
38-
if [ ! -z "$REMOTE_HOST" ]; then
39-
echo "REMOTE_HOST variable is set, appending -remoteHost"
40-
REMOTE_HOST_PARAM="-remoteHost $REMOTE_HOST"
41-
fi
42-
43-
if [ ! -z "$SE_OPTS" ]; then
44-
echo "appending selenium options: ${SE_OPTS}"
45-
fi
46-
4715
rm -f /tmp/.X*lock
4816

49-
java ${JAVA_OPTS} -cp ${JAVA_CLASSPATH:-"/opt/selenium/*:."} org.openqa.grid.selenium.GridLauncherV3 \
50-
-role node \
51-
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
52-
${REMOTE_HOST_PARAM} \
53-
-nodeConfig /opt/selenium/config.json \
54-
${SE_OPTS}
17+
java -jar /opt/selenium/selenium-server.jar node --publish-events tcp://"$HUB_HOST":4442 \
18+
--subscribe-events tcp://"$HUB_HOST":4443

README.md

Lines changed: 20 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The project is made possible by volunteer contributors who have put in thousands
88

99
### IRC (#selenium at Freenode)
1010

11-
## Docker images for Selenium Standalone Server Hub and Node configurations with Chrome and Firefox
12-
[Travis CI](https://travis-ci.org/SeleniumHQ/docker-selenium)
11+
## Docker images for Selenium Grid with Chrome, Firefox and Opera
12+
[![Travis Status](https://travis-ci.com/SeleniumHQ/docker-selenium.svg?branch=master)](//travis-ci.com/SeleniumHQ/docker-selenium/builds)
1313

1414
Images included:
1515
- __selenium/base__: Base image which includes Java runtime and Selenium Server JAR file
@@ -18,41 +18,38 @@ Images included:
1818
- __selenium/node-chrome__: Grid Node with Chrome installed, needs to be connected to a Grid Hub
1919
- __selenium/node-firefox__: Grid Node with Firefox installed, needs to be connected to a Grid Hub
2020
- __selenium/node-opera__: Grid Node with Opera installed, needs to be connected to a Grid Hub
21-
- __selenium/node-chrome-debug__: Grid Node with Chrome installed and runs a VNC server, needs to be connected to a Grid Hub
22-
- __selenium/node-firefox-debug__: Grid Node with Firefox installed and runs a VNC server, needs to be connected to a Grid Hub
23-
- __selenium/node-opera-debug__: Grid Node with Opera installed and runs a VNC server, needs to be connected to a Grid Hub
2421
- __selenium/standalone-chrome__: Selenium Standalone with Chrome installed
2522
- __selenium/standalone-firefox__: Selenium Standalone with Firefox installed
2623
- __selenium/standalone-opera__: Selenium Standalone with Opera installed
27-
- __selenium/standalone-chrome-debug__: Selenium Standalone with Chrome installed and runs a VNC server
28-
- __selenium/standalone-firefox-debug__: Selenium Standalone with Firefox installed and runs a VNC server
29-
- __selenium/standalone-opera-debug__: Selenium Standalone with Opera installed and runs a VNC server
3024

3125
##
3226

3327
## Running the images
34-
:exclamation: When executing `docker run` for an image with Chrome or Firefox please either mount `-v /dev/shm:/dev/shm` or use the flag `--shm-size=2g` to use the host's shared memory.
28+
:exclamation: When executing `docker run` for an image that contains a browser please either mount `-v /dev/shm:/dev/shm` or use the
29+
flag `--shm-size=2g` to use the host's shared memory.
3530

36-
:exclamation: In general, 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.
31+
:exclamation: Always use a tag with an element suffix to pin a specific browser version.
32+
See [Tagging Conventions](https://github.com/SeleniumHQ/docker-selenium/wiki/Tagging-Convention) for details.
3733

3834
Chrome
3935
``` bash
4036
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:3.141.59-zirconium
41-
#OR
37+
# OR
4238
$ docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-chrome:3.141.59-zirconium
4339
```
4440
Firefox
4541
``` bash
4642
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:3.141.59-zirconium
47-
#OR
43+
# OR
4844
$ docker run -d -p 4444:4444 --shm-size 2g selenium/standalone-firefox:3.141.59-zirconium
4945
```
5046
Opera
5147
``` bash
5248
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-opera:3.141.59-zirconium
53-
#OR
49+
# OR
5450
$ docker run -d -p 4444:4444 --shm-size=2g selenium/standalone-opera:3.141.59-zirconium
5551
```
52+
5653
This is a known workaround to avoid the browser crashing inside a docker container, here are the documented issues for
5754
[Chrome](https://code.google.com/p/chromium/issues/detail?id=519952) and [Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=1338771#c10).
5855
The shm size of 2gb is arbitrary but known to work well, your specific use case might need a different value, it is recommended
@@ -69,9 +66,9 @@ $ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-firefox:3.
6966
$ docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-opera:3.141.59-zirconium
7067
```
7168

72-
_Note: Only one standalone image can run on port_ `4444` _at a time._
69+
_Note: Only one Standalone container can run on port_ `4444` _at a time._
7370

74-
To inspect visually what the browser is doing use the `standalone-chrome-debug`, `standalone-firefox-debug` or `standalone-opera-debug` images. See [Debugging](#debugging) section for details.
71+
To inspect visually what the browser is doing, see the [Debugging](#debugging) section for details.
7572

7673
### Selenium Grid Hub and Nodes
7774
There are different ways to run the images and create a grid, check the following options.
@@ -113,7 +110,7 @@ services:
113110
volumes:
114111
- /dev/shm:/dev/shm
115112
depends_on:
116-
- hub
113+
- selenium-hub
117114
environment:
118115
HUB_HOST: hub
119116

@@ -122,7 +119,7 @@ services:
122119
volumes:
123120
- /dev/shm:/dev/shm
124121
depends_on:
125-
- hub
122+
- selenium-hub
126123
environment:
127124
HUB_HOST: hub
128125

@@ -131,11 +128,11 @@ services:
131128
volumes:
132129
- /dev/shm:/dev/shm
133130
depends_on:
134-
- hub
131+
- selenium-hub
135132
environment:
136133
HUB_HOST: hub
137134

138-
hub:
135+
selenium-hub:
139136
image: selenium/hub:3.141.59-zirconium
140137
ports:
141138
- "4444:4444"
@@ -161,7 +158,6 @@ services:
161158
- selenium-hub
162159
environment:
163160
- HUB_HOST=selenium-hub
164-
- HUB_PORT=4444
165161

166162
firefox:
167163
image: selenium/node-firefox:3.141.59-zirconium
@@ -171,7 +167,6 @@ services:
171167
- selenium-hub
172168
environment:
173169
- HUB_HOST=selenium-hub
174-
- HUB_PORT=4444
175170

176171
opera:
177172
image: selenium/node-opera:3.141.59-zirconium
@@ -181,7 +176,6 @@ services:
181176
- selenium-hub
182177
environment:
183178
- HUB_HOST=selenium-hub
184-
- HUB_PORT=4444
185179
```
186180
187181
To stop the grid and cleanup the created containers, run `docker-compose down`.
@@ -195,7 +189,7 @@ To stop the grid and cleanup the created containers, run `docker-compose down`.
195189
version: '3.7'
196190

197191
services:
198-
hub:
192+
selenium-hub:
199193
image: selenium/hub:3.141.59-zirconium
200194
ports:
201195
- "4444:4444"
@@ -205,8 +199,7 @@ services:
205199
volumes:
206200
- /dev/shm:/dev/shm
207201
environment:
208-
HUB_HOST: hub
209-
HUB_PORT: 4444
202+
HUB_HOST: selenium-hub
210203
deploy:
211204
replicas: 1
212205
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
@@ -216,8 +209,7 @@ services:
216209
volumes:
217210
- /dev/shm:/dev/shm
218211
environment:
219-
HUB_HOST: hub
220-
HUB_PORT: 4444
212+
HUB_HOST: selenium-hub
221213
deploy:
222214
replicas: 1
223215
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
@@ -227,25 +219,12 @@ services:
227219
volumes:
228220
- /dev/shm:/dev/shm
229221
environment:
230-
HUB_HOST: hub
231-
HUB_PORT: 4444
222+
HUB_HOST: selenium-hub
232223
deploy:
233224
replicas: 1
234225
entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'
235226
```
236227
237-
#### Using `--link`
238-
This option can be used for a single host scenario (hub and nodes running in a single machine), but it is not recommended
239-
for longer term usage since this is a docker [legacy feature](https://docs.docker.com/compose/compose-file/#links).
240-
It could serve you as an option for a proof of concept, and for simplicity it is used in the examples shown from now on.
241-
242-
``` bash
243-
$ docker run -d -p 4444:4444 --name selenium-hub selenium/hub:3.141.59-zirconium
244-
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-chrome:3.141.59-zirconium
245-
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-firefox:3.141.59-zirconium
246-
$ docker run -d --link selenium-hub:hub -v /dev/shm:/dev/shm selenium/node-opera:3.141.59-zirconium
247-
```
248-
249228
### Deploying to Kubernetes
250229
251230
Check out [the Kubernetes examples](https://github.com/kubernetes/examples/tree/master/staging/selenium)

Standalone/start-selenium-standalone.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
#
33
# IMPORTANT: Change this file only in directory Standalone!
44

5-
java ${JAVA_OPTS} -cp ${JAVA_CLASSPATH:-"/opt/selenium/*:."} org.openqa.grid.selenium.GridLauncherV3 \
6-
${SE_OPTS}
5+
java -jar /opt/selenium/selenium-server.jar standalone

StandaloneOpera/selenium.conf

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
; Documentation of this file format -> http://supervisord.org/configuration.html
22

3-
; Priority 0 - xvfb, 5 - fluxbox (debug images), 10 - x11vnc (debug images), 15 - selenium-node
3+
; Priority 0 - xvfb, 5 - fluxbox, 10 - x11vnc, 15 - selenium-node
44

55
[program:xvfb]
66
priority=0
@@ -21,6 +21,43 @@ stderr_logfile_backups=5
2121
stdout_capture_maxbytes=50MB
2222
stderr_capture_maxbytes=50MB
2323

24+
[program:fluxbox]
25+
priority=5
26+
command=/opt/bin/start-fluxbox.sh
27+
autostart=true
28+
autorestart=unexpected
29+
startsecs=0
30+
startretries=0
31+
32+
;Logs
33+
redirect_stderr=false
34+
stdout_logfile=/var/log/supervisor/fluxbox-stdout.log
35+
stderr_logfile=/var/log/supervisor/fluxbox-stderr.log
36+
stdout_logfile_maxbytes=50MB
37+
stderr_logfile_maxbytes=50MB
38+
stdout_logfile_backups=5
39+
stderr_logfile_backups=5
40+
stdout_capture_maxbytes=50MB
41+
stderr_capture_maxbytes=50MB
42+
43+
[program:vnc]
44+
priority=10
45+
command=/opt/bin/start-vnc.sh
46+
autostart=true
47+
autorestart=false
48+
startsecs=0
49+
startretries=0
50+
51+
;Logs
52+
redirect_stderr=false
53+
stdout_logfile=/var/log/supervisor/vnc-stdout.log
54+
stderr_logfile=/var/log/supervisor/vnc-stderr.log
55+
stdout_logfile_maxbytes=50MB
56+
stderr_logfile_maxbytes=50MB
57+
stdout_logfile_backups=5
58+
stderr_logfile_backups=5
59+
stdout_capture_maxbytes=50MB
60+
stderr_capture_maxbytes=50MB
2461

2562
[program:selenium-standalone]
2663
priority=15

tests/SeleniumTests/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,16 @@ def tearDown(self):
6363
class ChromeTests(SeleniumGenericTests):
6464
def setUp(self):
6565
self.driver = webdriver.Remote(
66-
desired_capabilities=DesiredCapabilities.CHROME
66+
desired_capabilities=DesiredCapabilities.CHROME,
67+
command_executor='http://localhost:4444'
6768
)
6869

6970

7071
class FirefoxTests(SeleniumGenericTests):
7172
def setUp(self):
7273
self.driver = webdriver.Remote(
73-
desired_capabilities=DesiredCapabilities.FIREFOX
74+
desired_capabilities=DesiredCapabilities.FIREFOX,
75+
command_executor='http://localhost:4444'
7476
)
7577

7678
def test_title_and_maximize_window(self):
@@ -84,5 +86,6 @@ def setUp(self):
8486
capabilities = DesiredCapabilities.CHROME
8587
capabilities['browserName'] = 'operablink'
8688
self.driver = webdriver.Remote(
87-
desired_capabilities=capabilities
89+
desired_capabilities=capabilities,
90+
command_executor='http://localhost:4444'
8891
)

0 commit comments

Comments
 (0)