本博文出自51CTO博客再生细胞博主,有任何问题请进入博主页面互动讨论! |
一、OpenStack Rally 性能测试
1.注意点
在测试nova,在配置文件里面如果不指定网络id,那么默认是外网的网络(该网络是共享的),如果想要指定网络,那么该网络必须是共享的状态,否则将会报错:无法发现网络。如果测试多于50台的虚拟机需要修改默认值,因为默认值是有限制的可用如下命令查看:
- [root@rally nova]# nova absolute-limits
- +-------------------------+---------+
- | Name | Value |
- +-------------------------+---------+
- | maxServerMeta | 128 |
- | maxPersonality | 100 |
- | maxImageMeta | 128 |
- | maxPersonalitySize | 10240 |
- | maxTotalRAMSize | 5120000 |
- | maxSecurityGroupRules | 20 |
- | maxTotalKeypairs | 100 |
- | totalRAMUsed | 58960 |
- | maxSecurityGroups | 10 |
- | totalFloatingIpsUsed | 0 |
- | totalInstancesUsed | 24 |
- | totalSecurityGroupsUsed | 1 |
- | maxTotalFloatingIps | 10 |
- | maxTotalInstances | 200 |
- | totalCoresUsed | 51 |
- | maxTotalCores | 500 |
- +-------------------------+---------+
修改默认值可以在界面,管理员->默认值,进行修改;其次可以在运行nova-api服务的节点上修改配置文件nova.conf
#p#
2.安装rally:
- [root@rally nova]#git clone https://github.com/stackforge/rally.git
- [root@rally rally]# /usr/bin/easy_install pip (安装pip,有就不需要装了)
- [root@rally rally]# mkdir /root/.pip
- [root@rally rally]# vim /root/.pip/pip.conf (设置pip源,加快安装速度)
- [global]
- [root@rally nova]#pip install -U virtualenv 安装虚拟环境(可装可不装,一般为了系统的干净还是装个虚拟环境)
- [root@rally nova]#virtualenv .venv
- [root@rally nova]#. .venv/bin/activate
- [root@rally nova]#yum install gcc-c++ (安装编译工具)
- [root@rally nova]#cd rally
- [root@rally rally]#./install_rally.sh
- ....
======================================================================
Information about your Rally installation:
* Method: system
* Database at: /var/lib/rally/database
* Configuration file at: /etc/rally
======================================================================
安装完成,数据库的配置这里暂时没做。
创建一个随便命名的.json格式文件:
- [root@rally rally]# : :
- [root@rally rally]# rally deployment create --file=existing.json --name=existing
+--------------------------------------+----------------------------+----------+------------------+--------+
| uuid | created_at | name | status | active |
+--------------------------------------+----------------------------+----------+------------------+--------+
| 15ef811a-6460-407c-b391-c0f435f1ae54 | 2015-03-05 10:09:36.468176 | existing | deploy->finished | |
+--------------------------------------+----------------------------+----------+------------------+--------+
Using deployment: 15ef811a-6460-407c-b391-c0f435f1ae54
- [root@rally rally]# rally deployment check
- keystone endpoints are valid and following services are available:
- +------------+-----------+-----------+
- | services | type | status |
- +------------+-----------+-----------+
- | ceilometer | metering | Available |
- | cinder | volume | Available |
- | cinderv2 | volumev2 | Available |
- | glance | image | Available |
- | keystone | identity | Available |
- | neutron | network | Available |
- | nova | compute | Available |
- | nova_ec2 | ec2 | Available |
- | novav3 | computev3 | Available |
- +------------+-----------+-----------+
#p#
如此便可继续往下进行OpenStack基准测试了。
举个测试启动虚拟机的例子:boot.json文件内容如下:
doc/samples/tasks/scenarios/nova/boot.json
- [root@rally nova]# cat boot.json
- {
- "NovaServers.boot_server": [
- {
- "args": {
- "flavor": {
- "name": "m1.large"
- },
- "image": {
- "name": "Windows_Server_2008R2_SP1_Standard_64bit"
- },
- "nics":[{"net-id": "c7048568-c966-4d57-a927-90dd8830fb96"}],(默认是没有这行的)
- },
- "runner": {
- "type": "constant",
- "times": 100, (测试次数100) "concurrency": 2 (并发数)
- },
- "context": {
- "users": {
- "tenants": 3,
- "users_per_tenant": 2
- }
- }
- }
- }
- }
- [root@rally nova]# . /root/rally/.venv/bin/activate
- [root@rally nova]# rally -v task start boot.json(/root/rally/doc/samples/tasks/scenarios/nova这是当前的目录)
以上的图是测试结果。
相关链接:https://wiki.openstack.org/wiki/Rally
https://rally.readthedocs.org/en/latest/tutorial/step_0_installation.html
https://rally.readthedocs.org/en/latest/tutorial/step_1_setting_up_env_and_running_benchmark_from_samples.html
#p#
社区对OpenStack平台功能性的测试工具采用Tempest,性能测试采用Rally。
二、OpenStack平台功能性的测试工具Tempest
1、什么是Tempest
1).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格式
#p#
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>
若有不足之处,欢迎批评指正!