3. Check out
pyvirtualdisplayas a way of controlling virtual displays from Python.
I would look into using headless browsers as a “dev-only” tool, to
speed up the running of FTs on the developer’s machine, while the
tests on the CI server use actual browsers.
The alternative is to set up a virtual display: we get the server to pretend it has a screen
attached to it, so Firefox runs happily. There’s a few tools out there to do this; we’ll use
one called “Xvfb” (X Virtual Framebuffer)
3
because it’s easy to install and use, and be‐
cause it has a convenient Jenkins plugin.
We go back to our project and hit “Configure” again, then find the section called “Build
Environment”. Using the virtual display is as simple as ticking the box marked “Start
Xvfb before the build, and shut it down after,” as in
Figure 20-8.
Figure 20-8. Sometimes config is easy
The build does much better now:
[...]
Xvfb starting$ /usr/bin/Xvfb :2 -screen 0 1024x768x24 -fbdir
/var/lib/jenkins/2013-11-04_03-27-221510012427739470928xvfb
[...]
+ python manage.py test lists accounts
...................................................
---------------------------------------------------------------------
Ran 51 tests in 0.410s
OK
Creating test database for alias 'default'...
Destroying test database for alias 'default'...
+ pip install selenium
Requirement already satisfied (use --upgrade to upgrade): selenium in
/var/lib/jenkins/shiningpanda/jobs/ddc1aed1/virtualenvs/d41d8cd9/lib/python3.3/site-packages
Setting Up a Virtual Display so the FTs Can Run Headless
|
373