← Back to team overview

launchpad-dev team mailing list archive

Re: [Branch ~launchpad-pqm/launchpad/devel] Rev 10575: [r=gary][ui=none] Make it possible to use launchpadlib in web service

 

On Fri, 2010-03-26 at 12:41 +1300, Michael Hudson wrote:
> On 25/03/10 01:22, noreply@xxxxxxxxxxxxx wrote:
> [snip]
> 3) (this is the novel and exciting bit) For reasons that are not 
> entirely clear[1] it causes running 
> test_dir_construction_and_trivial_running from 
> canonical.launchpad.testing.tests.test_pages.TestMakeStoryTest to kill 
> the test suite run:
> 
> Running canonical.testing.layers.PageTestLayer tests:
> [snip horrors]
>   File "/home/mwh/canonical/checkouts/trunk/lib/canonical/testing/layers.py", line 728, in testTearDown
>     DatabaseLayer.connect().close()
>   File "/home/mwh/canonical/checkouts/trunk/lib/canonical/testing/profiled.py", line 29, in profiled_func
>     return func(cls, *args, **kw)
>   File "/home/mwh/canonical/checkouts/trunk/lib/canonical/testing/layers.py", line 804, in connect
>     return LaunchpadTestSetup().connect()
>   File "/home/mwh/canonical/checkouts/trunk/lib/canonical/ftests/pgsql.py", line 270, in connect
>     self._connectionString(self.dbname, self.dbuser)
>   File "/home/mwh/canonical/checkouts/trunk/lib/canonical/ftests/pgsql.py", line 123, in fake_connect
>     return ConnectionWrapper(_org_connect(*args, **kw))
> psycopg2.OperationalError: FATAL:  database "launchpad_ftest" does not exist

This is because test_dir_construction_and_trivial_running creates and
runs a nested test suite. The completion of the last test in the
sub-suite triggers a DatabaseLayer.testTearDown(). The test containing
the suite then ends, triggering another DL.tTD(). DL.tTD() previously
did nothing in either case, because the tests in the sub-suite were
no-ops which did not commit, so the DB was never marked as dirty, and
PgTestSetup optimised away the DB destruction.

But the Launchpad.login changes this -- it will probably commit at least
once, to register the usage of the OAuth nonce. A simple
browser.open('https://launchpad.dev') in one of the tests also triggers
the crash, since it commits to the session DB and a couple of other
places for not-very-good reasons.





References