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

Commit b822798

Browse files
committed
Pick random ports from a range to avoid collisions
1 parent 8b935d7 commit b822798

File tree

5 files changed

+62
-29
lines changed

5 files changed

+62
-29
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ matrix:
4848
services:
4949
- docker
5050
env:
51-
- DOCKER_VERSION="1.13.0-rc1"
51+
- DOCKER_VERSION="1.13.0-rc2"
5252
DOCKER_COMPOSE_VERSION="1.9.0"
5353
# Linux with docker:stable compose:beta/older
5454
- os: linux
@@ -68,7 +68,7 @@ matrix:
6868
services:
6969
- docker
7070
env:
71-
- DOCKER_VERSION="1.13.0-rc1"
71+
- DOCKER_VERSION="1.13.0-rc2"
7272
DOCKER_COMPOSE_VERSION="1.9.0-rc4"
7373
# Mac OSX: only test native docker version
7474
- os: osx

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,33 @@ Note image ids also change after scm-source.json has being updated which trigger
77
###### To get container versions
88
docker exec grid versions
99

10+
## TBD_DOCKER_TAG
11+
+ Date: TBD_DATE
12+
+ Pick random ports from a range to avoid collisions
13+
+ Image tag details:
14+
+ Selenium 2: TBD_SELENIUM_2_VERSION (TBD_SELENIUM_2_REVISION)
15+
+ Selenium 3: 3.0.1 (1969d75)
16+
+ Chrome stable: TBD_CHROME_STABLE
17+
+ Firefox for Selenium 2: TBD_FIREFOX_FOR_SEL2
18+
+ Firefox for Selenium 3: TBD_FIREFOX_FOR_SEL3
19+
+ Geckodriver: TBD_GECKO_DRIVER
20+
+ Chromedriver: TBD_CHROME_DRIVER (TBD_CHROMEDRIVER_COMMIT)
21+
+ Java: TBD_JAVA_VENDOR Java TBD_JAVA_BUILD
22+
+ Timezone: TBD_TIME_ZONE
23+
+ FROM ubuntu:UBUNTU_FLAVOR-UBUNTU_DATE
24+
+ Python: TBD_PYTHON_VERSION
25+
+ Sauce Connect TBD_SAUCE_CONNECT_VERS, build TBD_SAUCE_CONNECT_BUILD TBD_SAUCE_CONNECT_REVISION
26+
+ BrowserStack Local version TBD_BROWSER_STACK_VERSION
27+
+ Tested on kernel dev host: 4.4.0-47-generic x86_64
28+
+ Tested on kernel CI host: TBD_HOST_UNAME
29+
+ Built at dev host with: Docker version 1.12.3, build 6b644ec
30+
+ Built at CI host with: Docker version TBD_DOCKER_VERS, build TBD_DOCKER_BUILD
31+
+ Built at dev host with: Docker Compose version 1.9.0, build 2585387
32+
+ Built at CI host with: Docker Compose version TBD_DOCKER_COMPOSE_VERS, build TBD_DOCKER_COMPOSE_BUILD
33+
+ Image size: TBD_IMAGE_SIZE
34+
+ Digest: TBD_DIGEST
35+
+ Image ID: TBD_IMAGE_ID
36+
1037
## 3.0.1g
1138
+ Date: 2016-11-18
1239
+ NoVNC new defaults: autoconnect=true, view_only=true, resize=scale

CONTRIBUTING.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ For pull requests or local commits:
77
docker exec grid versions && ./test/after_script && travis lint
88
open ./images/grid2_console.png && open ./images/grid3_console.png && open ./videos/mobile_emulation/*.mkv
99
open test/seleIDE/videos/rc/sele_ide.mkv
10-
git checkout -b tmp-3.0.1g && git checkout ./images/grid2_console.png && git checkout ./images/grid3_console.png
10+
git checkout -b tmp-3.0.1h && git checkout ./images/grid2_console.png && git checkout ./images/grid3_console.png
1111
#git add ... git commit ... git push ... open pull request
1212

1313
For repository owners only:
1414

15-
git commit -m "NoVNC new defaults: autoconnect=true, view_only=true, resize=scale"
16-
git tag -d latest && git tag 3.0.1g && git push origin tmp-3.0.1g && git push --tags
15+
git commit -m "Pick random ports from a range to avoid collisions"
16+
git tag -d latest && git tag 3.0.1h && git push origin tmp-3.0.1h && git push --tags
1717

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

21-
git checkout master && git pull && git branch -d tmp-3.0.1g && git push origin --delete tmp-3.0.1g
21+
git checkout master && git pull && git branch -d tmp-3.0.1h && git push origin --delete tmp-3.0.1h
2222

2323
-- Re-add TBD_* section in CHANGELOG.md starting with TBD_DOCKER_TAG
2424
-- If Chrome version changed upload:
@@ -35,9 +35,9 @@ Keep certain bins if chrome version changed for example:
3535
## Retry
3636
Failed in Travis? retry
3737

38-
git tag -d 3.0.1g && git push origin :3.0.1g
38+
git tag -d 3.0.1h && git push origin :3.0.1h
3939
#git add ...
40-
git commit --amend && git tag 3.0.1g && git push --force origin tmp-3.0.1g && git push --tags
40+
git commit --amend && git tag 3.0.1h && git push --force origin tmp-3.0.1h && git push --tags
4141

4242
## Docker push from Travis CI
4343
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: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -662,16 +662,20 @@ ENV DEFAULT_SELENIUM_HUB_PORT="24444" \
662662
DEFAULT_VNC_PORT="25900" \
663663
DEFAULT_NOVNC_PORT="26080" \
664664
DEFAULT_SAUCE_LOCAL_SEL_PORT="4445" \
665-
DEFAULT_SUPERVISOR_HTTP_PORT="29001"
665+
DEFAULT_SUPERVISOR_HTTP_PORT="19001"
666666

667667
# Commented for now; all these versions are still available at
668668
# https://github.com/elgalu/docker-selenium/releases/tag/2.47.1m
669669
# USE_SELENIUM "2" / "3"
670670
# Selenium 2 or 3
671671
# CHROME_FLAVOR "stable"
672-
# Default chrome flavor, options no longer avariable: beta|unstable
672+
# Default chrome flavor, options no longer available: beta|unstable
673673
# PICK_ALL_RANDMON_PORTS "true" / "false"
674674
# Randomize all ports, i.e. pick unused unprivileged ones
675+
# RANDOM_PORT_FROM
676+
# RANDOM_PORT_TO
677+
# When using PICK_ALL_RANDMON_PORTS=true the ports will
678+
# be from a range to avoid collisions
675679
# MEM_JAVA_PERCENT "80"
676680
# Because the JVM uses only 1/4 of system memory by default
677681
# WAIT_FOREGROUND_RETRY
@@ -782,11 +786,13 @@ ENV DEFAULT_SELENIUM_HUB_PORT="24444" \
782786
# DOCKER_SOCK
783787
# Run docker from inside docker
784788
# Usage: docker run -v /var/run/docker.sock:/var/run/docker.sock
785-
# -v $(which docker):$(which docker)
789+
# -v $(which docker):/usr/bin/docker
786790
ENV FIREFOX_VERSION="${FF_VER}" \
787791
USE_SELENIUM="2" \
788792
CHROME_FLAVOR="stable" \
789793
PICK_ALL_RANDMON_PORTS="false" \
794+
RANDOM_PORT_FROM="23100" \
795+
RANDOM_PORT_TO="29999" \
790796
USER="seluser" \
791797
HOME="/home/seluser" \
792798
VNC_STORE_PWD_FILE="/home/seluser/.vnc/passwd" \

bin/entry.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -128,47 +128,47 @@ fi
128128

129129
# TODO: Remove this duplicated logic
130130
if [ "${SELENIUM_HUB_PORT}" = "0" ]; then
131-
export SELENIUM_HUB_PORT=$(get_unused_port)
131+
export SELENIUM_HUB_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
132132
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
133133
# User want to pick random ports but may also want to fix some others
134134
if [ "${SELENIUM_HUB_PORT}" = "${DEFAULT_SELENIUM_HUB_PORT}" ]; then
135-
export SELENIUM_HUB_PORT=$(get_unused_port)
135+
export SELENIUM_HUB_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
136136
fi
137137
fi
138138

139139
if [ "${SELENIUM_NODE_CH_PORT}" = "0" ]; then
140-
export SELENIUM_NODE_CH_PORT=$(get_unused_port)
140+
export SELENIUM_NODE_CH_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
141141
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
142142
# User want to pick random ports but may also want to fix some others
143143
if [ "${SELENIUM_NODE_CH_PORT}" = "${DEFAULT_SELENIUM_NODE_CH_PORT}" ]; then
144-
export SELENIUM_NODE_CH_PORT=$(get_unused_port)
144+
export SELENIUM_NODE_CH_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
145145
fi
146146
fi
147147

148148
if [ "${SELENIUM_NODE_FF_PORT}" = "0" ]; then
149-
export SELENIUM_NODE_FF_PORT=$(get_unused_port)
149+
export SELENIUM_NODE_FF_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
150150
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
151151
# User want to pick random ports but may also want to fix some others
152152
if [ "${SELENIUM_NODE_FF_PORT}" = "${DEFAULT_SELENIUM_NODE_FF_PORT}" ]; then
153-
export SELENIUM_NODE_FF_PORT=$(get_unused_port)
153+
export SELENIUM_NODE_FF_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
154154
fi
155155
fi
156156

157157
if [ "${SELENIUM_NODE_RC_CH_PORT}" = "0" ]; then
158-
export SELENIUM_NODE_RC_CH_PORT=$(get_unused_port)
158+
export SELENIUM_NODE_RC_CH_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
159159
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
160160
# User want to pick random ports but may also want to fix some others
161161
if [ "${SELENIUM_NODE_RC_CH_PORT}" = "${DEFAULT_SELENIUM_NODE_RC_CH_PORT}" ]; then
162-
export SELENIUM_NODE_RC_CH_PORT=$(get_unused_port)
162+
export SELENIUM_NODE_RC_CH_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
163163
fi
164164
fi
165165

166166
if [ "${SELENIUM_NODE_RC_FF_PORT}" = "0" ]; then
167-
export SELENIUM_NODE_RC_FF_PORT=$(get_unused_port)
167+
export SELENIUM_NODE_RC_FF_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
168168
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
169169
# User want to pick random ports but may also want to fix some others
170170
if [ "${SELENIUM_NODE_RC_FF_PORT}" = "${DEFAULT_SELENIUM_NODE_RC_FF_PORT}" ]; then
171-
export SELENIUM_NODE_RC_FF_PORT=$(get_unused_port)
171+
export SELENIUM_NODE_RC_FF_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
172172
fi
173173
fi
174174

@@ -199,11 +199,11 @@ if [ "${VNC_START}" = "true" ]; then
199199
export VNC_PORT=$(get_unused_port_from_range ${VNC_FROM_PORT} ${VNC_TO_PORT})
200200
else
201201
if [ "${VNC_PORT}" = "0" ]; then
202-
export VNC_PORT=$(get_unused_port)
202+
export VNC_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
203203
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
204204
# User want to pick random ports but may also want to fix some others
205205
if [ "${VNC_PORT}" = "${DEFAULT_VNC_PORT}" ]; then
206-
export VNC_PORT=$(get_unused_port)
206+
export VNC_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
207207
fi
208208
fi
209209
fi
@@ -213,29 +213,29 @@ fi
213213

214214

215215
if [ "${NOVNC_PORT}" = "0" ]; then
216-
export NOVNC_PORT=$(get_unused_port)
216+
export NOVNC_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
217217
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
218218
# User want to pick random ports but may also want to fix some others
219219
if [ "${NOVNC_PORT}" = "${DEFAULT_NOVNC_PORT}" ]; then
220-
export NOVNC_PORT=$(get_unused_port)
220+
export NOVNC_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
221221
fi
222222
fi
223223

224224
if [ "${SAUCE_LOCAL_SEL_PORT}" = "0" ]; then
225-
export SAUCE_LOCAL_SEL_PORT=$(get_unused_port)
225+
export SAUCE_LOCAL_SEL_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
226226
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
227227
# User want to pick random ports but may also want to fix some others
228228
if [ "${SAUCE_LOCAL_SEL_PORT}" = "${DEFAULT_SAUCE_LOCAL_SEL_PORT}" ]; then
229-
export SAUCE_LOCAL_SEL_PORT=$(get_unused_port)
229+
export SAUCE_LOCAL_SEL_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
230230
fi
231231
fi
232232

233233
if [ "${SUPERVISOR_HTTP_PORT}" = "0" ]; then
234-
export SUPERVISOR_HTTP_PORT=$(get_unused_port)
234+
export SUPERVISOR_HTTP_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
235235
elif [ "${PICK_ALL_RANDMON_PORTS}" = "true" ]; then
236236
# User want to pick random ports but may also want to fix some others
237237
if [ "${SUPERVISOR_HTTP_PORT}" = "${DEFAULT_SUPERVISOR_HTTP_PORT}" ]; then
238-
export SUPERVISOR_HTTP_PORT=$(get_unused_port)
238+
export SUPERVISOR_HTTP_PORT=$(get_unused_port_from_range ${RANDOM_PORT_FROM} ${RANDOM_PORT_TO})
239239
fi
240240
fi
241241

0 commit comments

Comments
 (0)