Linux运维--实践-Rally

1.rally简介

    OpenStack Rally 是一个自动化测试工具,社区希望通过 Rally 来解答 “How does OpenStack work at scale?(如何规模化运行 OpenStack)” 的问题。为了实现这一目的,Rally 被设计成集自动化部署、功能验证、性能测试和分析报告于一体,作为 OpenStack CI/CD 系统中的基础工具,帮助用户不断提高系统的 SLA(服务等级协议)、性能和稳定性。

    简而言之,Rally 能够帮助用户完成整个 OpenStack 平台或者某个单一组件功能的压力测试,帮助用户验证和评估稳定系统工作负载的规模。

2.应用场景

  1. 应用案例

    自动化测试、分析,评估新引入的代码如何影响云平台的性能;
    自动化测试、分析新引入的代码是否完美兼容云平台功能清单;
    评估不同的部署方式如何影响云平台的性能,以此得出性能峰值最高的云平台部署架构;
    评估不同硬件设备对云平台的性能影响,以此得出性能峰值最高的云平台硬件设施;

  2. rally架构

上图是 Rally 的总体架构,描述了 Rally 的组成结构、数据流和 OpenStack 的调用方式。

Deploy Engine:存储部署所需要的凭证(credentials)信息,以插件的形式集成第三方自动化部署工具(e.g. Devstack, Fuel, etc.),提供自动化部署能力。
Verification:通过调用 Tempest(基于 unittest 的功能测试框架)来验证云平台的功能清单。
Benchmark Engine/Task Engine:是一个通用的测试用例插件框架,允许用户编写参数化的 Plugin 实现以及对应的 Task
File(YAML/JSON)来满足自定义功能、性能测试需求,使用这种通用的方式来生成真实的用户负载。

    Rally 最初被设计成一种不需要 Daemon 的 CLI-Driver,这使 Rally 非常易于使用和开发。但通常 OpenStack Projects 总是以 “as-a-Service” 来实现的,所以现在社区也提出了 RaaS 的理念,并付诸于行动(work in progress)。

上图描述了 “Rally-as-a-Service” 和 “Rally-as-an-APP” 两种形式的实现架构,显然两者在实现上的区别主要在于是否具有 Daemon 以及相应的 HTTP、RPC Invoke,也就是所谓的是否实现了泛 “Service” 化。实际上,对于用户而言无需太过于关心上层的调用方式,用户只需关心 Rally Core 的 Benchmark Engine/Task Framework 的应用。所以本文采用的是更为成熟、简单以及常用的 “Rally-as-an-APP” 模式。

5.安装及使用
5.1 安装

在kolla环境中,直接在globals.yml中开启rally。

enable_rally: yes

如果是性能测试设计主机关闭等操作,建议rally安装在一台非测试节点的机器。

安装完优化一下参数,rally配置文件位置:/etc/rally/rally.conf

默认注释所有选项,测试中遇到如下问题:

获取实例状态超时
连接超时

做如下设置,避免超时影响测试结果,时间设置1800s:

[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

5.2.1 创建deployment

1.使用环境变量创建

安装rally客户端
yum install python-rally  openstack-rally  
 
rally deployment create --fromenv  --name=existing 
[root@kolla ~]#  rally deployment  create --fromenv --name=existing 
Database is missing. Create database by command `rally db create'
 
[root@kolla ~]# rally db create 
Creating database: sqlite:////tmp/rally.sqlite
Database created successfully
[root@kolla ~]#  rally deployment  create --fromenv --name=existing
    Env manager got invalid spec:
["There is no Platform plugin with name: 'existing@openstack'"]

问题1:
    Env manager got invalid spec: 
["There is no Platform plugin with name: 'existing@openstack'"]
解决办法:
pip  install rally-openstack  
 
问题2:
[root@kolla ~]# rally deployment create --fromenv --name=existing 
2019-06-25 12:06:23.098 139478 WARNING rally.common.plugin.discover [-]      Failed to load plugins from module 'rally_openstack' (package: 'rally-openstack 1.5.0'): (Babel 2.3.4 (/usr/lib/python2.7/site-packages), Requirement.parse('Babel!=2.4.0,>=2.5.3'), set(['python-watcherclient'])): ContextualVersionConflict: (Babel 2.3.4 (/usr/lib/python2.7/site-packages), Requirement.parse('Babel!=2.4.0,>=2.5.3'), set(['python-watcherclient']))
Env manager got invalid spec: 
["There is no Platform plugin with name: 'existing@openstack'"]
pip install Babel==2.6.0 
问题3:
[root@kolla ~]# rally deployment create --fromenv --name=existing 
2019-06-25 12:10:34.774 139579 WARNING rally.common.plugin.discover [-]      Failed to load plugins from module 'rally_openstack' (package: 'rally-openstack 1.5.0'): (urllib3 1.21.1 (/usr/lib/python2.7/site-packages), Requirement.parse('urllib3>=1.23'), set(['kubernetes'])): ContextualVersionConflict: (urllib3 1.21.1 (/usr/lib/python2.7/site-packages), Requirement.parse('urllib3>=1.23'), set(['kubernetes']))
Env manager got invalid spec: 
["There is no Platform plugin with name: 'existing@openstack'"]
 
[root@kolla ~]# pip install urllib3==1.23
Collecting urllib3==1.23
  Downloading http://pypi.doubanio.com/packages/bd/c9/6fdd990019071a4a32a5e7cb78a1d92c53851ef4f56f62a3486e6a7d8ffb/urllib3-1.23-py2.py3-none-any.whl (133kB)
    100% |████████████████████████████████| 143kB 1.5MB/s 
Installing collected packages: urllib3
  Found existing installation: urllib3 1.21.1
    Uninstalling urllib3-1.21.1:
      Successfully uninstalled urllib3-1.21.1
Successfully installed urllib3-1.23
问题3:
[root@kolla ~]# rally deployment create --fromenv --name=existing 
2019-06-25 12:11:29.250 139609 WARNING rally.common.plugin.discover [-]      Failed to load plugins from module 'rally_openstack' (package: 'rally-openstack 1.5.0'): (keystoneauth1 3.10.0 (/usr/lib/python2.7/site-packages), Requirement.parse('keystoneauth1>=3.13.0'), set(['openstacksdk'])): ContextualVersionConflict: (keystoneauth1 3.10.0 (/usr/lib/python2.7/site-packages), Requirement.parse('keystoneauth1>=3.13.0'), set(['openstacksdk']))
Env manager got invalid spec: 
["There is no Platform plugin with name: 'existing@openstack'"]
[root@kolla ~]# pip install keystoneauth1>=3.13.0
You are using pip version 8.1.2, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@kolla ~]# pip install keystoneauth1==3.13.0
Collecting keystoneauth1==3.13.0
  Downloading http://pypi.doubanio.com/packages/70/30/9649e83a663c8d60925f3e043f2926fed8a30505eb7340eab4be510f8230/keystoneauth1-3.13.0-py2.py3-none-any.whl (302kB)
    100% |████████████████████████████████| 307kB 7.7MB/s 
 
[root@kolla ~]# rally deployment create --fromenv --name=existing 
2019-06-25 12:12:09.576 139634 WARNING rally_openstack.platforms.existing [-] endpoint is deprecated and not used.
+--------------------------------------+----------------------------+----------+------------------+--------+
| uuid                                 | created_at                 | name     | status           | active |
+--------------------------------------+----------------------------+----------+------------------+--------+
| 2c09ef0f-b213-4b64-b056-14ccde426435 | 2019-06-25T04:12:09.490709 | existing | deploy->finished |        |
+--------------------------------------+----------------------------+----------+------------------+--------+
Using deployment: 2c09ef0f-b213-4b64-b056-14ccde426435
~/.rally/openrc was updated
 
HINTS:
 
* To use standard OpenStack clients, set up your env by running:
    source ~/.rally/openrc
  OpenStack clients are now configured, e.g run:
    openstack image list

2.使用json模板创建

vim /root/rally-openstack/samples/deployment/existing.json  
{
    "openstack": {
        "auth_url": "http://10.0.1.200:5000/v3",
        "region_name": "RegionOne",
        "endpoint_type": "public",
        "admin": {
            "username": "admin",
            "password": "aSFGmOilNvWdfNViQfhMYBy5owf79hArIpfSXD8d",
            "tenant_name": "admin"
        },
        "https_insecure": false,
        "https_cacert": ""
    }
}
 
 
[root@kolla ~]# rally deployment create --filename=/root/rally-openstack/samples/deployments/existing.json --name=exsisting2  
+--------------------------------------+----------------------------+------------+------------------+--------+
| uuid                                 | created_at                 | name       | status           | active |
+--------------------------------------+----------------------------+------------+------------------+--------+
| 22c66610-42f2-4ba3-994e-07a0ee0c7fc2 | 2019-06-25T06:11:36.379447 | exsisting2 | deploy->finished |        |
+--------------------------------------+----------------------------+------------+------------------+--------+
Using deployment: 22c66610-42f2-4ba3-994e-07a0ee0c7fc2
~/.rally/openrc was updated
 
HINTS:
 
* To use standard OpenStack clients, set up your env by running:
    source ~/.rally/openrc
  OpenStack clients are now configured, e.g run:
    openstack image list
 
 
rally deployment show 
rally deployment list  

5.2.2 检查deployment

检查创建的deployment各项服务是否正常,以下是执行结果

[root@kolla ~]# rally deployment check 
--------------------------------------------------------------------------------
Platform openstack:
--------------------------------------------------------------------------------
 
Available services:
+-------------+----------------+-----------+
| Service     | Service Type   | Status    |
+-------------+----------------+-----------+
| __unknown__ | alarming       | Available |
| __unknown__ | compute_legacy | Available |
| __unknown__ | event          | Available |
| __unknown__ | placement      | Available |
| __unknown__ | sharev2        | Available |
| barbican    | key-manager    | Available |
| cinder      | volume         | Available |
| cinder      | volumev2       | Available |
| cinder      | volumev3       | Available |
| cloud       | cloudformation | Available |
| glance      | image          | Available |
| gnocchi     | metric         | Available |
| heat        | orchestration  | Available |
| keystone    | identity       | Available |
| manila      | share          | Available |
| neutron     | network        | Available |
| nova        | compute        | Available |
+-------------+----------------+-----------+

5.3 执行task

Task是Rally执行的一个测试单元,执行Task时需要指定入口文件,可以是json文件或者yaml文件1

rally task start  /rally-openstack/samples/tasks/scenarios/nova/boot_ljy.yaml

5.4 应用场景
5.4.1 创建和删除虚拟机

vim boot-and-delete.json​
{% set flavor_name = flavor_name or "m1.tiny" %}
{
    "NovaServers.boot_and_delete_server": [
        {
            "args": {
                "flavor": {
                    "name": "{{flavor_name}}"
                },
                "image": {
                    "name": "^cirros.*-disk$"
                },
                "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": "^cirros.*-disk$"
                },
                "auto_assign_nic": true
            },
            "runner": {
                "type": "constant",
                "times": 10,
                "concurrency": 2
            },
            "context": {
                "users": {
                    "tenants": 3,
                    "users_per_tenant": 2
                },
                "network": {
                    "start_cidr": "10.2.0.0/24",
                    "networks_per_tenant": 2
                }
            },
            "sla": {
                "failure_rate": {
                    "max": 0
                }
            }
        }
    ]
}

5.4.2 创建云盘

[root@kolla cinder]# cat create-volume.json
{
    "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
                }
            }
        }
    ]
}

5.4.3 创建和删除网络

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

5.5 查看task

可使用rally task list,来列出已经执行的task

rally task list 
+--------------------------------------+-----------------+---------------------+---------------+----------+--------+
| UUID                                 | Deployment name | Created at          | Load duration | Status   | Tag(s) |
+--------------------------------------+-----------------+---------------------+---------------+----------+--------+
| 11d01654-4ba6-4adf-9d1e-2612eb9e0716 | existing        | 2019-06-25 06:20:27 | 3.244         | finished |        |
| 8303c5be-8e0b-435e-82d5-0548ca89553f | existing        | 2019-06-25 06:52:17 | 0.0           | crashed  |        |
| cff605dc-0870-4666-a57b-a7ccf9080a10 | existing        | 2019-06-25 06:53:09 | 0.0           | crashed  |        |
| a434647f-1f2a-4184-b392-65b9107dd5a7 | existing        | 2019-06-25 06:53:54 | 52.047        | running  |        |
+--------------------------------------+-----------------+---------------------+---------------+----------+--------+

5.6 生成web报告

使用rally task report [task_id] --out=[outfile.html]可以生成web格式的测试报告

[root@kolla nova]# rally task report a434647f-1f2a-4184-b392-65b9107dd5a7 --out boot-and-delete.output.html
2019-06-25 15:01:35.452 140808 INFO rally.api [-] Building 'html' report for the following task(s): 'a434647f-1f2a-4184-b392-65b9107dd5a7'.
2019-06-25 15:01:35.481 140808 INFO rally.api [-] The report has been successfully built.

参考文档:

https://www.cnblogs.com/jinyuanliu/p/10948292.html#_label2

https://blog.csdn.net/u013553406/article/details/52026883

rally task start /rally-openstack/samples/tasks/scenarios/nova/boot_ljy.yaml

猜你喜欢

转载自www.cnblogs.com/shiyw/p/12373294.html