Robottelo is a test suite which exercises The Foreman. All tests are automated, suited for use in a continuous integration environment, and data driven. There are three types of tests:
- UI tests, which rely on Selenium's WebDriver.
- CLI tests, which rely on Paramiko.
- API tests, which rely on Requests.
The following is only a brief setup guide for Robottelo. More extensive documentation is available at Read the Docs.
Install Python header files. The package providing these files varies per distribution. For example:
- Fedora 20 provides header files in the python-devel package.
- Ubuntu 14.04 provides header files in the python-dev package.
Get the source code and install dependencies:
$ git clone git://github.com/omaciel/robottelo.git $ pip install -r requirements.txt
That's it! You can now go ahead and start testing The Foreman. However, there are a few other things you may wish to do before continuing:
- You may want to install development tools (such as gcc) for your OS. If
running Fedora or Red Hat Enterprise Linux, execute
yum groupinstall "Development Tools"
. - You may wish to install the optional dependencies listed in
requirements-optional.txt
. (Use pip, as shown above.) They are required for tasks like working with certificates, running the internal robottelo test suite and checking code quality with pylint.
Before running any tests, you must create a configuration file:
$ cp robottelo.properties.sample robottelo.properties $ vi robottelo.properties
That done, you can run tests using make
:
$ make test-robottelo $ make test-docstrings $ make test-foreman-api $ make test-foreman-cli $ make test-foreman-ui
If you want to run the test suite without the aid of make
, you can do that
with either unittest or nose:
$ python -m unittest discover -s tests -t . $ nosetests -c robottelo.properties
The following sections discuss, in detail, how to update the configuration file and run tests directly.
To configure Robottelo, create a file named robottelo.properties
. You can
use the robottelo.properties.sample
file as a starting point. Then, edit the
configuration file so that at least the following attributes are set:
server.hostname=[FULLY QUALIFIED DOMAIN NAME] server.ssh.key_private=[PATH TO YOUR SSH KEY] server.ssh.username=root project=foreman locale=en_US remote=0 [foreman] admin.username=admin admin.password=changeme
Note that you only need to configure the SSH key if you want to run CLI tests. There are other settings to configure what web browser to use for UI tests and even configuration to run the automation using SauceLabs. For more information about what web browsers you can use, check Selenium's WebDriver documentation.
To run all tests:
$ python -m unittest discover \ --start-directory tests/ \ --top-level-directory .
It is possible to run a specific subset of tests:
$ python -m unittest tests.robottelo.test_decorators $ python -m unittest tests.robottelo.test_decorators.DataDecoratorTestCase $ python -m unittest tests.robottelo.test_decorators.DataDecoratorTestCase.test_data_decorator_smoke
To get more verbose output, or run multiple tests:
$ python -m unittest discover -s tests/ -t . -v $ python -m unittest \ tests.robottelo.test_decorators \ tests.robottelo.test_cli
To test The Foreman's API, CLI or UI, use the following commands respectively:
$ python -m unittest discover -s tests/foreman/api/ $ python -m unittest discover -s tests/foreman/cli/ $ python -m unittest discover -s tests/foreman/ui/
For more information about Python's unittest module, read the documentation.
You must have nose installed to execute the nosetests
command.
To run all tests:
$ nosetests -c robottelo.properties
It is possible to run a specific subset of tests:
$ nosetests -c robottelo.properties tests.robottelo.test_decorators $ nosetests -c robottelo.properties tests.robottelo.test_decorators:DataDecoratorTestCase $ nosetests -c robottelo.properties tests.robottelo.test_decorators:DataDecoratorTestCase.test_data_decorator_smoke
To get more verbose output, or run multiple tests:
$ nosetests -c robottelo.properties -v $ nosetests -c robottelo.properties \ tests.robottelo.test_decorators \ tests.robottelo.test_cli
To test The Foreman's API, CLI or UI, use the following commands respectively:
$ nosetests -c robottelo.properties tests.foreman.api $ nosetests -c robottelo.properties tests.foreman.cli $ nosetests -c robottelo.properties tests.foreman.ui
Many of the existing tests use the DDT module to allow for a more data-driven
methodology and in order to run a specific test you need override the way
nosetests
discovers test names. For instance, if you wanted to run only the
test_positive_create_1
data-driven tests for the foreman.cli.test_org
module:
$ nosetests -c robottelo.properties -m test_positive_create_1 \ tests.foreman.cli.test_org
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.
If you are looking for information on a specific function, class or method, this part of the documentation is for you. The following is an overview of the topics covered by the API. For more granular information, follow one of the links.
.. toctree:: :maxdepth: 2 api/index
Bugs are listed on GitHub. If you think you've found a new issue, please do one of the following:
- Open a new bug report on Github.
- Join the #robottelo IRC channel on Freenode (irc.freenode.net).
You can generate the documentation for Robottelo as follows, so long as you have Sphinx and make installed:
$ cd docs $ make html
You can generate a graph of Foreman entities and their dependencies, so long as you have graphviz installed:
$ make graph-entities
To check for code smells:
$ ./lint.py | less
The design and development for this software is led by Og Maciel.