Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The zone(), pod(), cluster(), host() are plain objects that carry just attributes. For instance a zone consists of the attributes - name, dns entries, network type etc. Within a zone I create pod()s and append them to my zone object, further down creating cluster()s in those pods and appending them to the pod and within the clusters finally my host()s that get appended to my cluster object. Once I have defined all that is necessary to create my cloud I pass on the described configuration to the generate_setup_config() method which gives me my resultant configuration in JSON format.

Sandbox Scripts

You don't always want to describe one hosts configurations in python files so we've included some common examples in the Marvin tarball under the sandbox directory. In the sandbox are configurations of a single host advanced and a sing single host basic zone that can be tailored to your environment using a simple properties file. The property file, setup.properties is contains editable name, value (name=value) pairs that you can change to the IPs, hostnames etc that you have in your environment. The properties file when passed to the python script will generate the JSON configuration for you.

Sample setup.properties:

Code Block
borderStylesolid

[globals

...

]
secstorage.allowed.internal.sites=10.147.28.0/24

...



[environment]
dns=10.147.28.6

...


mshost=localhost

...


mysql.host=localhost

...


mysql.cloud.user=cloud

...


mysql.cloud.passwd=cloud

...



[cloudstack]
private.gateway=10.147.29.1

...


private.pod.startip=10.147.29.150

...


private.pod.endip=10.147.29.159

And generate the JSON config as follows:

Code Block
borderStylesolid

root@cloud:~/incubator-cloudstack/tools/marvin/marvin/sandbox/advanced# python advanced_env.py -i setup.properties -o advanced.cfg

...


root@cloud:~/incubator-cloudstack/tools/marvin/marvin/sandbox/advanced# head -10 advanced.cfg

...


{
    "zones":

...

 [
        {
            "name": "Sandbox-XenServer",

...


            "guestcidraddress": "10.1.1.0/24",

...


            
... <snip/> ...

Marvin Nose Plugin

Nose extends unittest to make testing easier. Nose comes with plugins that help integrating your regular unittests into external build systems, coverage, profiling etc. Marvin comes with its own nose plugin for this so you can use nose to drive CloudStack tests. The plugin can be installed by simply running setuptools in your marvin source directory. Running nosetests -p will show if the plugin registered successfully.

Code Block
borderStylesolid

$ cd /usr/local/lib/python2.7/site-packages/marvin

...


$ easy_install .

...


Processing .

...


Running setup.py -q bdist_egg --dist-dir

...

 
Installed /usr/local/lib/python2.7/dist-packages/marvin_nose-0.1.0-py2.7.egg

...


Processing dependencies for marvin-nose==0.1.0

...


Finished processing dependencies for marvin-nose==0.1.0

...


 
$ nosetests -p

...


Plugin xunit

...


Plugin multiprocess

...


Plugin capture

...


Plugin logcapture

...


Plugin coverage

...


Plugin attributeselector

...


Plugin doctest

...


Plugin profile

...


Plugin collect-only

...


Plugin isolation

...


Plugin pdb

...


Plugin marvin

...




# Usage and running tests

...


$ nosetests --with-marvin --marvin-config=/path/to/basic_zone.cfg --load /path/to/tests

The smoke tests and component tests contain attributes that can be used to filter the tests that you would like to run against your deployment. You would use nose's attrib plugin for this. Currently zone models are

  • advanced - Typical Advanced Zone
  • basic - a basic zone without security groups
  • sg - a basic zone with security groups
  • eip - an elastic ip basic zone
  • advancedns - advanced zone with a netscaler device
  • speed = 0/1/2 (greater the value lesser the speed)
  • multihost/multipods/mulitcluster (test requires multiple set of hosts/pods/clusters)

Python Resources

  1. The single largest python resource is the python website itself - http://www.python.orgImage Modified
  2. Mark Pilgrim's - "Dive Into Python" - is another great resource. The book is available for free online - http://www.diveintopython.netImage Modified. Chapter 1- 6 cover a good portion of language basics and Chapter 13 & 14 are essential for anyone doing test script development
  3. To read more about the assert methods the language reference is the ideal place - http://docs.python.org/library/unittest.htmlImage Modified
  4. Python testing cookbook: We have a local copy that can be shared for internal use only. Please email me.

More Examples

Examples of tests with more backend verification and complete integration of suites for network, snapshots, templates etc can be found in the test/integration/smoke directory. Almost all of these test suites use common library wrappers written around the test framework to simplify writing tests. These libraries are found under test/integration/lib. You may start using these libraries at your convenience but there's no better way than to write the complete API call yourself to understand its behaviour.

The libraries take advantage of the fact that every resource - VirtualMachine, ISO, Template, PublicIp etc follows the pattern of

  • create - where we cause creation of the resource eg: deployVirtualMachine
  • delete - where we delete our resource eg: deleteVolume
  • list - where we look for some state of the resource eg: listPods

Acknowledgements

  • The original author of the testing framework - Edison Su
  • Maintenance and bug fixes - Prasanna Santhanam
  • Documentation - Prasanna and Edison

For any feedback, typo corrections please email Prasanna Santhanam

...