Grokking OpenStack

OpenStack - little pieces


When I first started developing with my Devstack installation I was told to use ./ to run the test suite and that was good enough for me. Then I began to see some other commands to run tests, tox -epy27, tox -epep8 and I ran the commands but didn’t fully understand why some commands are better than others.

Then I had to run some tests in /opt/stack/nova and every command I ran failed. Why? I didn’t know. But now I do.

Recently there has been a move in the repos to testr from nosetests. I got caught in this and have learned a bit about how to dig myself out of this hole.

First of all I am running Ubuntu 12.04 and when I first installed the OS I also installed: apt-get install git libxml2-dev libxslt1-dev and after installing devstack I installed tox with pip install tox. I also had python 2.7 on my machine and wanted to install 2.6 for testing which I did with apt-get install python-software-properties, add-apt-repository ppa:j5-dev/python2.6, apt-get update, apt-get install python2.6 python2.6-dev. I also learned I needed the mysql development libraries which I got with apt-get install mysql-client libmysqlclient-dev.

So I followed my current workflow upon cd’ing into a new directory: git status, git pull, rm -rf .venv, sudo python install. Then I tried both ./ which failed and tox which failed.

I found out that the “Error: pg_config executable not found.” in my output was due to missing the libpq-dev in Ubuntu (rhel is postgresql-devel).

I also learned that this error output “Please install a more recent version first, using ‘easy_install -U distribute’.” suggesting that running easy_install -U distribute might solve the problem didn’t for me. Distribute is bundled by virtualenv which is used by tox. The solution? Upgrade tox with pip install tox --upgrade.

Also when running tox if I got an error “invalid command ‘testr’” I learned that tox -r will create an updated test environment using testr and the tests passed for me. So if I run tox -r I don’t need to remove the virtual environment with rm -rf .venv since the -r flag to tox will rebuild venv from stratch.

So right now my workflow is to run tests with tox which runs tests against python 2.6 and 2.7 (since I have both installed) and pep8 or tox -epy26 for just testing against python 2.6, tox -epy27 for testing just against python 2.7 and tox -epep8 for just running the pep8 tests. If you are inclined, taking a peek into tox.ini will show you the configuration for the different environments. Some tox environments are not run by default but can be helpful for debugging and cleanup, an example would be pyflakes.

I hope this information is helpful to you.

Thanks for supporting this GNOME OPW intern,
Anita Kuno.