Jump to: navigation, search

Difference between revisions of "Solum/Testing"

(Running Functional Tests)
(Running Unit Tests)
 
(12 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
= Solum Testing =
 
= Solum Testing =
  
Currently Solum depends on OpenStack Keystone, Nova, Heat, Glance, and Swift. Additional dependencies may be added in the future. We recommend using Devstack to set up Solum with its various low level services. See the [https://solum.readthedocs.org/en/latest/getting_started/ Getting Started Guide] for information about how to set up your Devstack environment. You can use the provided Vagrant setup, or you can configure Devstack on your own.
+
Currently Solum depends on OpenStack Keystone, Nova, Heat, Glance, Swift, Barbican, Mistral and Marconi. Additional dependencies may be added in the future. We recommend using Devstack to set up Solum with its various low level services. See the [https://solum.readthedocs.org/en/latest/getting_started/ Getting Started Guide] for information about how to set up your Devstack environment. You can use the provided Vagrant setup, or you can configure Devstack on your own.
 +
 
 +
Functional tests, Unit tests and PEP8 ([http://docs.openstack.org/developer/hacking/ OpenStack Style Guidelines]) checks are automatically run for Solum through our Stackforge gate jobs when new code is submitted for review in the [https://github.com/stackforge/solum git repository], and are automatically tested again prior to merge. To run these tests on your local Solum Vagrant/Devstack box, follow these below steps.
  
 
== Tempest Setup ==
 
== Tempest Setup ==
Line 8: Line 10:
 
=== Checkout tempest code ===
 
=== Checkout tempest code ===
  
  cd ${DEVSTACK_DIR}
+
cd ${DEVSTACK_DIR}
  git clone https://github.com/openstack/tempest.git
+
git clone https://github.com/openstack/tempest.git
  
 
=== Create tempest configuration file ===
 
=== Create tempest configuration file ===
  
  cd ${DEVSTACK_DIR}/tempest/etc
+
cd ${DEVSTACK_DIR}/tempest/etc
  cp tempest.conf.sample tempest.conf
+
cp tempest.conf.sample tempest.conf
 +
 
 +
=== Copy tempest configuration file to appropriate location ===
 +
 
 +
sudo mkdir -p /etc/tempest
 +
sudo cp ${DEVSTACK_DIR}/tempest/etc/tempest.conf /etc/tempest/tempest.conf
  
 
=== Configure Tempest ===
 
=== Configure Tempest ===
 
Add the following text to etc/tempest.conf
 
Add the following text to etc/tempest.conf
  [DEFAULT]
+
[DEFAULT]
  debug=True
+
debug=True
  use_stderr=False
+
use_stderr=False
  log_file=tempest.log
+
log_file=tempest.log
 
   
 
   
  [identity]
+
[identity]
  tenant_name = service
+
auth_version = v2
  password = your_openstack_password
+
admin_domain_name = Default
  username = solum
+
admin_tenant_name = admin
  uri_v3 = http://127.0.0.1:5000/v3/
+
admin_password = solum
  uri = http://127.0.0.1:5000/v2.0/
+
admin_username = admin
 +
alt_tenant_name = alt_demo
 +
alt_password = solum
 +
alt_username = alt_demo
 +
tenant_name = demo
 +
password = solum
 +
username = demo
 +
uri_v3 = http://10.0.2.15:5000/v3/
 +
uri = http://10.0.2.15:5000/v2.0/
  
 
NOTE: The uri_v3 and uri setting should correspond to where you are running your Keystone instance.
 
NOTE: The uri_v3 and uri setting should correspond to where you are running your Keystone instance.
Line 35: Line 50:
 
Once you have Tempest set up, you may execute your functional tests:
 
Once you have Tempest set up, you may execute your functional tests:
  
  cd ${DEVSTACK_DIR}/solum/functionaltests
+
cd ${DEVSTACK_DIR}/solum/functionaltests
  export TEMPEST_DIR=${DEVSTACK_DIR}/tempest
+
export TEMPEST_DIR=${DEVSTACK_DIR}/tempest
  ./run_tests.sh
+
./run_tests.sh
 +
 
 +
You can optionally run specifc functional test:
 +
 
 +
cd ${DEVSTACK_DIR}/solum
 +
export PYTHONPATH=$PYTHONPATH:${DEVSTACK_DIR}/tempest
 +
nosetests --tests dir_name1[.dir_name2...dir_nameN].test_file_name:TestClassName.test_method_name
 +
Example: nosetests --tests functionaltests.api.v1.test_plan:TestPlanController.test_plans_create
  
 
== Running Unit Tests ==
 
== Running Unit Tests ==
Unit tests are automatically run for Solum through our Stackforge gate jobs when new code is submitted for review in the [https://github.com/stackforge/solum git repository], and are automatically tested again prior to merge. To run tests locally in your development environment, you can use <code>tox</code> with your local version of python (example is for Python 2.6):
+
You can use <code>tox</code> with your local version of python (example is for Python 2.7):
  
  tox -e py26
+
cd ${DEVSTACK_DIR}/solum
 +
  tox -e py27
 +
 
 +
You can optionally run specific unit test:
 +
 
 +
cd ${DEVSTACK_DIR}/solum
 +
tox -e py27 -- dir_name1[.dir_name2...dir_nameN].test_file_name:TestClassName.test_method_name
 +
Example: tox -e py27 -- solum.tests.api.handlers.test_assembly:TestAssemblyHandler.test_assembly_get
 +
 
 +
If you want to debug a specific unit test:
 +
 
 +
cd ${DEVSTACK_DIR}/solum
 +
python -m testtools.run solum.tests.deployer.handlers.test_heat.HandlerTest.test_check_stack_status
 +
 
 +
You may have to pip install following: mock, oslotest
  
 
On CentOS 6.5, the following additional packages may be needed:
 
On CentOS 6.5, the following additional packages may be needed:
  yum -y install openssl-devel python-devel libffi-devel python-lxml libxml2-devel libxslt-devel
+
  sudo yum -y install openssl-devel python-devel libffi-devel python-lxml libxml2-devel libxslt-devel
 +
 
 +
On Ubuntu:
 +
sudo apt-get install libxml2-dev libxslt-dev
 +
 
 +
== Running PEP8 Checks ==
 +
You can use <code>tox</code>:
 +
 
 +
cd ${DEVSTACK_DIR}/solum
 +
tox -e pep8

Latest revision as of 15:20, 18 April 2016

Solum Testing

Currently Solum depends on OpenStack Keystone, Nova, Heat, Glance, Swift, Barbican, Mistral and Marconi. Additional dependencies may be added in the future. We recommend using Devstack to set up Solum with its various low level services. See the Getting Started Guide for information about how to set up your Devstack environment. You can use the provided Vagrant setup, or you can configure Devstack on your own.

Functional tests, Unit tests and PEP8 (OpenStack Style Guidelines) checks are automatically run for Solum through our Stackforge gate jobs when new code is submitted for review in the git repository, and are automatically tested again prior to merge. To run these tests on your local Solum Vagrant/Devstack box, follow these below steps.

Tempest Setup

Solum uses the tempest functional testing framework. To manually set up tempest:

Checkout tempest code

cd ${DEVSTACK_DIR}
git clone https://github.com/openstack/tempest.git

Create tempest configuration file

cd ${DEVSTACK_DIR}/tempest/etc
cp tempest.conf.sample tempest.conf

Copy tempest configuration file to appropriate location

sudo mkdir -p /etc/tempest
sudo cp ${DEVSTACK_DIR}/tempest/etc/tempest.conf /etc/tempest/tempest.conf

Configure Tempest

Add the following text to etc/tempest.conf

[DEFAULT]
debug=True
use_stderr=False
log_file=tempest.log

[identity]
auth_version = v2
admin_domain_name = Default
admin_tenant_name = admin
admin_password = solum
admin_username = admin
alt_tenant_name = alt_demo
alt_password = solum
alt_username = alt_demo
tenant_name = demo
password = solum
username = demo
uri_v3 = http://10.0.2.15:5000/v3/
uri = http://10.0.2.15:5000/v2.0/

NOTE: The uri_v3 and uri setting should correspond to where you are running your Keystone instance.

Running Functional Tests

Once you have Tempest set up, you may execute your functional tests:

cd ${DEVSTACK_DIR}/solum/functionaltests
export TEMPEST_DIR=${DEVSTACK_DIR}/tempest
./run_tests.sh

You can optionally run specifc functional test:

cd ${DEVSTACK_DIR}/solum
export PYTHONPATH=$PYTHONPATH:${DEVSTACK_DIR}/tempest
nosetests --tests dir_name1[.dir_name2...dir_nameN].test_file_name:TestClassName.test_method_name
Example: nosetests --tests functionaltests.api.v1.test_plan:TestPlanController.test_plans_create

Running Unit Tests

You can use tox with your local version of python (example is for Python 2.7):

cd ${DEVSTACK_DIR}/solum
tox -e py27

You can optionally run specific unit test:

cd ${DEVSTACK_DIR}/solum
tox -e py27 -- dir_name1[.dir_name2...dir_nameN].test_file_name:TestClassName.test_method_name
Example: tox -e py27 -- solum.tests.api.handlers.test_assembly:TestAssemblyHandler.test_assembly_get

If you want to debug a specific unit test:

cd ${DEVSTACK_DIR}/solum
python -m testtools.run solum.tests.deployer.handlers.test_heat.HandlerTest.test_check_stack_status

You may have to pip install following: mock, oslotest

On CentOS 6.5, the following additional packages may be needed:

sudo yum -y install openssl-devel python-devel libffi-devel python-lxml libxml2-devel libxslt-devel

On Ubuntu:

sudo apt-get install libxml2-dev libxslt-dev

Running PEP8 Checks

You can use tox:

cd ${DEVSTACK_DIR}/solum
tox -e pep8