1

I'm trying to run some headless robot/Selenium tests via Elastic Bamboo using Xvfb, on Ubuntu 15.04 in AWS EC2. It works if I run Xvfb manually and then run the test...

export display=:99
Xvfb :99 -screen 0 1024x768x24 -nolisten tcp -ac &
pybot --nostatusrc --variablefile variables/vars.py -e TBD -e broken -x xunit -d reports/ tests/
<test output appears>

But I want to use the provided xvfb-run script so I can run a bunch of tests in parallel and have them use different displays. When I run it via xvfb-run however it hangs, no output, never terminates.

xvfb-run -a -e /dev/stdout --nostatusrc --variablefile variables/vars.py -e TBD -e broken -x xunit -d reports/ tests/
<hangs>

In the /usr/bin/xvfb-run script this is the core of the functionality:

# Start Xvfb.
MCOOKIE=$(mcookie)
tries=10
while [ $tries -gt 0 ]; do
    tries=$(( $tries - 1 ))
    XAUTHORITY=$AUTHFILE xauth source - << EOF >>"$ERRORFILE" 2>&1
add :$SERVERNUM $XAUTHPROTO $MCOOKIE
EOF
    # handle SIGUSR1 so Xvfb knows to send a signal when it's ready to accept
    # connections
    trap : USR1
    (trap '' USR1; exec Xvfb ":$SERVERNUM" $XVFBARGS $LISTENTCP -auth $AUTHFILE >>"$ERRORFILE" 2>&1) &
    XVFBPID=$!
    wait || :
    if kill -0 $XVFBPID 2>/dev/null; then
        break
    elif [ -n "$AUTONUM" ]; then
        # The display is in use so try another one (if '-a' was specified).
        SERVERNUM=$((SERVERNUM + 1))
        SERVERNUM=$(find_free_servernum)
        continue
    fi
    error "Xvfb failed to start" >&2
    XVFBPID=
    exit 1
done

Nothing shows up in stdout (or a log if I set it to a file). So I edited xvfb-run to set -x, and what happens is the script gets to the exec then hangs:

...
16-Nov-2015 14:36:52    + xauth source -
16-Nov-2015 14:36:52    + trap : USR1
16-Nov-2015 14:36:52    + XVFBPID=6123
16-Nov-2015 14:36:52    + wait
16-Nov-2015 14:36:52    + trap '' USR1
16-Nov-2015 14:36:52    + exec Xvfb :99 -screen 0 640x480x8 -nolisten tcp -auth /tmp/xvfb-run.js9dgH/Xauthority
<hangs here>

From looking more into it, it's getting to the "wait", and is expecting the child to send back a SIGUSR1 to proceed, but it's either never getting sent from Xvfb or not getting received correctly by the shell.

Anyone have a line on what the issue could be?

It works on Ubuntu 15.10 desktop in VirtualBox, Ubuntu 15.10 server in VirtualBox, and the stock Canonical Ubuntu AMI (ami-3ad5af50) in EC2 so it has to be something specific to the Atlassian configured Ubuntu AMI, but I can't figure out what... I manually upgraded an instance off their AMI to 15.10 but that didn't clear it up.

1 Answer 1

0

Ah, never mind, I finally found the problem - Atlassian had added a Xvfb wrapper script of their own (/usr/local/bin/Xvfb) that was blocking the signal send. For anyone who has this issue in the future, check and see if Xvfb is being executed directly or via a wrapper, and if it's a wrapper it will break xvfb-run.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .