Marvin ↓ - our automation framework is a Python module that leverages the abilities of python and its multitude of libraries. Tests written using our framework use the unittest module under the hood. The unittest module is the Python version of the unit-testing framework originally developed by Kent Beck et al and will be familiar to the Java people in the form of JUnit. The following document will act as a tutorial introduction to those interested in testing CloudStack with python. This document does not cover the python language and we'll be pointing the reader instead to explore some tutorials that are more thorough on the topic. In the following we will be assuming basic python scripting knowledge from the reader. The reader is encouraged to walk through the steps after he/she has their environment setup and configured.
Environment
Developers
If you are a developer the cloudstack development environment is sufficient to get started
- Checkout the incubator-cloudstack -oss project from git:from incubator-cloudstack.apache.orggit
- You will need Python - version 2.6 to install marvin but 2.7 to run the tests. Additional modules installed by Marvin - python-paramiko, mysql-connector-python, nose
- You should install Eclipse and the PyDev plugin. PyDev features auto-completion and some good documentation on how to install itfor python modules from within the Eclipse environment.
- On the master branch the 'developer' profile compiles, packages and installs Marvin.
Code Block |
---|
mvn -P developer -pl: cloud-apidoc, :cloud-marvin
|
- The mvn deploy goal will install marvin using pip. If not you may install it by hand by pip or easy_install
Code Block |
---|
pip install tools/marvin/dist/Marvin-0.1.0.tar.gz
|
...
If you are a QA engineer you won't need the entire codebase to build marvin.
- Jenkins Jenkins@builds.a.o holds artifacts of the marvin builds and you can download it.
- The artifact (.tar.gz) is available after the build succeeds. Download it.
- On the client machine where you will be writing/running tests from setup the following:
- Install python 2.7 (http://www.python.org/download/releases/)
- Install setuptools. Follow the instructions for your client machine from here(windows/linux/mac)
- (for Windows only) Install pycrypto on Windows because windows does not bundle gcc to compile pycrypto.
- The Marvin artifact you downloaded can now be installed. Any required python packages will be installed automatically
Code Block |
---|
easy_install tools/marvin/dist/Marvin-0.1.0.tar.gz
|
- To test if the installation was successful get into a python shell
Code Block |
---|
root@cloud:~/cloudstack-oss/tools/marvin/dist# python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import marvin
>>> from marvin.cloudstackAPI import *
|
imports should happen without reporting errors.
...
- Verifying status of resources within hypervisors is fine. Most hypervisors provide standard SSH server access
- Your tests should include the complete command and its expected output. ** e.g. iptables -L INPUT -# to list the INPUT chain of iptables
- If you execute multiple commands then all of them should be chained together on one line** e.g: service iptables stop; service iptables start #to stop and start iptables
- Your script must execute over ssh because this is how Marvin will execute it** ssh <target-backend-machine> "<your script>" #should return the output of your script** move the credential specific information into the deployment config file and/or use a standard credential
- Most external devices like F5/ NetScaler have ssh open to execute commands. But you must include the command and its expected output in the test as not everyone is aware of the device's CLI
- If you are using a UI like vCenter to verify something most likely you cannot automate what you see there because there are no ASLv2 licensed libraries for vmware/esx as of today.
...