Merge lp:~jtv/launchpad/fake-librarian into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Jeroen T. Vermeulen on 2010-08-16 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11380 |
| Proposed branch: | lp:~jtv/launchpad/fake-librarian |
| Merge into: | lp:launchpad |
| Diff against target: |
600 lines (+386/-34) 7 files modified
lib/canonical/launchpad/browser/librarian.py (+3/-2) lib/canonical/librarian/client.py (+18/-10) lib/canonical/librarian/interfaces.py (+21/-7) lib/canonical/librarian/storage.py (+22/-13) lib/canonical/librarian/web.py (+2/-2) lib/lp/testing/fakelibrarian.py (+201/-0) lib/lp/testing/tests/test_fakelibrarian.py (+119/-0) |
| To merge this branch: | bzr merge lp:~jtv/launchpad/fake-librarian |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Gary Poster (community) | Approve on 2010-08-16 | ||
| Curtis Hovey (community) | code | 2010-07-26 | Approve on 2010-08-09 |
|
Review via email:
|
|||
Commit Message
Fake Librarian.
Description of the Change
= Fake Librarian =
This implements a fake librarian that we could use in tests.
The real librarian runs as a separate daemon that needs to be started and managed during test runs, taken up and down in some places (which takes ages), and sometimes manually killed in order to get things running again. It also writes files to the filesystem. In other words, it's lots of stuff we'd rather not have too much of in test runs.
In this branch I propose a simple fake librarian that could replace the real thing in many tests. It runs purely in-process and stores non-persistently, so it has none of that stuff that we don't like. Of course that also means it won't work for tests that fire off sub-processes.
To splice the fake librarian into a test's environment, e.g. in a cut-down LaunchpadLayer, we would ideally:
* Create one global FakeLibrarian object.
* Override the ILibrarianClient utility with the fake librarian.
* Override the ILibraryFileAli
* Register the fake librarian as a transaction synchronizer.
The test would then use the fake librarian instead of the real one.
URLs and remote addition of files are not supported for now, so the fake librarian would be of little use in browser tests for now.
You'll also note that the fake librarian keeps track of whether a file has been committed to storage. This is an idiosyncrasy of the real librarian: any newly added files remain inaccessible until you commit. Stuart noted that it would be best to simulate the real librarian's behaviour here so that we don't hide nasty transaction-
The fake librarian uses the real database objects, just like the original. This means that it should still work when application code goes straight to the database, e.g. by joining or prejoining LibraryFileAlias and/or LibraryFileContent.
At the time of writing I'm sure we'll still want to play with this a bit before considering it for use in our test suite. I'm filing this as a Work-in-Progress MP.
Test with:
{{{
./bin/test -vvc -m lp.testing.
}}}
No lint.
Jeroen
| Gary Poster (gary) wrote : | # |
The changes since Curtis' approval look very good to me.

Thanks to doing this. I am very excited by this. I think it will help the test setup for project release files for the registry.
I have one concern. This will not work our of proc the way it is demonsdtrated. Like config and zcml registryations that happing in tests now, they do not affect an out-of-proc process. I think engineers should know via a comment in the FackLibrarian that it operates only in the current proc.