Skip to content
This repository was archived by the owner on Jun 30, 2021. It is now read-only.

Commit c2a7e7a

Browse files
committed
Add WORKDIR & exec grid cat HUB_PORT #=> 24444
1 parent 1330cdf commit c2a7e7a

20 files changed

+218
-92
lines changed

.travis.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22
# us to pick a language else it will pick Ruby by default
33
language: generic
44

5-
sudo: required
6-
services:
7-
- docker
8-
9-
# Omit running tests on temporal branches
5+
# Omit running tests on temporal branches,
6+
# i.e. branches with names that start with "tmp"
107
branches:
118
except:
129
- /^tmp/
@@ -17,37 +14,59 @@ env:
1714

1815
matrix:
1916
allow_failures:
20-
- os: osx
21-
env:
17+
# Currently erroring in Mac (OSX):
18+
# https://travis-ci.org/elgalu/docker-selenium/jobs/143553463#L636
19+
# com.docker.docker Incompatible CPU detected
20+
# Docker requires a processor with virtualization capabilities
21+
- env:
2222
- DOCKER_VERSION="1.12.0-rc3"
2323
DOCKER_COMPOSE_VERSION="1.8.0-rc2"
24+
OPERATING_SYSTEM="osx"
2425
include:
2526
# Linux with docker:stable compose:stable
2627
- os: linux
28+
sudo: required
29+
dist: trusty
30+
services:
31+
- docker
2732
env:
2833
- DOCKER_VERSION="stable"
2934
DOCKER_COMPOSE_VERSION="1.7.1"
3035
DOCKER_PUSH=true
3136
# Linux with docker:beta compose:stable
3237
- os: linux
38+
sudo: required
39+
dist: trusty
40+
services:
41+
- docker
3342
env:
3443
- DOCKER_VERSION="1.12.0-rc3"
3544
DOCKER_COMPOSE_VERSION="1.7.1"
3645
# Linux with docker:stable compose:beta
3746
- os: linux
47+
sudo: required
48+
dist: trusty
49+
services:
50+
- docker
3851
env:
3952
- DOCKER_VERSION="stable"
4053
DOCKER_COMPOSE_VERSION="1.8.0-rc2"
4154
# Linux with docker:beta compose:beta
4255
- os: linux
56+
sudo: required
57+
dist: trusty
58+
services:
59+
- docker
4360
env:
4461
- DOCKER_VERSION="1.12.0-rc3"
4562
DOCKER_COMPOSE_VERSION="1.8.0-rc2"
4663
# Mac OSX: only test native docker version
4764
- os: osx
65+
osx_image: xcode8
4866
env:
4967
- DOCKER_VERSION="1.12.0-rc3"
5068
DOCKER_COMPOSE_VERSION="1.8.0-rc2"
69+
OPERATING_SYSTEM="osx"
5170

5271
before_install:
5372
- travis_retry ./test/before_install_setup

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ Note image ids also change after scm-source.json has being updated which trigger
99

1010
## TBD_DOCKER_TAG
1111
+ Date: TBD_DATE
12-
+ TBD_COMMIT_MSG
12+
+ Add OSX support closes #111 #110
13+
+ Add docs/share-host.md and docs/jenkins.md (WIP)
14+
+ Chore: Add `WORKDIR ${NORMAL_USER_HOME}`
15+
+ Chore: Add `docker exec grid cat HUB_PORT #=> 24444`
1316
+ Image tag details:
1417
+ Selenium: vTBD_SELENIUM_VERSION (TBD_SELENIUM_REVISION)
1518
+ Chrome stable: TBD_CHROME_STABLE

CONTRIBUTING.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,19 @@ For pull requests or local commits:
88
open ./images/grid_console.png #to verify the versions are correct
99
git checkout ./images/grid_console.png && open ./videos/chrome/test.mkv
1010
travis lint #if you changed .travis.yml
11-
git checkout -b tmp-2.53.1f #name your branch according to your changes
11+
git checkout -b tmp-2.53.1g #name your branch according to your changes
1212
#git add ... git commit ... git push ... open pull request
1313

1414
For repository owners only:
1515

1616
git commit -m "Add OSX support closes #111 #110"
1717
git tag -d latest #tag latest will be updated from TravisCI
18-
git tag 2.53.1f && git push origin tmp-2.53.1f && git push --tags
18+
git tag 2.53.1g && git push origin tmp-2.53.1g && git push --tags
1919

2020
-- Wait for Travis to pass OK
2121
-- Make sure changes got merged into master by elgalubot
2222

23-
git checkout master && git pull && git branch -d tmp-2.53.1f && git push origin --delete tmp-2.53.1f
23+
git checkout master && git pull && git branch -d tmp-2.53.1g && git push origin --delete tmp-2.53.1g
2424

2525
-- Re-add TBD_* section in CHANGELOG.md starting with TBD_DOCKER_TAG
2626
-- Upgrade release tag in github.com with latest CHANGELOG.md
@@ -37,9 +37,9 @@ Keep certain bins if chrome version changed for example:
3737
## Retry
3838
Failed in Travis? retry
3939

40-
git tag -d 2.53.1f && git push origin :2.53.1f
40+
git tag -d 2.53.1g && git push origin :2.53.1g
4141
#git add ...
42-
git commit --amend && git tag 2.53.1f && git push --force origin tmp-2.53.1f && git push --tags
42+
git commit --amend && git tag 2.53.1g && git push --force origin tmp-2.53.1g && git push --tags
4343

4444
## Docker push from Travis CI
4545
Travis [steps](https://docs.travis-ci.com/user/docker/#Pushing-a-Docker-Image-to-a-Registry) involve `docker login` and docker credentials encryptions.

Dockerfile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ RUN apt-get update -qqy \
440440
&& pip install --upgrade pip \
441441
&& pip install --upgrade setuptools \
442442
&& pip install --upgrade selenium \
443+
&& pip install --upgrade retrying \
443444
&& rm -rf /var/lib/apt/lists/*
444445

445446
#=========================================
@@ -970,7 +971,10 @@ ENV FIREFOX_VERSION="${FF_VER}" \
970971
SELENIUM_HUB_PARAMS="" \
971972
SELENIUM_NODE_PARAMS="" \
972973
SELENIUM_NODE_PROXY_PARAMS="" \
973-
SELENIUM_NODE_REGISTER_CYCLE="" \
974+
# How often in ms the node will try to register itself again.
975+
# Allow to restart the hub without having to restart the nodes.
976+
# (node) in ms. Selenium default: 5000
977+
SELENIUM_NODE_REGISTER_CYCLE="0" \
974978
# To taggle issue #58 see https://goo.gl/fz6RTu
975979
CHROME_ARGS="--no-sandbox" \
976980
# e.g. CHROME_ARGS="--no-sandbox --ignore-certificate-errors" \
@@ -982,8 +986,12 @@ ENV FIREFOX_VERSION="${FF_VER}" \
982986
MAX_SESSIONS=1 \
983987
SEL_RELEASE_TIMEOUT_SECS=19000 \
984988
SEL_BROWSER_TIMEOUT_SECS=16000 \
985-
SEL_CLEANUPCYCLE_MS=90000 \
986-
SEL_NODEPOLLING_MS=80000 \
989+
# How often a proxy will check for timed out thread.
990+
# (node) in ms. Selenium default: 5000
991+
SEL_CLEANUPCYCLE_MS=9000 \
992+
# Interval between alive checks of node how often the hub checks if the node is still alive.
993+
# (node) in ms. Selenium default: 5000
994+
SEL_NODEPOLLING_MS=6000 \
987995
# Docker for Mac beta - containers do not start #227
988996
no_proxy=localhost \
989997
HUB_ENV_no_proxy=localhost \
@@ -1169,6 +1177,7 @@ COPY scm-source.json /
11691177
# Ensure the file is up-to-date else you should update it by running
11701178
# ./host-scripts/gen-scm-source.sh
11711179
# on the host machine
1180+
WORKDIR ${NORMAL_USER_HOME}
11721181

11731182
#===================
11741183
# CMD or ENTRYPOINT

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,26 @@ If you don't require a real browser [PhantomJS](https://github.com/ariya/phantom
3939
You can also configure [xvfb](https://docs.travis-ci.com/user/gui-and-headless-browsers/#Using-xvfb-to-Run-Tests-That-Require-a-GUI) yourself but it involves some manual steps and doesn't include video recording, nor does PhantomJS nor Electron.
4040
A [new chromium headless project](https://github.com/electron/electron/issues/228#issuecomment-223797342) looks very promising so might we worth to take a look though as of now leaves video recording out of scope there and Firefox also out of scope.
4141

42+
### Requisites
43+
This project is normally tested in the last version of Docker and docker-compose and also in the release candidates.
44+
To figure out the currently used specific versions it surely works on,
45+
see file [.travis.yml](./.travis.yml) example values:
46+
47+
docker --version #=> 1.11.2
48+
docker-compose --version #=> 1.7.1
49+
50+
If you need to use docker-machine to run docker
51+
(like for example on a Mac before the Docker native version 1.12),
52+
you also need to install VirtualBox and then run these commands to get started:
53+
54+
55+
```sh
56+
docker-machine create --driver virtualbox default
57+
eval "$(docker-machine env default)"
58+
```
59+
60+
You will need to run the second `eval` command for every new terminal window.
61+
4262
### Usage
4363

4464
<h4 id="run"><img width="24" src="./images/icons/logo.png" /> Run</h4>
@@ -76,6 +96,9 @@ Shutdown immediately, no mercy
7696
### Docker Compose
7797
See [docker-compose](./docs/docker-compose.md)
7898

99+
### Jenkins
100+
See [jenkins](./docs/jenkins.md)
101+
79102
### Parallel
80103
This image is designed to run one test on each docker container but if you still want to run multiple tests in parallel you can still do, there are some ways to do this:
81104

bin/entry.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,26 @@ if [ "${SHM_TRY_MOUNT_UNMOUNT}" = "true" ]; then
339339
tmpfs /dev/shm || true
340340
fi
341341

342+
#-------------------------------------------
343+
# Keep updated environment vars inside files
344+
#-------------------------------------------
345+
# So can be consulted later on with:
346+
# docker exec grid cat HUB_PORT #=> 24444
347+
# docker exec selenium_chrome_1 cat FF_PORT #=> 44023
348+
echo "${SELENIUM_HUB_PORT}" > SELENIUM_HUB_PORT
349+
echo "${SELENIUM_HUB_PORT}" > HUB_PORT
350+
echo "${SELENIUM_NODE_CH_PORT}" > SELENIUM_NODE_CH_PORT
351+
echo "${SELENIUM_NODE_CH_PORT}" > CH_PORT
352+
echo "${SELENIUM_NODE_FF_PORT}" > SELENIUM_NODE_FF_PORT
353+
echo "${SELENIUM_NODE_FF_PORT}" > FF_PORT
354+
echo "${DISPLAY}" > DISPLAY
355+
echo "${VNC_PORT}" > VNC_PORT
356+
echo "${NOVNC_PORT}" > NOVNC_PORT
357+
echo "${SSHD_PORT}" > SSHD_PORT
358+
echo "${SAUCE_LOCAL_SEL_PORT}" > SAUCE_LOCAL_SEL_PORT
359+
echo "${SUPERVISOR_HTTP_PORT}" > SUPERVISOR_HTTP_PORT
360+
env > env
361+
342362
#------
343363
# exec
344364
#------

docker-compose-host.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ services:
1414

1515
chrome:
1616
image: elgalu/selenium
17+
depends_on:
18+
- hub
1719
network_mode: host
1820
shm_size: 1g
1921
environment:
@@ -23,11 +25,11 @@ services:
2325
- GRID=false
2426
- CHROME=true
2527
- FIREFOX=false
26-
depends_on:
27-
- hub
2828

2929
firefox:
3030
image: elgalu/selenium
31+
depends_on:
32+
- hub
3133
network_mode: host
3234
environment:
3335
- SELENIUM_HUB_PORT
@@ -36,8 +38,6 @@ services:
3638
- GRID=false
3739
- CHROME=false
3840
- FIREFOX=true
39-
depends_on:
40-
- hub
4141

4242
#-- Notes --#
4343
# shm_size: 1g

docker-compose.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
hub:
55
image: elgalu/selenium
66
ports:
7-
- 4444:${SELENIUM_HUB_PORT}
7+
- ${SELENIUM_HUB_PORT}:${SELENIUM_HUB_PORT}
88
environment:
99
- SELENIUM_HUB_PORT
1010
- VNC_START=false
@@ -15,8 +15,6 @@ services:
1515

1616
chrome:
1717
image: elgalu/selenium
18-
depends_on:
19-
- hub
2018
network_mode: "service:hub"
2119
shm_size: 1g
2220
environment:
@@ -29,8 +27,6 @@ services:
2927

3028
firefox:
3129
image: elgalu/selenium
32-
depends_on:
33-
- hub
3430
network_mode: "service:hub"
3531
environment:
3632
- SELENIUM_HUB_PORT

docs/docker-compose.md

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,42 @@
11
# Compose
22
Scale up and down the nodes by using [docker-compose](https://docs.docker.com/compose/).
3-
Install the tooling by following that link and make sure you have latest stable versions of both tools.
43

5-
## Requisites
6-
Docker and docker-compose:
4+
For using it by sharing the host (localhost) network interface see [share-host](./share-host.md)
75

8-
docker --version #=> 1.11.2
9-
docker-compose --version #=> 1.7.1
6+
For requirements check [README#requisites](../README.md#requisites)
107

118
## Usage
12-
Either clone this repository or download the file [docker-compose.yml](../docker-compose.yml) using `wget`
9+
Either clone this repository or download the file [docker-compose.yml][] using `wget`
1310

1411
wget -nv "https://raw.githubusercontent.com/elgalu/docker-selenium/master/docker-compose.yml"
12+
docker-compose -p selenium down #ensure is not already running
1513

1614
### Run
17-
Either start with `docker-compose ... scale` as shown in below example or you can also use `docker-compose up` and scale after in a second command.
15+
Start it with `docker-compose up` then **scale** it:
1816

19-
SELENIUM_HUB_PORT=4444 docker-compose -p selenium up -d
20-
docker-compose -p selenium scale chrome=3 firefox=3
17+
export SELENIUM_HUB_PORT=4444 NODES=3
18+
docker-compose -p selenium up -d
19+
docker-compose -p selenium scale chrome=${NODES} firefox=${NODES}
2120

2221
Wait until the grid starts properly before starting the tests _(Optional but recommended)_
2322

24-
docker-compose -p selenium exec -T --index=3 chrome wait_all_done 30s
23+
docker exec selenium_hub_1 wait_all_done 30s
24+
for ((i=1; i<=${NODES}; i++)); do
25+
docker-compose -p selenium exec -T --index=$i chrome wait_all_done 30s
26+
docker-compose -p selenium exec -T --index=$i firefox wait_all_done 30s
27+
done
28+
29+
### Test
30+
You can now run your tests by using the `--seleniumUrl="http://localhost:4444/wd/hub"`.
31+
32+
However if your web application under test is running in localhost, e.g. `--appHost=localhost`
33+
you should instead either dockerize your application and add it to the [docker-compose.yml][] file as another [service](https://docs.docker.com/compose/compose-file/#/service-configuration-reference) or somehow replace `--appHost=localhost` with `--appHost=d.host.loc.dev` in the config file of your testing framework. The string `d.host.loc.dev` is a place holder inside the docker container that points to the IP of your localhost.
2534

2635
### Cleanup
27-
The `down` compose command stops and remove containers, networks, volumes, and images created by `up` or `scale`
36+
Once your tests are done you can clean up:
2837

2938
docker-compose -p selenium down
39+
40+
The `down` compose command stops and remove containers, networks, volumes, and images created by `up` or `scale`
41+
42+
[docker-compose.yml]: ../docker-compose.yml

docs/jenkins.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,2 @@
1-
# Compose
2-
Scale up and down the nodes by using [docker-compose](https://docs.docker.com/compose/).
3-
For requirements check [docker-compose#requisites](./docker-compose.md#requisites)
4-
5-
## Usage
6-
Either clone this repository or download the file [docker-compose-host.yml](../docker-compose-host.yml) using `wget`
7-
8-
wget -nv -O docker-compose.yml "https://raw.githubusercontent.com/elgalu/docker-selenium/master/docker-compose-host.yml"
9-
10-
### Run
11-
Either start with `docker-compose ... scale` as shown in below example or you can also use `docker-compose up` and scale after in a second command.
12-
13-
SELENIUM_HUB_PORT=4444 docker-compose -p selenium scale hub=1 chrome=3 firefox=3
14-
15-
Wait until the grid starts properly before starting the tests _(Optional but recommended)_
16-
17-
docker-compose -p selenium exec -T --index=3 chrome wait_all_done 30s
18-
19-
### Cleanup
20-
The `down` compose command stops and remove containers, networks, volumes, and images created by `up` or `scale`
21-
22-
docker-compose -p selenium down
1+
# Jenkins
2+
Follow the same procedure as explained in [docker-compose](./docker-compose.md)

0 commit comments

Comments
 (0)