Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running py.test with xvfb-run

I am trying to run tests in Jenkins for a Python package which uses PyQt4, and the tests create windows. Since I'm running the tests in Jenkins, I need to redirect the graphical output, so I'm using xvfb-run. Most of the time, this works, but a fraction of the time, the testing will randomly fail with:

/usr/bin/xvfb-run: line 171: kill: (27375) - No such process

If I re-run the tests, it works fine most of the time (so it's just a one-off problem).

Has anyone encountered this issue before? Do you have any ideas for workarounds to improve the stability of the testing?

like image 998
astrofrog Avatar asked Oct 07 '22 11:10

astrofrog


2 Answers

It work through find the Xvfb process and kill it.

ps auwx | grep "Xvfb" | grep -v grep
like image 90
kqqsysu Avatar answered Oct 09 '22 02:10

kqqsysu


If your copy of xvfb-run is the same as mine, I can confirm I've seen this too.

In my case, the target process caused Xvfb to crash. This means that the wrapper script itself fails at line 171 when tearing down no longer running Xvfb. To work around it I wrapped kill $XVFBPID in a set +e/set -e block. It also helps if you specify --error-file= so that xvfb-run saves the asynchronous standard error output from Xvfb while your target process is running, so you can get the underlying cause fixed.

Work around:

# Kill Xvfb now that the command has exited.
# Ignore failure of kill since we want to be forgiving of Xvfb itself crashing
set +e
kill $XVFBPID
set -e
like image 41
shuckc Avatar answered Oct 09 '22 02:10

shuckc