Skip to content

Commit

Permalink
Find free xvfb display instead of hardcoded 99 using the -a option
Browse files Browse the repository at this point in the history
Up until now the xvfb display has been hardcoded to 99 for all nodes.
This sometimes causes errors if the display is not actually free.
xvfb-run has a -a --auto-servernum option, which tries to get a free
server number, starting at 99, or the argument to --server-num.

Fixes #772
  • Loading branch information
Antonello Caboni committed Aug 30, 2018
1 parent f0c5ad4 commit 8fdb929
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 104 deletions.
6 changes: 1 addition & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ release: tag_major_minor
docker push $(NAME)/standalone-chrome-debug:$(MAJOR_MINOR_PATCH)
docker push $(NAME)/standalone-firefox-debug:$(MAJOR_MINOR_PATCH)

test: test_shell_functions \
test_chrome \
test: test_chrome \
test_firefox \
test_chrome_debug \
test_firefox_debug \
Expand All @@ -222,9 +221,6 @@ test: test_shell_functions \
test_firefox_standalone_debug


test_shell_functions:
./tests/test-shell-functions.sh

test_chrome:
VERSION=$(VERSION) NAMESPACE=$(NAMESPACE) ./tests/bootstrap.sh NodeChrome

Expand Down
5 changes: 1 addition & 4 deletions NodeBase/Dockerfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,14 @@ USER seluser
#==============================
# Scripts to run Selenium Node
#==============================
COPY entry_point.sh \
functions.sh \
/opt/bin/
COPY entry_point.sh /opt/bin/

#============================
# Some configuration options
#============================
ENV SCREEN_WIDTH 1360
ENV SCREEN_HEIGHT 1020
ENV SCREEN_DEPTH 24
ENV DISPLAY :99.0

#========================
# Selenium Configuration
Expand Down
5 changes: 1 addition & 4 deletions NodeBase/entry_point.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#!/bin/bash

source /opt/bin/functions.sh
/opt/bin/generate_config > /opt/selenium/config.json

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

SERVERNUM=$(get_server_num)

rm -f /tmp/.X*lock

xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
-role node \
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
Expand Down
6 changes: 0 additions & 6 deletions NodeBase/functions.sh

This file was deleted.

52 changes: 0 additions & 52 deletions NodeBase/test-functions.sh

This file was deleted.

11 changes: 6 additions & 5 deletions NodeDebug/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#
# IMPORTANT: Change this file only in directory NodeDebug!

source /opt/bin/functions.sh
/opt/bin/generate_config > /opt/selenium/config.json

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

SERVERNUM=$(get_server_num)

rm -f /tmp/.X*lock

DISPLAY=$DISPLAY \
xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
-role node \
-hub http://$HUB_PORT_4444_TCP_ADDR:$HUB_PORT_4444_TCP_PORT/grid/register \
Expand All @@ -68,6 +64,11 @@ NODE_PID=$!
trap shutdown SIGTERM SIGINT
for i in $(seq 1 10)
do
DISPLAY=$(xvfb-run printenv DISPLAY)
if [ -z "$DISPLAY" ]; then
echo "\$DISPLAY env variable is empty"
break
fi
xdpyinfo -display $DISPLAY >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
Expand Down
6 changes: 1 addition & 5 deletions Standalone/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# IMPORTANT: Change this file only in directory Standalone!

source /opt/bin/functions.sh

export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

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

SERVERNUM=$(get_server_num)

rm -f /tmp/.X*lock

xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
xvfb-run -a --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
${SE_OPTS} &
NODE_PID=$!
Expand Down
12 changes: 6 additions & 6 deletions StandaloneDebug/entry_point.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
#
# IMPORTANT: Change this file only in directory StandaloneDebug!

source /opt/bin/functions.sh

export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

function shutdown {
Expand All @@ -24,17 +22,19 @@ fi

rm -f /tmp/.X*lock

SERVERNUM=$(get_server_num)

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

trap shutdown SIGTERM SIGINT
for i in $(seq 1 10)
do
DISPLAY=$(xvfb-run printenv DISPLAY)
if [ -z "$DISPLAY" ]; then
echo "\$DISPLAY env variable is empty"
break
fi
xdpyinfo -display $DISPLAY >/dev/null 2>&1
if [ $? -eq 0 ]; then
break
Expand Down
17 changes: 0 additions & 17 deletions tests/test-shell-functions.sh

This file was deleted.

0 comments on commit 8fdb929

Please sign in to comment.