[openstack-dev] [Neutron][oslo.db] Inspecting sqlite db during unit tests
Mike Bayer
mbayer at redhat.com
Fri Jul 22 14:47:38 UTC 2016
On 07/22/2016 04:02 AM, Kevin Benton wrote:
> Now that we have switched to oslo.db for test provisioning the
> responsibility of choosing a location lands
> here: https://github.com/openstack/oslo.db/blob/a79479088029e4fa51def91cb36bc652356462b6/oslo_db/sqlalchemy/provision.py#L505
>
> The problem is that when you specify OS_TEST_DBAPI_ADMIN_CONNECTION it
> does end up creating the file, but then the logic above chooses a URL
> based on the random ident. So you can find an sqlite file in your tmp
> dir, it just won't be the one you asked for.
>
> It seems like a bug in the oslo.db logic, but the commit that added it
> was part of a much larger refactor so I'm not sure if it was intentional
> to ensure that no two tests used the same db.
it is, the testr system runs tests in multiple subprocesses and I think
neutron has it set to four. if they all shared the same sqlite database
file you'd have failed tests.
>
> On Thu, Jul 21, 2016 at 1:45 PM, Carl Baldwin <carl at ecbaldwin.net
> <mailto:carl at ecbaldwin.net>> wrote:
>
> 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
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe:
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> <http://OpenStack-dev-request@lists.openstack.org?subject:unsubscribe>
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
>
>
> __________________________________________________________________________
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
More information about the OpenStack-dev
mailing list