[openstack-dev] un-hardcoding sql_connection for unit tests
Flavio Percoco
flavio at redhat.com
Wed May 8 07:01:35 UTC 2013
On 07/05/13 16:22 -0400, David Ripton wrote:
>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.)
>
Makes sense.
For glance we have GLANCE_TEST_SQL_CONNECTION env var, which is used
by functional tests. We're on our way to re-factor those so, it seems
like a good time to make this happen as well.
>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.)
I use tox, it is indeed a bit slower than run_tests but it keeps test
environments separated.
>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?
>
Ditto.
Seems fair to align the name of the variable.
Cheers,
FF
--
{ name: "Flavio Percoco",
gpg: "87112EC1",
internal: "8261386",
phone: "+390687502386",
irc: ["fpercoco", "flaper87"]}
More information about the OpenStack-dev
mailing list