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.
There is also a very recent commit to Neutron at https://review.openstack.org/#/c/332476/ , which I think changes the system to actually use the provisioning for the SQLite database as well, whereas before it might have been not taking effect. But in any case, the OS_TEST_DBAPI_ADMIN_CONNECTION thing still works in that if you give it a file-based URL, provisioning should be putting the database files in /tmp. If your approach is "pdb.set_trace(); then look at the file", just do this:
$ OS_TEST_DBAPI_ADMIN_CONNECTION=sqlite:///myfile.db .tox/functional/bin/python -m unittest neutron.tests.unit.db.test_db_base_plugin_v2.TestBasicGet.test_single_get_admin
> /home/classic/dev/redhat/openstack/neutron/neutron/tests/unit/db/test_db_base_plugin_v2.py(790)test_single_get_admin()
-> plugin = neutron.db.db_base_plugin_v2.NeutronDbPluginV2() (Pdb) (Pdb) self.engine.url sqlite:////tmp/hjbckefatl.db then you can "sqlite3 /tmp/hjbckefatl.db" while the test is pending.
On Thu, Jul 21, 2016 at 1:45 PM, Carl Baldwin <c...@ecbaldwin.net <mailto:c...@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-requ...@lists.openstack.org?subject:unsubscribe <http://openstack-dev-requ...@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-requ...@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-requ...@lists.openstack.org?subject:unsubscribe http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev