• Python学习总结 11 使用tempest测试OpenStack


    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格式

    安装与使用参考文档  http://docs.OpenStack.org/developer/tempest/overview.html

    下载tempest

    # git clone https://github.com/openstack/tempest.git  
    # cd tempest   
    # python setup.py install  
    # pip install -r requirements.txt  

    生成配置文件

    # pip install tox  
    # sudo apt-get install curl # tox
    -egenconfig # cp etc/{tempest.conf.sample,tempest.conf}

    编辑tempest.conf 文件
    参考文档  http://docs.openstack.org/developer/tempest/configuration.html#tempest-configuration

    [root@localhost tempest]# grep ^[^#] etc/tempest.conf  
    [DEFAULT]  
    [alarming]  
    [auth]  
    use_dynamic_credentials = true  
    tempest_roles = admin  
    admin_username = admin  
    admin_project_name = admin  
    admin_password = admin  
    admin_domain_name = default  
    [baremetal]  
    [compute]  
    image_ref = CentOS-7-x86_64  
    flavor_ref = 1  
    flavor_ref_alt = 2  
    [compute-feature-enabled]  
    [dashboard]  
    dashboard_url = http://192.168.132.250/  
    login_url = http://192.168.132.250/auth/login/  
    [data-processing]  
    catalog_type = identity  
    [data-processing-feature-enabled]  
    [database]  
    [debug]  
    [identity]  
    uri = http://192.168.132.250:5000/v3  
    uri_v3 = http://192.168.132.250:5000/v3  
    auth_version = v3  
    username = admin  
    project_name = admin  
    in_role = admin  
    password = admin  
    domain_name = default  
    default_domain_id = default  
    [identity-feature-enabled]  
    api_v3 = true  
    [image]  
    [image-feature-enabled]  
    [input-scenario]  
    [negative]  
    [network]  
    [network-feature-enabled]  
    [object-storage]  
    [object-storage-feature-enabled]  
    [orchestration]  
    [oslo_concurrency]  
    [scenario]  
    [service_available]  
    [stress]  
    [telemetry]  
    [telemetry-feature-enabled]  
    [validation]  
    [volume]  
    [volume-feature-enabled]  

    2, 安装 tempest

    $ git clone https://github.com/openstack/tempest/ # 下载源码$ pip install tempest # 安装tempest项目
    如果pip install 报错,比如某个Python包版本冲突或者之类的,可以先执行下$ pip install -r tempest/requirements.txt # 安装Python依赖包
    然后再执行$ pip install tempest

       还需要安装一下模块。

    pip install nose 

    pip install oslo.log

    pip install testrepository

    pip install paramiko

      安装urllib3

    wget https://pypi.python.org/packages/3b/f0/e763169124e3f5db0926bc3dbfcd580a105f9ca44cf5d8e6c7a803c9f6b5/urllib3-1.16.tar.gz#md5=fcaab1c5385c57deeb7053d3d7d81d59
    tar xvf urllib3-1.16.tar.gz  && cd urllib3-1.16/
    python setup.py install

    3, 初始化 Tempest

    http://www.tuicool.com/articles/VzmInaR

    4,Tempest Coding Guide

    https://docs.openstack.org/developer/tempest/HACKING.html

    5, 执行部分测试用例

    testr run tempest.api.compute.admin.test_delete_server.py

    6,运行测试
    执行所有测试

    nosetests tempest

    执行某一个包下的测试

    nosetests tempest/tests/identity

    执行一个测试代码

    nosetests tempest/api/identity/v3/test_projects.py  
  • 相关阅读:
    python之访问限制机制
    python之property装饰器
    python之封装、组合
    python中classmethod和staticmethod
    (专题一)01 matlab基础
    代数运算
    点运算
    研究生学习安排2019/6/6
    图像处理中创建CDib类时无法选择基类类型时怎么办
    04 学习java养成良好的写作习惯
  • 原文地址:https://www.cnblogs.com/wangshuo1/p/7058423.html
Copyright © 2020-2023  润新知