Thursday, December 26, 2013

Running nova unit tests in pycharm

I use a macbook pro (13" with 8 Gb of Ram) for my openstack development and run Fusion (headless) with ubuntu 12.04 running on that.  In my VM i run devstack pointing to a VC environment which is sitting under my desk at work.  I run samba on the VM and export my filesystem so i can use Pycharm as my IDE.  I also wanted to be able to run unit tests under Pycharm. Working with +Shawn Hartsock I was able to get it all working - but it took a couple of hours.  So i'll document it here for others.

First I needed to install mysql, postgres, and nose on my macbook.  I didn't investigate why i needed 2 different databases.  Once they were installed i made sure that mysql_config and pg_config were in my path.

I then grabbed a copy of nova from git and set up the virtual environment

git clone https://github.com/openstack/nova.git
cd nova
./run_tests.sh 

Since my virtual environment was not created, the script asked to create it and about 1/2 hour later it was all done.

Then i created a new project in pycharm by adding the nova directory and made sure that my python interpreter was pointing to my virtual env for this project.


Then edit your debug/runtime configuration and so it looks like this - i've created a /tmp/lock directory for lock files.


Ready to go - I opened up the tests that i wanted to run -  nova/tests/virt/test_virt.py and right clicked on the run unit tests  


and the tests run.  You will see the ones that passed and failed and can drill down into the failures.  In this case you can see that it's having double with /proc - which doesn't exist on a mac.  +Shawn Hartsock  has a patch for that which will hopefully be upstreamed soon.



I'm hoping this will be useful in my next patches as I try to write tests and code at the same time.  Please update if you follow this and have other issues.  I'll try to keep it updated as I continue using unit tests in pycharm.













No comments:

Post a Comment