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