Merge lp:~doxxx/bzr/quiet-serve into lp:bzr

Proposed by Gordon Tyler
Status: Superseded
Proposed branch: lp:~doxxx/bzr/quiet-serve
Merge into: lp:bzr
Diff against target: 28 lines (+11/-0)
1 file modified
bzrlib/tests/blackbox/test_serve.py (+11/-0)
To merge this branch: bzr merge lp:~doxxx/bzr/quiet-serve
Reviewer Review Type Date Requested Status
Robert Collins (community) Needs Fixing
Review via email: mp+15076@code.launchpad.net

This proposal has been superseded by a proposal from 2009-11-21.

To post a comment you must log in.
Revision history for this message
Gordon Tyler (doxxx) wrote :

Adds a testcase for bug #252834. The actual bug seems to have been fixed some time ago, but I figured a testcase couldn't hurt.

Revision history for this message
Robert Collins (lifeless) wrote :

Thanks for submitting this. We really prefer to test things close to the
thing under question.

In this particular case, why is a subprocess needed?

 review needsfixing

review: Needs Fixing
Revision history for this message
Gordon Tyler (doxxx) wrote :

I'm not sure, I just followed the example of the other tests in that class. Perhaps it's because if you started it in-process there would be no way to interrupt it and it would hang the tests?

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Gordon Tyler wrote:
> I'm not sure, I just followed the example of the other tests in that class. Perhaps it's because if you started it in-process there would be no way to interrupt it and it would hang the tests?

Also note that if you are using a subprocess that you are going to kill,
then you need to skip the test on windows so it doesn't hang. (At least
until a patch comes along that can use TerminateProcess :)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAksGsZIACgkQJdeBCYSNAAMGlgCdF0kYZpWNZ3DN1H/q6Xp4ZiSS
f9sAoLFJNgWPdpKRaZuCHQoex7al6UMH
=kvJ+
-----END PGP SIGNATURE-----

Revision history for this message
Gordon Tyler (doxxx) wrote :

> Also note that if you are using a subprocess that you are going to kill,
> then you need to skip the test on windows so it doesn't hang. (At least
> until a patch comes along that can use TerminateProcess :)

Note that it says "skip_if_plan_to_signal=True", which means skip on win32 until my other patch lands. ;)

Revision history for this message
Robert Collins (lifeless) wrote :

On Fri, 2009-11-20 at 13:02 +0000, Gordon Tyler wrote:
> I'm not sure, I just followed the example of the other tests in that
> class. Perhaps it's because if you started it in-process there would
> be no way to interrupt it and it would hang the tests?

So, you cargo culted, which is fine :). However this test doesn't need a
subprocess. The other ones did for a few reasons, but I don't see why
this one would.

subprocess tests are very expensive, its an exceptional thing to do to
add one.

-Rob

Revision history for this message
Gordon Tyler (doxxx) wrote :

> So, you cargo culted, which is fine :). However this test doesn't need a
> subprocess. The other ones did for a few reasons, but I don't see why
> this one would.

Can you explain to me why this test doesn't require one? I cannot see a difference between this and the other tests. If the test invokes 'bzr serve' in-process it will block and the tests will hang.

Revision history for this message
Robert Collins (lifeless) wrote :

A couple of ways to prevent that
 - use a server startup hook to trigger shutdown.
 - use a thread

-Rob

Revision history for this message
Gordon Tyler (doxxx) wrote :

> A couple of ways to prevent that
> - use a server startup hook to trigger shutdown.
> - use a thread

Well, silly me, I didn't see the utility functions in TestCmdServeChrooting which do all that. I'll adapt the new testcase to use that.

On a related note, why do the other tests in TestBzrServe launch a subprocess and not do the same thing as TestCmdServeChrooting?

Revision history for this message
Gordon Tyler (doxxx) wrote :

I've been able to adapt the testcase to run the command in-process. I had to get inventive with the KeyboardInterrupt handling so that the testcase could still get the stdout and stderr.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/blackbox/test_serve.py'
2--- bzrlib/tests/blackbox/test_serve.py 2009-11-16 21:36:52 +0000
3+++ bzrlib/tests/blackbox/test_serve.py 2009-11-20 06:35:24 +0000
4@@ -24,6 +24,7 @@
5 import sys
6 import thread
7 import threading
8+import time
9
10 from bzrlib import (
11 builtins,
12@@ -119,6 +120,16 @@
13 url = 'bzr://localhost:%d/' % port
14 self.permit_url(url)
15 return process, url
16+
17+ def test_bzr_serve_quiet(self):
18+ self.make_branch('.')
19+ args = ['serve', '--port', 'localhost:0', '--quiet']
20+ process = self.start_bzr_subprocess(args, skip_if_plan_to_signal=True)
21+ time.sleep(1) # wait for subprocess to (possibly) write to stdout/err
22+ out, err = self.finish_bzr_subprocess(process, retcode=None,
23+ send_signal=signal.SIGTERM)
24+ self.assertEqual('', out)
25+ self.assertEqual('', err)
26
27 def test_bzr_serve_inet_readonly(self):
28 """bzr server should provide a read only filesystem by default."""