社区对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:
###查看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.gz cd unittest2-0.5.1python setup.py install
###查看xslt-config命令是否存在
[root@controller001 ~]# whereis xslt-config xslt-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
[root@controller001 ~]#/usr/bin/easy_install pip
###进入tempest目录进行安装(没有安装虚拟机环境)
[root@controller001 ~]#python setup.py install
(可选)###如果不想将tempest安装在真实环境中那么执行如下命令
[root@controller001 ~]#pip -U virtualenv
[root@controller001 ~]#virtualenv .venv
[root@controller001 ~]#. .venv/bin/activate
[root@controller001 ~]#python setup.py install
###安装junitxml,是测试报告输出为xml格式
[root@controller001]#pip install junitxml
###由于tempest在Icehouse时期上使用是有bug的,bug如下:
###在/root/tempest/tempest/openstack/common/log.py文件下添加
注意:在Juno版本时期,此bug已修复,故而可以跳过。
###修改tempest.conf文件,注意创建外网的时候不要共享,否则在测试启动虚拟机以及进行网络测试的时候会报错
cp etc/tempest.conf.sample etc/tempest.conf
[root@controller001 etc]# == /usr/bincatalog_type===53f6877e-2f46-43e3-93b7-7e22786cacb2 flavor_ref = 1
= = ./= 7e4b08b4-d7a1-4eff--= 7e4b08b4-d7a1-4eff--=== =-====-feature-= = = = = = = = http:login_url = http:============= http:uri_v3 = .=-feature-= = === http:region =-feature-= =
public_router_id =ac4a4d9b-27c7-492b-824a-ae384710ab2a region =RegionOne tenant_network_cidr = 10.100.0.0/16 tenant_network_mask_bits = 28 tenant_networks_reachable = true [network-feature-enabled] [object-storage] [object-storage-feature-enabled] [orchestration] [scenario] [service_available] (这里配置需要测试哪些模块) ceilometer = false cinder = true glance = true heat = false horizon = true ironic = false neutron = true nova = true sahara = false swift = false trove = false zaqar = false [stress] [telemetry] [volume] [volume-feature-enabled] multi_backend =true (测试cinder的后端存储有多个backend)
###修改好配置文件之后,进行测试(以测试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 url‘value and body‘s value tenants,{"tenant": {"enabled": true, "name": "tenant--1612865724", "description": ""}} I want to the url‘value and body‘s value users,{"user": {"tenantId": "b8f636519ff949d19405e59fce2f78ac", "password": "pass--1460623961", "name": "user--1945966900", "email": ""}} I want to the url‘value and body‘s 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 url‘value and body‘s value users,{"user": {"password": "pass--46178537", "name": "user--996425809", "email": ""}} I want to the url‘value and body‘s value tenants,{"tenant": {"enabled": true, "name": "tenant--781047271", "description": ""}} I want to the url‘value and body‘s value tenants,{"tenant": {"enabled": true, "name": "tenant--1886860973", "description": ""}} I want to the url‘value and body‘s value OS-KSADM/roles,{"role": {"name": "role--684861165"}} I want to the url‘value and body‘s value http://172.16.100.162:35357/v2.0/tokens,{"auth": {"passwordCredentials": {"username": "user--996425809", "password": "pass--46178537"}}}I want to the url‘value and body‘s 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 url‘value and body‘s 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
本文出自 “再生细胞” 博客,请务必保留此出处http://wangtianfa.blog.51cto.com/5281093/1621797
原文地址:http://wangtianfa.blog.51cto.com/5281093/1621797