Skip to content

Commit 96ffe69

Browse files
authored
Merge pull request SeleniumHQ#778 from anto-ac/issue-772-cannot-open-display
Find free xvfb display instead of hardcoded 99 using the -a option
2 parents f0c5ad4 + 8fdb929 commit 96ffe69

File tree

9 files changed

+16
-104
lines changed

9 files changed

+16
-104
lines changed

Makefile

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,7 @@ release: tag_major_minor
211211
docker push $(NAME)/standalone-chrome-debug:$(MAJOR_MINOR_PATCH)
212212
docker push $(NAME)/standalone-firefox-debug:$(MAJOR_MINOR_PATCH)
213213

214-
test: test_shell_functions \
215-
test_chrome \
214+
test: test_chrome \
216215
test_firefox \
217216
test_chrome_debug \
218217
test_firefox_debug \
@@ -222,9 +221,6 @@ test: test_shell_functions \
222221
test_firefox_standalone_debug
223222

224223

225-
test_shell_functions:
226-
./tests/test-shell-functions.sh
227-
228224
test_chrome:
229225
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeChrome
230226

NodeBase/Dockerfile.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,17 +72,14 @@ USER seluser
7272
#==============================
7373
# Scripts to run Selenium Node
7474
#==============================
75-
COPY entry_point.sh \
76-
functions.sh \
77-
/opt/bin/
75+
COPY entry_point.sh /opt/bin/
7876

7977
#============================
8078
# Some configuration options
8179
#============================
8280
ENV SCREEN_WIDTH 1360
8381
ENV SCREEN_HEIGHT 1020
8482
ENV SCREEN_DEPTH 24
85-
ENV DISPLAY :99.0
8683

8784
#========================
8885
# Selenium Configuration

NodeBase/entry_point.sh

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

3-
source /opt/bin/functions.sh
43
/opt/bin/generate_config > /opt/selenium/config.json
54

65
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
@@ -42,11 +41,9 @@ if [ ! -z "$SE_OPTS" ]; then
4241
echo "appending selenium options: ${SE_OPTS}"
4342
fi
4443

45-
SERVERNUM=$(get_server_num)
46-
4744
rm -f /tmp/.X*lock
4845

49-
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
46+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
5047
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
5148
-role node \
5249
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \

NodeBase/functions.sh

Lines changed: 0 additions & 6 deletions
This file was deleted.

NodeBase/test-functions.sh

Lines changed: 0 additions & 52 deletions
This file was deleted.

NodeDebug/entry_point.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
#
33
# IMPORTANT: Change this file only in directory NodeDebug!
44

5-
source /opt/bin/functions.sh
65
/opt/bin/generate_config > /opt/selenium/config.json
76

87
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
@@ -51,12 +50,9 @@ if [ ! -z "$SE_OPTS" ]; then
5150
echo "appending selenium options: ${SE_OPTS}"
5251
fi
5352

54-
SERVERNUM=$(get_server_num)
55-
5653
rm -f /tmp/.X*lock
5754

58-
DISPLAY=$DISPLAY \
59-
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
55+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
6056
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
6157
-role node \
6258
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
@@ -68,6 +64,11 @@ NODE_PID=$!
6864
trap shutdown SIGTERM SIGINT
6965
for i in $(seq 1 10)
7066
do
67+
DISPLAY=$(xvfb-run printenv DISPLAY)
68+
if [ -z "$DISPLAY" ]; then
69+
echo "\$DISPLAY env variable is empty"
70+
break
71+
fi
7172
xdpyinfo -display $DISPLAY >/dev/null 2>&1
7273
if [ $? -eq 0 ]; then
7374
break

Standalone/entry_point.sh

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

5-
source /opt/bin/functions.sh
6-
75
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
86

97
function shutdown {
@@ -15,11 +13,9 @@ if [ ! -z "$SE_OPTS" ]; then
1513
echo "appending selenium options: ${SE_OPTS}"
1614
fi
1715

18-
SERVERNUM=$(get_server_num)
19-
2016
rm -f /tmp/.X*lock
2117

22-
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
18+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
2319
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
2420
${SE_OPTS} &
2521
NODE_PID=$!

StandaloneDebug/entry_point.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#
33
# IMPORTANT: Change this file only in directory StandaloneDebug!
44

5-
source /opt/bin/functions.sh
6-
75
export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"
86

97
function shutdown {
@@ -24,17 +22,19 @@ fi
2422

2523
rm -f /tmp/.X*lock
2624

27-
SERVERNUM=$(get_server_num)
28-
29-
DISPLAY=$DISPLAY \
30-
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
25+
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
3126
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
3227
${SE_OPTS} &
3328
NODE_PID=$!
3429

3530
trap shutdown SIGTERM SIGINT
3631
for i in $(seq 1 10)
3732
do
33+
DISPLAY=$(xvfb-run printenv DISPLAY)
34+
if [ -z "$DISPLAY" ]; then
35+
echo "\$DISPLAY env variable is empty"
36+
break
37+
fi
3838
xdpyinfo -display $DISPLAY >/dev/null 2>&1
3939
if [ $? -eq 0 ]; then
4040
break

tests/test-shell-functions.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)