How to Install and Run Tempest

Prerequisites 

Before beginning you will need an OpenStack deployment. Login to the undercloud (stack@undercloud-0) and run the following commands to install all necessary dependencies:

$ sudo yum -y install git && sudo yum -y install wget
$ sudo yum group install -y 'Development Tools'
$ sudo yum -y install python-devel sshpass
$ sudo yum -y install gcc git libffi-devel libxml2-devel libxslt-devel mariadb-devel openssl-devel python-pip‍‍‍‍‍‍‍‍

Setting Up Pip and the Virtual Environment

This step will set up pip and a virtual environment to be used for your Tempest runs. If you don’t already have pip installed on your undercloud, you can get it with the following command:

$ sudo curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py;python get-pip.py‍‍

Now you are ready to install the virtualenv package and actually stand up a virtual environment:

$ pip install virtualenv
$ source .venv/bin/activate‍‍‍‍

You will also need the junitxml package; you can get this via pip as well:

(.venv) $ pip install junitxml‍‍

Installing Tempest

Now that all relevant dependencies are installed and your virtual environment is up and running, it’s time to actually install Tempest. 

(.venv) $ git clone http://git.openstack.org/openstack/tempest
(.venv) $ cd tempest
(.venv) $ pip install -U pip
(.venv) $ cd ..‍‍‍‍‍‍‍‍

Installing external Tempest plugins (optional)

You may want to include some external Tempest plugins as part of your runs. If that is the case, you can install them by emulating the following steps:

(.venv) $ git clone <your plugin repo URL>
(.venv) $ cd <your plugin repo>
(.venv) $ pip install --upgrade -e .
(.venv) $ cd ..‍‍‍‍‍‍‍‍

To verify your plugin was installed and discovered by Tempest, run the following command - you should see your plugin listed:

(.venv) $ pip list | grep -i <your plugin name>‍‍

Repeat the above steps for each internal plugin you wish to install.

Configuring Tempest

Tempest is now installed, but we can’t actually run it until it has been configured - this is done by editing /etc/tempest.conf. This can be done manually, but it is recommended you use python-tempestconf to do so:

(NOTE: This will not work for Newton - you must configure tempest.conf manually for Newton or below)

(.venv) $ git clone https://git.openstack.org/openstack/python-tempestconf
(.venv) $ cd python-tempestconf
(.venv) $ pip install .
(.venv) $ . ~/overcloudrc‍‍‍‍‍‍‍‍

The actually configuration command can be done many different ways (see the python-tempestconf documentation for more info); this is the simplest implementation and should work for basic deployments:

(overcloud) (.venv) $ python config_tempest/main.py --create --debug identity.uri $OS_AUTH_URL identity.admin_password $OS_PASSWORD identity.region regionOne‍‍

Lastly, move the generated tempest.conf file to /etc/tempest.conf to override the empty one generated by your Tempest installation:

(overcloud) (.venv) $ mv etc/tempest.conf /etc/tempest‍‍

Running Tempest

Finally, you are ready to run Tempest! Return to the tempest directory and run Tempest with stestr (see the stestr documentation for more info):

(overcloud) (.venv) $ cd tempest
(overcloud) (.venv) $ stestr run‍‍‍‍

Special thanks to Eran Kuris and Mike Abrams who made writing this article possible