[openstack-dev] [Neutron][oslo.db] Inspecting sqlite db during unit tests

Carl Baldwin carl at ecbaldwin.net
Thu Jul 21 20:45:44 UTC 2016


Hi,

In Neutron, we run unit tests with an in-memory sqlite instance. It is
impossible, as far as I know, to inspect this database using the sqlite3
command line while the unit tests are running. So, we have to resort to
python / sqlalchemy to do it. This is inconvenient.

Months ago, I was able to get the unit tests to write the sqlite db to a
file so that I could inspect it while I was sitting at a breakpoint in the
code. That was very nice. Yesterday, I tried to repeat that while traveling
and was unable to figure it out. I had to time box my effort to move on to
other things.

As far as I remember, the mechanism that I used was to adjust the
neutron.conf for the tests [1]. I'm not totally sure about this because I
didn't take sufficient notes, I think because it was pretty easy to figure
it out at the time. This mechanism doesn't seem to have any effect these
days. I changed it to 'sqlite:////tmp/unit-test.db' and never saw a file
created there.

I did a little bit of digging and I tried one more thing. That was to
set OS_TEST_DBAPI_ADMIN_CONNECTION='sqlite:////tmp/unit-test.db' in the
environment before running tests. I was encouraged because this caused a
file to be created at that location but the file remained empty for the
duration of the run.

Does anyone know off the top of their head how to get unit tests in Neutron
to use a file based sqlite db?

Carl

[1]
https://github.com/openstack/neutron/blob/97c491294cf9eca0921336719d62d74ec4e1fa96/neutron/tests/etc/neutron.conf#L26
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160721/1bb49a52/attachment.html>


More information about the OpenStack-dev mailing list