Installing, Configuring and Running Tempest tests against Openstack

The intent of this article is to give detailed information about how to install and configure tempest and run tempest tests. Tempest is the integration test suit of Openstack which is responsible for validating a stack. To achieve this, tempest has integration test suit in the tempest project and also tempest unit tests inside each individual project like neutron-lbaas.
In this article, tempest is configured to run against a live stack that has F5 Openstack Agent and F5 Opesntack LBaaSv2 driver running.

For more information about how the F5 OpenStack development team uses Tempest tests, see F5 OpenStack Testing Methodology.

Most of the information here is from Tempest - The Openstack Integration Test Suite. 

 
Installing Tempest
 
Installing tempest is the first step. To do that you can create a virtual environment:
 
pip install virtualenv
# Change to a directory where virtual environments directories can be created.
virtualenv <test-env>
source <test-env>/bin/activate

 

After installing and activating virtualenv, you need to check out the tempest repo and install it using pip:

git clone http://git.openstack.org/openstack/tempest
pip install tempest/
 
Installing tempest will create a /etc/tempest directory in your virtualenv path and it will contain the sample config file packaged with tempest. After you fill out the content of tempest.conf and accounts.yaml, you need to copy both files to this directory and run the following command:
 
export TEMPEST_CONFIG_DIR=<test-env>/etc/tempest/

 

Running Tempest test for neutron_lbaas project

 

To run the neutron_lbaas tempest unit tests, you need to clone the neutron_lbaas project:

 

git clone https://github.com/openstack/neutron-lbaas.git

 

 Also you can use tox for testing. You can install tox using pip:

 

 

pip install tox

 

Configuring tox.ini file

Installing tox will create a tox.ini file in the root directory of neutron_lbaas project. inside the tox.ini file, there are multiple envlist options.  In order to run tox against lbaasv2, modify the envlist and only include apiv2 in the list. Running tox command will take about 15 minutes for neutron_lbaas package for first time. The reason is, it will create a virtualenv in the .tox directory inside the project and it will install all the dependency packages there. So next time, it will go and activate the virtualenv and it will run much faster.

 

envlist=apiv2

 

In this article, I will run the tests using py.test. So for this reason, you need to add pytest to the list of deps in the tox.ini file:

 

deps=<already defined dependencies>
 Pytest

 

And also modify the commands section of [testenv:apiv2] and include pytest: 

 

commands={posargs:py.test}
 

 

Configuring tempest.conf file

I added comments before the required fields in the tempest.conf and what their values should look like. Make sure to uncomment (remove the preceding #) the fields you want to include in your tempest.conf file, otherwise it will be substituted with the default value.

 

 [auth]
 ######################
 # fill out accounts.yaml file with the right credentials
 # and save it in the same directory as tempest.conf file
 ######################
 #test_accounts_file = <None>
 
 ######################
 # change this field to admin
 ######################
 #admin_username = <None>
 
 ######################
 # Openstack environment project name
 ######################
 #admin_project_name = <None>
 
 ######################
 # admin user password in Openstack environment
 ######################
 #admin_password = <None>
 
 
 [compute]
 ######################
 # This filed is required for scenario tests, uncomment image_ref 
 # field and pass the image_id for the cirros image in the Glance
 ######################
 #image_ref = <None>
 
 ######################
 # Pass the flavor_ref from the listed flavors in the Openstack environment
 # for scenario tests
 ######################
 #flavor_ref = 1
 
 ######################
 # network name from the admin tenant that has ports 
 # in both router and external_network 
 ######################
 #fixed_network_name = <None>
 
 [identity]
 ######################
 # uri field needs to be in the following format
 # http://<CONTROLLER_IP>:35357/v2.0
 ######################
 #uri = <None>
 
 
 [identity-feature-enabled]
  ######################
 # api_v2 needs to be set to true
 ######################
 # Is the v2 identity API enabled (boolean value)
 #api_v2 = true
 
 
 [network] 
 ######################
 # use the network cidr from your "fixed_network_name"
 ######################
 #project_network_cidr = 10.100.0.0/16
 
 #####################
 # project network mask bits for "fixed_network_name"
 #####################
 #project_network_mask_bits = 28
 
 
 ######################
 # This is the ID of your External network.
 ######################
 #public_network_id =
 
 ######################
 # This is the name of your External network.
 ######################
 #floating_network_name = <None>
 
 ######################
 # This is the ID of the public router.
 ######################
 #public_router_id =
 
 ######################
 # DNS server address
 ######################
 #dns_servers = 8.8.8.8,8.8.4.4
 
 ######################
 # This is address of fixed network
 ######################
 #default_network = 1.0.0.0/16,2.0.0.0/16
 
 
 [service_available]
 
 ######################
 # neutron is available and this field needs to be set to true.
 ######################
 # Whether or not neutron is expected to be available (boolean value)
 #neutron = false
 
 [validation]
 
 ######################
 # This is the username of the image you passed its ID in the image_ref field.
 # for cirros image this is "cirros"
 ######################
 #image_ssh_user = root
 
 ######################
 # This is the password of the image you passed its ID in the image_ref field.
 # for cirros image this is "cubswin:)"
 ######################
 #image_ssh_password = password
 
 ######################
 # Name of the network in the admin tenant that can be used for SSH connection
 ######################
 network_for_ssh = tempest-mgmt-network
 

 

Configuring accounts.yaml file

fill in the username, tenant name and password from the Openstack environment.

 

  
  username: 'admin'
  tenant_name: 'admin'
  password: 'changeme'

 

Running Tests

Neutron_lbaas has tempest api and scenario unit test. Api tests are responsible for examining the Openstack API whereas scenario tests are "through pass " tests as described in the Openstack documentation. After configuring tempest.conf and accounts.yaml file, you should be able to run the test using the following command:

 

cd neutron_lbaas/
tox -- py.test -lvv neutron_lbaas/tests/tempest/v2/api/test_health_monitor_admin.py
 

Now that you have Tempest set up, you can move on to writing your own Tempest tests to check your code. See F5 Tempest Plugin and Writing Tempest Tests for more information.

 

Published Sep 30, 2016
Version 1.0

Was this article helpful?

No CommentsBe the first to comment