Rally是OpenStack社區推出開源測試工具,可用於對OpenStack各個組件進行性能測試。javascript
經過使用Rally組件,用戶可完成OpenStack雲計算平臺的安裝部署、功能驗證、大規模負載測試(性能測試)、輸出測試報告等一系列動做。css
在icos環境中,直接在globals.yml中開啓rally。html
enable_rally: "yes"
而後tag安裝部署便可。java
若是是性能測試設計主機關閉等操做,建議rally安裝在一臺非測試節點的機器。node
安裝完優化一下參數,rally配置文件位置:/etc/rally/rally.confpython
默認註釋全部選項,測試中遇到以下問題:ios
作以下設置,避免超時影響測試結果,時間設置1800s:angularjs
[DEFAULT] openstack_client_http_timeout = 1800.0 [benchmark] cinder_volume_create_timeout = 1800.0 cinder_volume_delete_timeout = 1800.0 nova_server_boot_timeout = 1800.0 nova_server_boot_timeout = 1800.0
對於已經安裝部署了OpenStack系統,有兩種方式建立deploymentweb
1) 使用環境變量建立ajax
(rally)[root@node135 ~]# more openrc export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=xxxx export OS_AUTH_URL=http://100.2.28.139:35357 #生效一下 source openrc #建立 rally deployment create --fromenv --name=existing
2) 使用json文件建立
rally deployment create--file=existing.json --name=existing
existing文件模板默認位置/rally-openstack/samples/deployments
existing.json文件內容以下:
{ "type":"ExistingCloud", "auth_url": "http://10.25.*.*:35357/v3", "region_name":"RegionOne", "endpoint_type":"public", "admin": { "username":"admin", "password": "****", "tenant_name": "admin" }, "users": [ { "username": "nsp_test_1", "password":"password", "tenant_name":"nsp_tenant_1" }, { "username":"nsp_test_2", "password":"password2", "tenant_name":"nsp_tenant_2" } ] }
查看全部的deployment列表
rally deployment list
查看已經建立的deployment詳情
rally deployment show existing
rally deployment check
檢查建立的deployment各項服務是否正常,如下是執行結果
若是中途退出了環境,須要再次定義環境變量
rally deployment use existing
Task是Rally執行的一個測試單元,執行Task時須要指定入口文件,能夠是json文件或者yaml文件
以下是執行形式:
rally task start /rally-openstack/samples/tasks/scenarios/nova/boot_ljy.yaml
默認場景模板位置 /rally-openstack/samples/tasks/scenarios
boot-and-delete.yaml {% set flavor_name = flavor_name or "m1.tiny" %} #資源規格 --- NovaServers.boot_and_delete_server: - args: flavor: name: "{{flavor_name}}" image: name: "TestVM" #鏡像名稱 force_delete: false runner: type: "constant" times: 10 #測試次數 concurrency: 2 #併發數 context: users: tenants: 3 users_per_tenant: 2 sla: failure_rate: max: 0 - args: flavor: name: "{{flavor_name}}" image: name: "TestVM" auto_assign_nic: true runner: type: "constant" times: 10 concurrency: 2 context: users: tenants: 3 users_per_tenant: 2 network: start_cidr: "192.168.190.0/24" networks_per_tenant: 2 sla: failure_rate: max: 0
(rally)[root@control01 ljy]# more create-volume.yaml --- CinderVolumes.create_volume: - args: size: 1 runner: type: "constant" times: 3 concurrency: 2 context: users: tenants: 2 users_per_tenant: 2 sla: failure_rate: max: 0 - args: size: min: 1 max: 5 runner: type: "constant" times: 3 concurrency: 2 context: users: tenants: 2 users_per_tenant: 2 sla: failure_rate: max: 0
(rally)[root@control01 ljy]# more create-and-delete-networks.yaml --- NeutronNetworks.create_and_delete_networks: - args: network_create_args: {} runner: type: "constant" times: 10 concurrency: 1 context: users: tenants: 3 users_per_tenant: 3 quotas: neutron: network: -1 sla: failure_rate: max: 0
可以使用rally task list,來列出已經執行的task
使用rally task report [task_id] --out=[outfile.html]能夠生成web格式的測試報告
可能此時的html文件打開會有報錯,緣由是report.html文件中使用了一些css、js庫,而這些庫放在了google網站上,所以纔會出現這麼奇怪的現象。
須要將report.html裏面以下四行中的libs網址:
<link rel="stylesheet"href="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css"> <script type="text/javascript"src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script> <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.13/d3.min.js"></script> <script type="text/javascript"src="https://cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js"></script>
替換爲能夠訪問的bootcss靜態庫的libs網址,以下:
<link rel="stylesheet"href="http://cdn.bootcss.com/nvd3/1.1.15-beta/nv.d3.css"> <script type="text/javascript"src="http://cdn.bootcss.com/angular.js/1.3.3/angular.min.js"></script> <script type="text/javascript"src="http://cdn.bootcss.com/d3/3.4.13/d3.min.js"></script> <script type="text/javascript"src="http://cdn.bootcss.com/nvd3/1.1.15-beta/nv.d3.min.js"></script>
以後就能夠打開了。或者直接將report.html模板文件的對應行修改掉,這樣生成的報告web頁面都會自動替換。
模板文件位置:/usr/lib/python2.7/site-packages/rally/ui/templates/task/report.html
上面的命令執行成功,能夠看到生成的Html文件,在瀏覽器中可查看Html文件。展現效果以下: