OpenStack unit tests 环境调试
大多数情况下修改OpenSTack community 的各个project source code 需要提交对应的unit test, 但是由于dependency的环境版本变化,unit test会失败,本文简单介绍如何运行/project/run_tests.sh.
以OpenStack/Neutron 为例 :
使用虚拟环境安装包
# /opt/stack/neutron/requirements.txt 是neutron project下依赖的安装包
tools/with_venv.sh pip install -r /opt/stack/neutron/requirements.txt
# /opt/stack/neutron/test_requirements.txt 是neutron project下依赖的测试安装包
tools/with_venv.sh pip install -r /opt/stack/neutron/test_requirements.txt
不使用虚拟环境
pip install --upgrade -r requirements.txt
pip install --upgrade -r test-requirements.txt
升级
tools/with_venv.sh pip install --upgrade /opt/stack/neutron/requirements.txt
tools/with_venv.sh pip install --upgrade /opt/stack/neutron/test_requirements.txt
显示结果 :
Successfully installed amqplib jsonrpclib python-neutronclient alembic six Mako
Cleaning up...
测试project下所有的test cases
root@ubuntu:/opt/stack/heat#./run_tests.sh
....
测试 /heat/tests/test_instance.py
root@ubuntu:/opt/stack/heat# ./run_tests.sh heat.tests.test_instance
结果输出包含所有“test_instance”关键字
Ran 106 (-1407) tests in 2.115s (-53.826s)
PASSED (id=12)
Slowest Tests
Test id Runtime (s)
-------------------------------------------------------------------------------------------------------- -----------
heat.tests.test_instance_group_update_policy.InstanceGroupTest.test_instance_group_update 0.340
heat.tests.test_instance_group_update_policy.InstanceGroupTest.test_instance_group_update_policy_removed 0.318
heat.tests.test_instance.InstancesTest.test_build_nics 0.274
heat.tests.test_instance_group.InstanceGroupTest.test_handle_update_size 0.255
heat.tests.test_instance.InstancesTest.test_instance_create_duplicate_image_name_err 0.236
heat.tests.test_instance_group.InstanceGroupTest.test_update_error 0.149
heat.tests.test_instance.InstancesTest.test_instance_update_instance_type_failed 0.117
heat.tests.test_instance_group.InstanceGroupTest.test_update_fail_badkey 0.115
heat.tests.test_instance_group.InstanceGroupTest.test_update_fail_badprop 0.111
heat.tests.test_instance_group.InstanceGroupTest.test_create_error 0.086
测试/heat/tests/test_instance.py中的InstancesTest类
root@ubuntu:/opt/stack/heat# ./run_tests.sh heat.tests.test_instance.InstancesTest
Ran 68 (+15) tests in 1.305s (-0.802s)
PASSED (id=13)
Slowest Tests
Test id Runtime (s)
-------------------------------------------------------------------------------- -----------
heat.tests.test_instance.InstancesTest.test_instance_create 0.266
heat.tests.test_instance.InstancesTest.test_build_nics 0.256
heat.tests.test_instance.InstancesTest.test_instance_update_instance_type_failed 0.140
heat.tests.test_instance.InstancesTest.test_instance_create_unexpected_status 0.138
heat.tests.test_instance.InstancesTest.test_instance_status_verify_resize 0.110
heat.tests.test_instance.InstancesTest.test_instance_status_password 0.086
heat.tests.test_instance.InstancesTest.test_instance_status_rescue 0.085
heat.tests.test_instance.InstancesTest.test_instance_status_resize 0.081
heat.tests.test_instance.InstancesTest.test_instance_resume_volumes_step 0.075
heat.tests.test_instance.InstancesTest.test_instance_suspend_volumes_step 0.074
测试/heat/tests/test_instance.py中的InstancesTest类的test_build_nics方法
Ran 2 (-32) tests in 0.191s (-1.106s)
PASSED (id=14)
Slowest Tests
Test id Runtime (s)
------------------------------------------------------ -----------
heat.tests.test_instance.InstancesTest.test_build_nics 0.188
错误解决
1.AttributeError: 'module' object has no attribute 'DeprecatedOpt'
======================================================================
FAIL: unittest.loader.ModuleImportFailure.neutron.tests.unit.test_security_groups_rpc
unittest.loader.ModuleImportFailure.neutron.tests.unit.test_security_groups_rpc
----------------------------------------------------------------------
_StringException: ImportError: Failed to import test module: neutron.tests.unit.test_security_groups_rpc
Traceback (most recent call last):File "/usr/lib/python2.7/unittest/loader.py", line 252, in _find_testsmodule = self._get_module_from_name(name)File "/usr/lib/python2.7/unittest/loader.py", line 230, in _get_module_from_name__import__(name)File "/opt/stack/neutron/neutron/tests/unit/test_security_groups_rpc.py", line 29, in <module>from neutron import contextFile "/opt/stack/neutron/neutron/context.py", line 24, in <module>from neutron.db import api as db_apiFile "/opt/stack/neutron/neutron/db/api.py", line 22, in <module>from neutron.db import model_baseFile "/opt/stack/neutron/neutron/db/model_base.py", line 19, in <module>from neutron.openstack.common.db.sqlalchemy import modelsFile "/opt/stack/neutron/neutron/openstack/common/db/sqlalchemy/models.py", line 29, in <module>from neutron.openstack.common.db.sqlalchemy.session import get_sessionFile "/opt/stack/neutron/neutron/openstack/common/db/sqlalchemy/session.py", line 283, in <module>deprecated_opts=[cfg.DeprecatedOpt('sql_connection',
AttributeError: 'module' object has no attribute 'DeprecatedOpt'
解决方法: (来自https://bugs.launchpad.net/tripleo/+bug/1194807)
cd /usr/local/
lib/python2.7/dist-packages/
rm -rf oslo
pip install http://tarballs.openstack.org/oslo.config/oslo.config-1.2.0a2.tar.gz#egg=oslo.config-1.2.0a2
2. No module named webtest
解决方法 :
root@ubuntu:/opt/stack/neutron# pip install webtest
Downloading/unpacking webtestDownloading WebTest-2.0.7.zip (81kB): 81kB downloadedRunning setup.py egg_info for package webtestno previously-included directories found matching 'docs/_build'warning: no previously-included files matching '*.pyc' found anywhere in distributionwarning: no previously-included files matching '__pycache__' found anywhere in distribution
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from webtest)
Requirement already satisfied (use --upgrade to upgrade): WebOb>=1.2 in /usr/local/lib/python2.7/dist-packages (from webtest)
Downloading/unpacking waitress>=0.8.5 (from webtest)Downloading waitress-0.8.7.tar.gz (115kB): 115kB downloadedRunning setup.py egg_info for package waitressDownloading/unpacking beautifulsoup4 (from webtest)Downloading beautifulsoup4-4.3.1.tar.gz (142kB): 142kB downloadedRunning setup.py egg_info for package beautifulsoup4Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/dist-packages (from waitress>=0.8.5->webtest)
Installing collected packages: webtest, waitress, beautifulsoup4Running setup.py install for webtestno previously-included directories found matching 'docs/_build'warning: no previously-included files matching '*.pyc' found anywhere in distributionwarning: no previously-included files matching '__pycache__' found anywhere in distributionRunning setup.py install for waitressInstalling waitress-serve script to /usr/local/binRunning setup.py install for beautifulsoup4Successfully installed webtest waitress beautifulsoup4
Cleaning up...
OpenStack unit tests 环境调试相关推荐
- 建立openstack quantum开发环境 .
建立openstack quantum开发环境 作者:张华 发表于:2012-4-6 版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明 ( http://blog ...
- Android单元测试之Local unit tests(上)
Android单元测试之Local unit tests(上) 简介 本地单元测试 JUnit 4 添加依赖 测试例子 结论 Mockito 添加依赖 测试例子-mock基本使用 测试例子-mock与 ...
- Android 仪器化单元测试(instrumented unit tests) Androidx kotlin版本
前言 近期需要进行单元测试,测试内容需要真机环境,所以需要使用instrumented unit tests,用来在跑在真机上进行测试. 本blog用于记录. 简介 仪器化单元测试(instrumen ...
- 写算子单元测试Writing Unit Tests
写算子单元测试Writing Unit Tests! 一些单元测试示例,可在tests/python/relay/test_op_level3.py中找到,用于累积总和与乘积算子. 梯度算子 梯度算子 ...
- [转]Creating Unit Tests for ASP.NET MVC Applications (C#)
本文转自:http://www.asp.net/mvc/tutorials/older-versions/unit-testing/creating-unit-tests-for-asp-net-mv ...
- Fuel 5.1安装openstack I版本环境 (ESXi)
2019独角兽企业重金招聘Python工程师标准>>> Fuel 简介 Fuel是Mirantis公司开发的部署openstack集群工具,主要功能为裸机PXE安装操作系统,mast ...
- 【云计算OpenStack-OpenStack Queens版本】基于OpenStack的云计算环境搭建
基于OpenStack的云计算环境搭建 一.基础环境 1.基本环境信息回顾 2.基本环境网络测试 二.实现过程 1.配置阿里yum源(所有节点) 2.安装NTP时钟服务(所有节点) 3.opensta ...
- Fun with Unit Tests – Testing abstract classes
Summary In this article I'll be looking into a trickier part of unit testing– testing the functional ...
- pycharm使用docker环境调试的配置步骤
默认已经安装了: docker(并下载好所需要的环境的image镜像) pycharm专业版 步骤: 创建docker的container image和container的关系,类似于类和实例之间的关 ...
最新文章
- 如何在电脑桌面添加计算机网络等,如何实现在电脑桌面上添加文字提醒
- 信号转换问题 | 模拟电路解决方式
- eclipse工程设置项目jre
- 【使用递归玩通关汉诺塔游戏】算法01-递归(斐波那契数列、汉罗塔问题)-java实现
- JAVA中JPasswordField实现密码的确认
- Nacos源码Notifier异步更新
- jsr303自定义验证_JSR 310新日期/时间API的自定义JSR 303 Bean验证约束
- braft的LogEntry日志记录存储LogStorage
- 每周送新书:Python数据分析、SSM框架、Redis深度历险
- 【UVA221】Urban Elevations(建筑物可视问题-数学题)
- 微信小程序云开发实现聊天(聊天室,一对一聊天)
- mac上的实用工具(mac常用工具)
- 小巧的网页聊天工具提供-GOFLY在线客服系统
- 【转载】Markdown编辑器如何在标题上添加序号
- 记忆的分类及其理论模型
- 【迁移学习】Self Paced Adversarial Training for Multimodal Few-shot Learning论文解读
- UEBA中的行为基线分析
- 联想计算机怎么关机,联想笔记本怎么关机
- 对称加密和非对称加密!
- 转:用调制解调器打电话收传真-ModemFax