Merge lp:~salgado/launchpad/fix-distro-bug-reporting-test into lp:~launchpad-committers/launchpad/python-migration

Proposed by Guilherme Salgado
Status: Merged
Approved by: Gary Poster
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~salgado/launchpad/fix-distro-bug-reporting-test
Merge into: lp:~launchpad-committers/launchpad/python-migration
Diff against target: 23 lines
1 file modified
lib/lp/soyuz/scripts/tests/test_copypackage.py (+2/-4)
To merge this branch: bzr merge lp:~salgado/launchpad/fix-distro-bug-reporting-test
Reviewer Review Type Date Requested Status
Gary Poster (community) Approve
Review via email: mp+13479@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Guilherme Salgado (salgado) wrote :

Looks like the librarian socket, in 2.5, is garbage collected right after an
upload, thus breaking test_re_upload_file_does_not_leak_file_descriptors. This
changes the test to not expect the socket to be open. We should probably not
rely on the garbage collector to do this, but fixing the librarian is out of
scope for this.

Revision history for this message
Gary Poster (gary) wrote :

merge-conditional

Hi Salgado. This looks good.

It's not obvious looking at the test in isolation that the re-upload actually worked. You told me on IRC that there is an assertion in getUtility(ILibraryFileAliasSet).create() that the file is created, so we are covered practically. I'd just like a comment in that regard in the test.

Thank you

Gary

review: Approve
Revision history for this message
Guilherme Salgado (salgado) wrote :

Thanks Gary, this is the change I did to the test.

=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-10-16 15:11:05 +0000
+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-10-16 16:41:07 +0000
@@ -161,6 +161,9 @@
         previously_open_files = number_of_open_files()

         public_file = re_upload_file(private_file)
+ # The above call would've raised an error if the upload failed, but
+ # better safe than sorry.
+ self.assertIsNot(None, public_file)

         open_files = number_of_open_files() - previously_open_files
         self.assertEqual(0, open_files)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/scripts/tests/test_copypackage.py'
2--- lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-09-29 17:27:52 +0000
3+++ lib/lp/soyuz/scripts/tests/test_copypackage.py 2009-10-16 15:20:27 +0000
4@@ -152,9 +152,7 @@
5 self.assertFileIsReset(private_file)
6
7 def test_re_upload_file_does_not_leak_file_descriptors(self):
8- # Reuploading a library file doesn't leak file descriptors. The
9- # only extra file opened by the end of the process is the socket
10- # with the librarian server.
11+ # Reuploading a library file doesn't leak file descriptors.
12 private_file = self.factory.makeLibraryFileAlias(restricted=True)
13 transaction.commit()
14
15@@ -165,7 +163,7 @@
16 public_file = re_upload_file(private_file)
17
18 open_files = number_of_open_files() - previously_open_files
19- self.assertEqual(1, open_files)
20+ self.assertEqual(0, open_files)
21
22
23 class UpdateFilesPrivacyTestCase(TestCaseWithFactory):

Subscribers

People subscribed via source and target branches