首页 > 代码库 > OpenStack平台功能性测试工具Tempest安装

OpenStack平台功能性测试工具Tempest安装

社区对OpenStack平台功能性的测试工具采用Tempest,性能测试采用Rally。

1、什么是Tempest

tempest
├── api # API的测试集
├── cli # OpenStack的命令行工具测试集
├── common # 一些公共的工具类和函数
├── scenario # 对OpenStack的常用场景进行测试,包括基本的启动VM,挂载volumn和网络配置等
├── services # tempest自己实现的OpenStack API Client,自己实现是为了不让一些bug隐藏在官方实现的Client里面。
├── stress # 压力测试集,利用multiprocessing来启动多个进程来同时对OpenStack发起请求。
├── thirdparty # EC2兼容的API测试集
├── whitebox # 白盒测试集,主要是对DB操作,然后发起请求,然后比对结果
2、tempest是通过nose驱动的,python语言编写,使用testtools和testresources等几个测试工具库
3、tempest.test.BaseTestCase,BaseTestCase声明config属性,读取配置文件
4、tempest.test.TestCase声明很多工具函数,供调用
5、每个测试可以分别测试JSON格式和XML格式

2、安装Tempest

##下载源码

git clone https://github.com/openstack/tempest.gitcd tempestvim requirements.txt
##添加
discover>=0.4.0

###查看python版本

python --version

###如若是2.6执行如下,2.7不需要

wget https://pypi.python.org/packages/source/u/unittest2/unittest2-0.5.1.tar.gztar zxvf unittest2-0.5.1.tar.gzcd unittest2-0.5.1python setup.py install

 ###查看xslt-config命令是否存在

[root@controller001 ~]# whereis xslt-configxslt-config: /usr/bin/xslt-config(代表存在)

###如果没有执行安装命令

[root@controller001 ~]#yum install libxslt-devel

###检查是否有gcc环境,没有则安装

[root@controller001 ~]#yum install gcc-c++

###安装一些相关的包

[root@controller001 ~]#yum install libevent-devel openssl-devel libffi-devel python-devel

###进入tempest目录进行安装(没有安装虚拟机环境)

[root@controller001 ~]#python setup.py install

(可选)###如果不想将tempest安装在真实环境中那么执行如下命令

[root@controller001 ~]#pip install -U virtualenv
[root@controller001 ~]#virtualenv .venv
[root@controller001 ~]#. .venv/bin/activate
[root@controller001 ~]#pythont setup.py install

###安装junitxml,是测试报告输出为xml格式

[root@controller001]#pip install junitxml

###由于tempestIcehouse上使用是有bug的,bug如下:

###在/root/tempest/tempest/openstack/common/log.py文件下添加

技术分享

###修改tempest.conf文件,注意创建外网的时候不要共享,否则在测试启动虚拟机以及进行网络测试的时候会报错

cp etc/tempest.conf.sample etc/tempest.conf
[root@controller001 etc]# egrep "^[^#]" tempest.conf[DEFAULT]lock_path =keystone [auth][baremetal][boto][cli]cli_dir = /usr/= true       (是否测试cli命令)[compute]                                           = compute  (keystone service-list命令显示type的值)endpoint_type = publicURL (keystone endpoint-list命令显示)fixed_network_name=53f6877e-2f46-43e3-93b7-= 1flavor_ref_alt = 2floating_ip_range = 172.16.101.0/24image_ref = 7e4b08b4-d7a1-4eff-9757-25e2234ca4db     (镜像id)image_ref_alt = 7e4b08b4-d7a1-4eff-9757-25e2234ca4dbregion =RegionOne                                     (与keystone endpoint-list命令列出值region值相同)ssh_user = root                                       use_floatingip_for_ssh = truevolume_device_name = vdb                              (挂载云硬盘)[compute-admin]domain_name = novapassword =admin tenant_name = adminusername = admin[compute-feature-enabled]live_migration = truerescue = trueresize = trueshelve = truesnapshot = truesuspend = truevnc_console = true[dashboard]dashboard_url = http://172.16.100.162/dashboard/login_url = http://172.16.100.162/auth/login/[data_processing][database][debug][identity]                                                  (keystone方面的配置)admin_password = adminadmin_role = adminadmin_tenant_name = adminadmin_username = adminalt_password = tempestalt_tenant_name = tempestalt_username = tempestcatalog_type = identityendpoint_type = publicURLpassword = adminregion = RegionOnetenant_name = adminuri = http://172.16.100.162:35357/v2.0uri_v3 = 172.16.100.162username = admin[identity-feature-enabled]api_v2 = trueapi_v3 = true[image]                                                  (glance方面的配置)catalog_type = imageendpoint_type = publicURLhttp_image = http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-uec.tar.gzregion =RegionOne[image-feature-enabled]api_v1 = trueapi_v2 = true[input-= networkdns_servers = 8.8.8.8,8.8.4.4endpoint_type = publicURLpublic_network_id =53f6877e-2f46-43e3-93b7-7e22786cacb2  public_router_id =ac4a4d9b-27c7-492b-824a-ae384710ab2aregion =RegionOnetenant_network_cidr = 10.100.0.0/16tenant_network_mask_bits = 28tenant_networks_reachable = true[network-feature-enabled][object-storage][object-storage-feature-enabled][orchestration][scenario][service_available]  (这里配置需要测试哪些模块)ceilometer = falsecinder = trueglance = trueheat = falsehorizon = trueironic = falseneutron = truenova = truesahara = falseswift = falsetrove = falsezaqar = false[stress][telemetry][volume][volume-feature-enabled]multi_backend =true

 ###修改好配置文件之后,进行测试(以测试keystone当中token为例)

[root@controller001 tempest]# nosetests tempest/api/identity/admin/test_tokens.py --with-xunit --xunit-file=/root/keystone_test_tokens.xml

----------------------------------------------------------------------
Ran 2 tests in 1.532s

OK

[root@controller001 ~]# cat keystone_test_tokens.xml <?xml version="1.0" encoding="UTF-8"?><testsuite name="nosetests" tests="2" errors="0" failures="0" skip="0"><testcase classname="tempest.api.identity.admin.test_tokens.TokensTestJSON" name="test_create_get_delete_token[gate]" time="0.270"><system-out><![CDATA[I want to the urlvalue and bodys value tenants,{"tenant": {"enabled": true, "name": "tenant--1612865724", "description": ""}}I want to the urlvalue and bodys value users,{"user": {"tenantId": "b8f636519ff949d19405e59fce2f78ac", "password": "pass--1460623961", "name": "user--1945966900", "email": ""}}I want to the urlvalue and bodys value http://172.16.100.162:35357/v2.0/tokens,{"auth": {"tenantName": "tenant--1612865724", "passwordCredentials": {"username": "user--1945966900", "password": "pass--1460623961"}}}]]></system-out></testcase><testcase classname="tempest.api.identity.admin.test_tokens.TokensTestJSON" name="test_rescope_token[gate]" time="0.526"><system-out><![CDATA[I want to the urlvalue and bodys value users,{"user": {"password": "pass--46178537", "name": "user--996425809", "email": ""}}I want to the urlvalue and bodys value tenants,{"tenant": {"enabled": true, "name": "tenant--781047271", "description": ""}}I want to the urlvalue and bodys value tenants,{"tenant": {"enabled": true, "name": "tenant--1886860973", "description": ""}}I want to the urlvalue and bodys value OS-KSADM/roles,{"role": {"name": "role--684861165"}}I want to the urlvalue and bodys value http://172.16.100.162:35357/v2.0/tokens,{"auth": {"passwordCredentials": {"username": "user--996425809", "password": "pass--46178537"}}}I want to the urlvalue and bodys value http://172.16.100.162:35357/v2.0/tokens,{"auth": {"token": {"id": "MIIDLgYJKoZIhvcNAQcCoIIDHzCCAxsCAQExCTAHBgUrDgMCGjCCAYQGCSqGSIb3DQEHAaCCAXUEggFxeyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMS0yMlQwNTo1MDowNy42NDg5NjIiLCAiZXhwaXJlcyI6ICIyMDE1LTAxLTIyVDA2OjUwOjA3WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJhdWRpdF9pZHMiOiBbIkpIZ0U0eDgwVFJXSkJORjJFUjdXV3ciXX0sICJzZXJ2aWNlQ2F0YWxvZyI6IFtdLCAidXNlciI6IHsidXNlcm5hbWUiOiAidXNlci0tOTk2NDI1ODA5IiwgInJvbGVzX2xpbmtzIjogW10sICJpZCI6ICI4OGQwNGVkZmU0YWE0MmEyYWUzZWQxZjAyNzVmYWQ3NCIsICJyb2xlcyI6IFtdLCAibmFtZSI6ICJ1c2VyLS05OTY0MjU4MDkifSwgIm1ldGFkYXRhIjogeyJpc19hZG1pbiI6IDAsICJyb2xlcyI6IFtdfX19MYIBgTCCAX0CAQEwXDBXMQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVW5zZXQxDjAMBgNVBAcMBVVuc2V0MQ4wDAYDVQQKDAVVbnNldDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tAgEBMAcGBSsOAwIaMA0GCSqGSIb3DQEBAQUABIIBAAjoxz4e-hnwHy45cd+o3tgQI1SdvidiOIfRrDAg5hMc0Fn9pGxnt-fYmZIBRH9b0LMjkjJa32OO2M0xmlcwCmaALsMMpBk5ouaECzNEJNGb2UyFW6Lpi5r5seM5HBO40brE0muMraOnzoRqkmGijEXf0RDn84iFrX40pvwo-htACNsB9fm1BkqUg8A+ANOJNHRGnqY80fIj+ipp5-53drN0VxbakHZvYJHAut5GsOdK-+TThj3fvbDA1fM-wa-SmZNV7xl-X8F9NChbe7VV3AFdE4XQHpdFZr+c4ZEDGlcq6VVRyD0OpeM2Nt9GbN8gevNWJpK2qjVJ2dxXgCZnDZg="}, "tenantName": "tenant--781047271"}}I want to the urlvalue and bodys value http://172.16.100.162:35357/v2.0/tokens,{"auth": {"token": {"id": "MIIDLgYJKoZIhvcNAQcCoIIDHzCCAxsCAQExCTAHBgUrDgMCGjCCAYQGCSqGSIb3DQEHAaCCAXUEggFxeyJhY2Nlc3MiOiB7InRva2VuIjogeyJpc3N1ZWRfYXQiOiAiMjAxNS0wMS0yMlQwNTo1MDowNy42NDg5NjIiLCAiZXhwaXJlcyI6ICIyMDE1LTAxLTIyVDA2OjUwOjA3WiIsICJpZCI6ICJwbGFjZWhvbGRlciIsICJhdWRpdF9pZHMiOiBbIkpIZ0U0eDgwVFJXSkJORjJFUjdXV3ciXX0sICJzZXJ2aWNlQ2F0YWxvZyI6IFtdLCAidXNlciI6IHsidXNlcm5hbWUiOiAidXNlci0tOTk2NDI1ODA5IiwgInJvbGVzX2xpbmtzIjogW10sICJpZCI6ICI4OGQwNGVkZmU0YWE0MmEyYWUzZWQxZjAyNzVmYWQ3NCIsICJyb2xlcyI6IFtdLCAibmFtZSI6ICJ1c2VyLS05OTY0MjU4MDkifSwgIm1ldGFkYXRhIjogeyJpc19hZG1pbiI6IDAsICJyb2xlcyI6IFtdfX19MYIBgTCCAX0CAQEwXDBXMQswCQYDVQQGEwJVUzEOMAwGA1UECAwFVW5zZXQxDjAMBgNVBAcMBVVuc2V0MQ4wDAYDVQQKDAVVbnNldDEYMBYGA1UEAwwPd3d3LmV4YW1wbGUuY29tAgEBMAcGBSsOAwIaMA0GCSqGSIb3DQEBAQUABIIBAAjoxz4e-hnwHy45cd+o3tgQI1SdvidiOIfRrDAg5hMc0Fn9pGxnt-fYmZIBRH9b0LMjkjJa32OO2M0xmlcwCmaALsMMpBk5ouaECzNEJNGb2UyFW6Lpi5r5seM5HBO40brE0muMraOnzoRqkmGijEXf0RDn84iFrX40pvwo-htACNsB9fm1BkqUg8A+ANOJNHRGnqY80fIj+ipp5-53drN0VxbakHZvYJHAut5GsOdK-+TThj3fvbDA1fM-wa-SmZNV7xl-X8F9NChbe7VV3AFdE4XQHpdFZr+c4ZEDGlcq6VVRyD0OpeM2Nt9GbN8gevNWJpK2qjVJ2dxXgCZnDZg="}, "tenantName": "tenant--1886860973"}}]]></system-out></testcase></testsuite>

若有不足之处,欢迎批评指正!

 

相关链接:http://www.oschina.net/question/129540_146999

 

OpenStack平台功能性测试工具Tempest安装