OpenStack Integration Test Suite Guide
Introduction to the OpenStack Integration Test Suite
Abstract
Preface Copy linkLink copied to clipboard!
This guide provides instructions to install, configure and manage the OpenStack Integration Test Suite in a Red Hat OpenStack Platform environment.
Chapter 1. Introduction Copy linkLink copied to clipboard!
As OpenStack consists of many different projects, it is important to test their interoperability within your OpenStack cluster. The OpenStack Integration Test Suite (tempest) automates the integration testing of your Red Hat OpenStack Platform deployment. Running tests ensures your cluster is working as expected, and can also provide early warning of potential problems, especially after an upgrade. The Integration Test Suite contains tests for OpenStack API validation and scenario testing, as well as unit testing for self-validation. It performs black box testing using the OpenStack public APIs, with ostestr as the test runner.
Chapter 2. OpenStack Integration Test Suite Tests Copy linkLink copied to clipboard!
The OpenStack Integration Test Suite has many applications. It acts as a gate for commits to the OpenStack core projects, it can stress test to generate load on a cloud deployment, and it can perform CLI tests to check the response formatting of the command line. However, the functionality that we are concerned with are the scenario tests and API tests. These tests are run against your OpenStack cloud deployment. The following sections briefly describe each of these tests and how you can implement them.
2.1. Scenario Tests Copy linkLink copied to clipboard!
Scenario tests simulate a typical end user action workflow to test the integration points between services. The testing framework conducts the set up, tests the integration between services, and then it is torn down. You should tag the tests with which services they relate to, to make it clear which client libraries the test uses. A scenario is based on a use case, for example:
- Upload an image to the Image Service
- Deploy an instance from the image
- Attach a volume to the instance
- Create a snapshot of the instance
- Detach the volume from the instance
2.2. API Tests Copy linkLink copied to clipboard!
API tests validate the OpenStack API. Tests use the OpenStack Integration Test Suite implementation of the OpenStack API. Both valid and invalid JSON can be used to make sure error responses are valid. Tests can be run independently, and do not rely on the state left by the previous test.
Chapter 3. Installing the OpenStack Integration Test Suite Copy linkLink copied to clipboard!
This section describes how to install the OpenStack Integration Test Suite using either the director or a manual installation.
3.1. Using the Director Copy linkLink copied to clipboard!
Edit /home/stack/undercloud.conf. By default, enable_tempest is set to false. Change this to true:
enable_tempest = true
You are now ready to install the tempest packages and plug-ins, described in Section 3.3, “Installing the OpenStack Integration Test Suite Packages”.
3.2. Preparing a Manual Installation Copy linkLink copied to clipboard!
To run the OpenStack Integration Test Suite, you need to first install the necessary packages and create a configuration file that will tell the Integration Test Suite where to find the various OpenStack services and other testing behaviour switches.
On the controller node, as a root user, create a virtual machine named tempest. This machine must run Red Hat Enterprise Linux 7.3 or greater; it also needs to be able to reach the cloud, but it does not have to be part of the cloud. For more information, see Creating Guests with Virt-Manager.
In addition, before installing the OpenStack Integration Test Suite, the following networks are required within your Red Hat OpenStack Platform environment:
- An external network that can provide a floating IP address.
- A private network.
These networks must be connected through a router.
Create the private network:
$ openstack network create _<network_name>_ --share $ openstack subnet create _<subnet_name>_ --subnet-range _<address/prefix>_ $ openstack router create _<router_name>_ $ openstack router add subnet _<router_name>_ _<subnet_name>_ --network _<network_name>_Create the public network:
$ openstack network create _<network_name>_ --external \ --provider-network-type flat $ openstack subnet create _<subnet_name>_ --subnet-range _<address/prefix>_ \ --gateway _<default_gateway>_ --no-dhcp --network _<network_name>_ $ openstack router set _<router_name>_ --external_gateway _<public_network_name>_ $ neutron router-gateway-set _<router_name>_ _<network_name>_
Create the required keystone roles:
$ openstack role create swiftoperator $ openstack role create heat_stack_owner
You are now ready to install and configure the OpenStack Integration Test Suite within the tempest virtual machine. For more information, see Section 3.3, “Installing the OpenStack Integration Test Suite Packages”.
3.3. Installing the OpenStack Integration Test Suite Packages Copy linkLink copied to clipboard!
Install the packages related to the OpenStack Integration Test Suite:
$ sudo yum install openstack-tempestHowever, this command will not install any tempest plug-ins. These are installed manually in the following steps, depending on your OpenStack installation:
Install the appropriate tempest plug-in for each component you have, separated by spaces, in the following format:
$ sudo yum install <component1> <component2> <component3>You can list multiple components in the same command.
Or:
$ sudo python /usr/share/openstack-tempest-13.0.0/tools/install_test_packages.pyReview the list of installed plugins:
$ tempest list-pluginsSee Section 3.3.1, “List of Tempest Plug-in Packages” for a list of available tempest plug-ins for each OpenStack component.
3.3.1. List of Tempest Plug-in Packages Copy linkLink copied to clipboard!
| Component | Package Name |
|---|---|
| aodh | python-aodh-tests |
| ceilometer | python-ceilometer-tests |
| cinder | python-cinder-tests |
| designate | python-designate-tests-tempest |
| gnocchi | python-gnocchi-tests Note To ensure that the Gnocchi component installs correctly, install python-gnocchi-tests. |
| heat | python-heat-tests |
| horizon | python-horizon-tests-tempest |
| ironic | python-ironic-tests |
| keystone | python-keystone-tests |
| manila | python-manila-tests |
| mistral | python-mistral-tests |
| neutron | python-neutron-tests |
| neutron-fwaas | python-neutron-fwaas-tests |
| neutron-lbaas | python-neutron-lbaas-tests |
| neutron-vpnaas | python-neutron-vpnaas-tests |
| sahara | python-sahara-tests-tempest |
| zaqar | python-zaqar-tests |
nova, swift, and glance do not have individual test plugins; their tests reside within the tempest package.
Chapter 4. Configuring the OpenStack Integration Test Suite Copy linkLink copied to clipboard!
4.1. Creating a Workspace Copy linkLink copied to clipboard!
Source the admin credentials:
In the undercloud:
$ source stackrcOr in the overcloud:
$ source overcloudrc
Initialize tempest:
$ cd ~ $ mkdir mytempest $ cd mytempest $ /usr/share/openstack-tempest-13.0.0/tools/configure-tempest-directoryThis creates a tempest workspace named
mytempestfor your user account.Generate the
etc/tempest.conffile:$ python tools/config_tempest.py --deployer-input ~/tempest-deployer-input.conf --debug --create identity.uri $OS_AUTH_URL identity.admin_password $OS_PASSWORD --network-id _<uuid>_uuidis the UUID of the external network.NoteFor offline systems, you can specify an existing glance image by adding the
--imageparameter. For example:--image cirros-0.3.4-x86_64-disk.img
You can view a list of existing workspaces:
$ tempest workspace list
4.2. Verifying Your Tempest Configuration Copy linkLink copied to clipboard!
Generate the
.testr.confin your tempest workspace:$ testr initVerify your current tempest configuration, specifying the tempest.conf file that was just generated:
$ tempest verify-config -o ~/mytempest/etc/tempest.conf
4.3. Changing the Logging Configuration Copy linkLink copied to clipboard!
The default location for log files is the logs directory within your tempest workspace.
To change this directory, in
~/mytempest/etc/tempest.conf, under the[DEFAULT]section, setlog_dirto the desired directory:[DEFAULT] log_dir = _<directory>_If you have your own logging configuration file, in
~/mytempest/etc/tempest.conf, under the[DEFAULT]section, setlog_config_appendto your file:[DEFAULT] log_config_append = _<file>_
If this is set, all other logging configuration in tempest.conf will be ignored, including log_dir.
4.4. Configuring Microversion Tests Copy linkLink copied to clipboard!
The OpenStack Integration Test Suite provides stable interfaces to test the API microversions. This section describes how to implement microversion tests using these interfaces. You first need to configure options in the tempest.conf configuration file to specify the target microversions. This is to make sure that the supported microversions match the microversions used in the OpenStack cloud. You can run multiple microversion tests in a single Integration Test Suite operation by specifying a range of target microversions.
For example, to limit the range of microversions for the compute service, in the [compute] section of your configuration file, assign values to the min_microversion and max_microversion parameters:
[compute]
min_microversion = 2.14
max_microversion = latest
Chapter 5. Using ostestr to Run Tempest Copy linkLink copied to clipboard!
Ostestr is an OpenStack wrapper for the testr test runner.
You can view a list of the available tests:
$ ostestr -lNoteBefore running tests, you can use
tempest cleanup --init-saved-stateto capture the current state. This will make cleanup easier. For more information see Chapter 6, Cleaning Tempest Resources.You can run specific tests using
ostestr.To run just one test, use:
ostestr --regex '(test_regex)'To run multiple tests:
ostestr --regex '(test1|test2|test3)'
5.1. Running Smoke Tests Copy linkLink copied to clipboard!
Smoke testing is a type of preliminary testing which only covers the most important functionality. While they are not comprehensive, running smoke tests can save time if they do identify a problem.
To run the smoke tests:
$ ostestr --regex '(.*smoke)'
5.2. Running Specific Tests Using Whitelist Files Copy linkLink copied to clipboard!
A whitelist file contains specific tests to include.
Create a
whitelist.txtfile in your tempest workspace:$ touch whitelist.txtAppend all the tests you want to run to the
whitelist.txtfile:$ cat whitelist.txt keystone_tempest_plugin.* networking_bgpvpn_tempest.tests*Run those tests using
ostestr:$ ostestr -w <path to whitelist tests file>
5.3. Skipping Tests Using Blacklist Files Copy linkLink copied to clipboard!
A blacklist file contains a list of tests to exclude.
Create a
skip_test.txtfile in your tempest workspace:$ touch skip_test.txtAppend all the tests to skip to the
skip_test.txtfile.$ cat skip_test.txt keystone_tempest_plugin.* networking_bgpvpn_tempest.tests*Run tests using
ostestr:$ ostestr -b <path to skip test file>You can run specific tests by skipping the listed tests:
ostestr --regex '(tempest.api.object_storage) -b <path to skip test file>
5.4. Running Tests in Parallel Concurrently, or Serially Copy linkLink copied to clipboard!
Run the tests in series:
$ ostestr --serialRun the tests in parallel (this is the default):
$ ostestr --parallelSpecify the number of workers to use when running tests in parallel:
$ ostestr --concurrency _<workers>_Alternatively:
$ ostestr -c _<workers>_By default, this is set to the number of CPUs.
Chapter 6. Cleaning Tempest Resources Copy linkLink copied to clipboard!
After running tempest, there will be files, users and tenants created in the testing process that need to be deleted. The ability to self-clean is one of the design principles of tempest.
6.1. Performing a Clean Up Copy linkLink copied to clipboard!
First you must initialize the saved state. This creates the file saved_state.json, which prevents the cleanup from deleting objects that need to be kept. Typically you would run cleanup with --init-saved-state prior to a tempest run. If this is not the case, saved_state.json must be edited to remove objects you want cleanup to delete.
$ tempest cleanup --init-saved-state
Run the cleanup:
$ tempest cleanup
6.2. Performing a Dry Run Copy linkLink copied to clipboard!
A dry run lists the files that would be deleted by a cleanup, but does not delete any files. The files are listed in the dry_run.json file.
$ tempest cleanup --dry-run
6.3. Deleting Tempest Objects Copy linkLink copied to clipboard!
Delete users and tenants created by tempest:
$ tempest cleanup --delete-tempest-conf-objects