OpenStack development environment and code testing

Source: Internet
Author: User
Tags virtual environment virtualenv

One, OpenStack single component development environment

1, Python Virtual environment construction

Description

The Python virtual environment is primarily an isolated environment that corresponds to a python third-party library in the system, where you can install programs and rely on libraries without affecting the libraries in your system. So, we can build a Python virtual environment and then install OpenStack components into a virtual environment for development and testing in a virtual environment!

Installation:

Yum Install python-virtualenv   #centos系统下
Or
Pip Install virtualenv #使用pip工具安装

To create and use a virtual environment:

 virtualenv virtenv              #virtenv为虚拟环境目录source virtenv/bin/activate     #启动虚拟环境, The command-line prompt will have a "(virtenv)" Indication to enter the virtual environment
pip Install ... #在虚拟环境中安装程序 ...

Virtual Environment directory:

Contains bin, include, Lib, lib64, all of which are virtual mappings to the corresponding folder in the/usr directory

Precautions:
Python executable Header #! If you list a specific Python path, you indicate an environment that you can specify as #!/usr/bin/env python if you want it to span a virtual environment

2. Python Unit Test

High-quality code writing is certainly inseparable from unit testing, Python's standard libraries and third-party libraries provide support for many unit tests, mainly listed in the following two:

1) unittest (Python standard library)

Https://docs.python.org/2/library/unittest.html?highlight=unittest#module-unittest

2) TestTools (extended and enhanced for unittest, more powerful)

http://testtools.readthedocs.org/en/latest/

3. The OpenStack Component development environment is specifically built

1) use git clone to download the source Library

2) Create a Python virtual environment in the source repository directory

3) Mounting component dependencies and components

Install -install -R test-requirements.txt
Site-packages Directory of Component source code virtual environment in CP Source Library

4) Run the unit test case in the source code of the component

python XXX

Description

The above steps follow the instructions of the OpenStack official documentation and code, which differ in detail in the developer documentation for each of the OpenStack components (http://docs.openstack.org/developer/ openstack-projects.html) have described how to build a development environment and do testing, OpenStack has actually written the above steps as a script, can run directly, but considering the reasons for the network download, so the above step to make the way to facilitate errors. The following are the official documents in this regard:

Https://wiki.openstack.org/wiki/Testing#Unit_Tests

(where the TOX test tool is used, TOX can deploy engineering and specified dependencies to a virtual environment and run all of the test cases you set up, simulating the actual deployment of the project after the test, the main reference: https://testrun.org/tox/latest/index.html)

Second, OpenStack integrated development Environment

1. Deploy a complete OpenStack platform environment using Packstack or Devstack

2. OpenStack Integration Testing

1) Copy the executable startup script of the component under test to the Bin directory of the component virtual environment

2) Stop the original running test component in the platform

3) Enter the component virtual environment and execute the startup script of the component under test, at which point the component program to be tested in the virtual environment can be run at the terminal.

4) operation and testing in the platform

Description

Basic reference to the OpenStack official program, this section of the official documentation is mainly about: https://wiki.openstack.org/wiki/Testing#IntegrationTests ( The main use of devstack for OpenStack installation, and then in the actual running environment for code testing! )

OpenStack development environment and code testing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.