Skip to content

Commit

Permalink
Add feature to run UI in headless mode
Browse files Browse the repository at this point in the history
By configuring virtual_display=1 in properties file, robottelo will use
a virtual display to run UI tests using PyVirtualDisplay package and
Xvfb.
  • Loading branch information
elyezer committed Aug 22, 2014
1 parent 6edd6a2 commit f5ecbd8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,23 @@ module::
$ nosetests -c robottelo.properties -m test_positive_create_1 \
tests.foreman.cli.test_org

Running UI tests in a headless server
-------------------------------------

If you want to run UI test suite in a headless server, like a continuous
integration server you will need to set ``virtual_display=1`` on properties
file and also install ``PyVirtualDisplay`` package (this package will be
already installed if you have installed the ``requirements-optional``).
``PyVirtualDisplay`` uses Xvfb to create a virtual display, so you will need to
install Xvfb, you can install on a yum based distro by running::

# yum install xorg-x11-server-Xvfb

With the initial configuration in place, now every time that an UI test runs it
will not pop any browser window if run in a desktop or will be able to run in a
headless server. Also this setup allows you to just run ``make
test-foreman-ui`` in order to run the entire UI test suite.

API Reference
=============

Expand Down
4 changes: 4 additions & 0 deletions requirements-optional.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ sphinx

# ???
nose_xunitmp

# For running UI tests in a headless mode
# PyVirtualDisplay requires xvfb
PyVirtualDisplay
4 changes: 4 additions & 0 deletions robottelo.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ locale=en_US
remote=0
smoke=0

# Virtual display controls if PyVirtualDisplay should be used to run UI tests
# when setting it to 1 then make sure to install required dependencies
virtual_display=0

[foreman]
admin.username=admin
admin.password=changeme
Expand Down
14 changes: 14 additions & 0 deletions robottelo/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import unittest
else:
import unittest2 as unittest

from robottelo.cli.metatest import MetaCLITest
from robottelo.common.helpers import get_server_url
from robottelo.common import conf
Expand Down Expand Up @@ -115,6 +116,14 @@ def setUpClass(cls):
cls.verbosity = int(conf.properties['nosetests.verbosity'])
cls.remote = int(conf.properties['main.remote'])

if int(conf.properties.get('main.virtual_display', '0')):
# Importing here because PyVirtualDisplay is optional
from pyvirtualdisplay import Display
cls.display = Display(size=(1024, 768))
cls.display.start()
else:
cls.display = None

def setUp(self):
"""
We do want a new browser instance for every test.
Expand Down Expand Up @@ -183,6 +192,11 @@ def tearDown(self):
self.browser.quit()
self.browser = None

@classmethod
def tearDownClass(cls):
if cls.display is not None:
cls.display.stop()


def assert_instance_intersects(first, other):
"""Determines if first and other match in type
Expand Down

0 comments on commit f5ecbd8

Please sign in to comment.