[openstack-dev] un-hardcoding sql_connection for unit tests

David Ripton dripton at redhat.com
Tue May 7 20:22:44 UTC 2013


Currently unit tests tend to hardcode 'sql_connection = "sqlite://"', 
which means an in-memory SQLite database.  This is a good default 
because it's fast and requires minimal configuration.  But it means we 
don't catch errors that only happen on MySQL and/or PostgreSQL 
early/often/easily enough.  (The tempest functional tests catch some of 
them, later.)

I'd like to have an easy way to modify the sql_connection for a unit 
test run.  One use case is to use SQLite with a file, so that you can 
dig around in the database after a test fails, to see what happened. 
Another is to use MySQL or PostgreSQL.  (In the long run I'd like our CI 
infrastructure to run all unit tests against all 3 databases.)

Last I heard, tox is the current preferred method of running OpenStack 
unit tests.  (But run_tests.sh is still around, and nose still works for 
some simple cases.)  Because we're using a variety of test runners, 
command-line options don't work so well.  Mangling a conf file and then 
copying back the old version when we're done doesn't seem so elegant. 
I'd really like to use an environment variable, but oslo.config doesn't 
currently support them.  (And adding them to oslo.config seems 
problematic, since it supports multiple ini files, and ini files contain 
multiple sections, so we'd be collapsing two levels of namespacing into 
a string.)

Do people think it's reasonable for me to hack support for an 
environment variable (probably OPENSTACK_SQL_CONNECTION) into our unit 
test infrastructure, or does someone have a better idea?

-- 
David Ripton   Red Hat   dripton at redhat.com



More information about the OpenStack-dev mailing list