Merge lp:~vila/bzr/1451448-skip-racy-tests into lp:bzr

Proposed by Vincent Ladeuil
Status: Merged
Approved by: Richard Wilbur
Approved revision: no longer in the source branch.
Merged at revision: 6604
Proposed branch: lp:~vila/bzr/1451448-skip-racy-tests
Merge into: lp:bzr
Diff against target: 137 lines (+35/-7)
5 files modified
bzrlib/tests/test_http.py (+18/-3)
bzrlib/tests/test_osutils.py (+3/-1)
bzrlib/tests/test_transport.py (+2/-1)
bzrlib/tests/test_urlutils.py (+3/-2)
doc/en/release-notes/bzr-2.7.txt (+9/-0)
To merge this branch: bzr merge lp:~vila/bzr/1451448-skip-racy-tests
Reviewer Review Type Date Requested Status
Richard Wilbur Approve
Review via email: mp+270266@code.launchpad.net

Commit message

Fix test failures blocking package builds.

Description of the change

This MP fixes the failures encountered since python 2.7.9 (see bug).

The http tests are the most trivial http tests so I'm confident the code is ok and that a *new* race is exposed. Moreover it's exposed only when the http client and server are running in the same thread.

I also skip the windows tests are this needs to be fixed and tested on windows (and I don't have access to a windows host) and that shouldn't block other platforms.

To post a comment you must log in.
Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

Thanks for the fixes, Vincent. Both situations seem suspect: running the http client and server in the same thread seems prone to races, running windows filesystem-specific tests on a non-windows filesystem sounds like it would be likely to fail.
+1

review: Approve
Revision history for this message
Vincent Ladeuil (vila) wrote :

Thanks for the review.

> Thanks for the fixes, Vincent. Both situations seem suspect:

> running the http client and server in the same thread seems prone to races,

Historically, all client/server tests has been written this way since day one. It took years to run into the races and realize the root cause was that the python library was not intended to support both the client and the server in this context.

So, after the fact, it seems obvious that this was a bad design decision but the thing is: when everything works and once in a blue moon a test fails, nobody suspects that design... ;)

> running
> windows filesystem-specific tests on a non-windows filesystem sounds like it
> would be likely to fail.

Well, history again, it was easier at one point to be able to run those tests on ubuntu to make sure the windows support wasn't regressing until tests can be run there. Nowadays... it's more complicated.

Hope this shed some light on the past ;)

Revision history for this message
Richard Wilbur (richard-wilbur) wrote :

On Mon, Sep 7, 2015 at 2:32 AM, Vincent Ladeuil <email address hidden> wrote:
> Thanks for the review.

I'm down to one machine that boots off a CD (won't boot from HD any
more :(, so I get on to check my E-mail but haven't bothered trying to
set up hydrazine, etc. Thus I can review and Approve, but not merge
till I finish fixing at least one of these machines.

[...]
> Hope this shed some light on the past ;)

I quite appreciate the history lesson. Thank you!

Can you send this to PQM? If not, let me know and it will be a good
excuse to concentrate on fixing at least one of my computers.

Revision history for this message
Vincent Ladeuil (vila) wrote :

> On Mon, Sep 7, 2015 at 2:32 AM, Vincent Ladeuil <email address hidden> wrote:
> > Thanks for the review.
>
> I'm down to one machine that boots off a CD (won't boot from HD any
> more :(,

:-/

> so I get on to check my E-mail but haven't bothered trying to
> set up hydrazine, etc. Thus I can review and Approve, but not merge
> till I finish fixing at least one of these machines.

ack.

>
> [...]
> > Hope this shed some light on the past ;)
>
> I quite appreciate the history lesson. Thank you!
>
> Can you send this to PQM? If not, let me know and it will be a good
> excuse to concentrate on fixing at least one of my computers.

Still waiting for PQM to resurrect (the related ticket priority has been bumped so crossed-fingers-hoping the fix will happen rsn).

Revision history for this message
Vincent Ladeuil (vila) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bzrlib/tests/test_http.py'
--- bzrlib/tests/test_http.py 2012-09-17 06:58:15 +0000
+++ bzrlib/tests/test_http.py 2015-09-08 08:00:02 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2011 Canonical Ltd1# Copyright (C) 2005-2012, 2015 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -656,13 +656,28 @@
656656
657 _req_handler_class = BadStatusRequestHandler657 _req_handler_class = BadStatusRequestHandler
658658
659 def setUp(self):
660 super(TestBadStatusServer, self).setUp()
661 # See https://bugs.launchpad.net/bzr/+bug/1451448 for details.
662 # TD;LR: Running both a TCP client and server in the same process and
663 # thread uncovers a race in python. The fix is to run the server in a
664 # different process. Trying to fix yet another race here is not worth
665 # the effort. -- vila 2015-09-06
666 if 'HTTP/1.0' in self.id():
667 raise tests.TestSkipped(
668 'Client/Server in the same process and thread can hang')
669
659 def test_http_has(self):670 def test_http_has(self):
660 t = self.get_readonly_transport()671 t = self.get_readonly_transport()
661 self.assertRaises(errors.InvalidHttpResponse, t.has, 'foo/bar')672 self.assertRaises((errors.ConnectionError, errors.ConnectionReset,
673 errors.InvalidHttpResponse),
674 t.has, 'foo/bar')
662675
663 def test_http_get(self):676 def test_http_get(self):
664 t = self.get_readonly_transport()677 t = self.get_readonly_transport()
665 self.assertRaises(errors.InvalidHttpResponse, t.get, 'foo/bar')678 self.assertRaises((errors.ConnectionError, errors.ConnectionReset,
679 errors.InvalidHttpResponse),
680 t.get, 'foo/bar')
666681
667682
668class InvalidStatusRequestHandler(http_server.TestingHTTPRequestHandler):683class InvalidStatusRequestHandler(http_server.TestingHTTPRequestHandler):
669684
=== modified file 'bzrlib/tests/test_osutils.py'
--- bzrlib/tests/test_osutils.py 2014-04-09 08:05:23 +0000
+++ bzrlib/tests/test_osutils.py 2015-09-08 08:00:02 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2011 Canonical Ltd1# Copyright (C) 2005-2015 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -925,6 +925,7 @@
925 """Test that _win32 versions of os utilities return appropriate paths."""925 """Test that _win32 versions of os utilities return appropriate paths."""
926926
927 def test_abspath(self):927 def test_abspath(self):
928 self.requireFeature(features.win32_feature)
928 self.assertEqual('C:/foo', osutils._win32_abspath('C:\\foo'))929 self.assertEqual('C:/foo', osutils._win32_abspath('C:\\foo'))
929 self.assertEqual('C:/foo', osutils._win32_abspath('C:/foo'))930 self.assertEqual('C:/foo', osutils._win32_abspath('C:/foo'))
930 self.assertEqual('//HOST/path', osutils._win32_abspath(r'\\HOST\path'))931 self.assertEqual('//HOST/path', osutils._win32_abspath(r'\\HOST\path'))
@@ -977,6 +978,7 @@
977 self.assertEqual('C:\\foo', osutils._win32_fixdrive('c:\\foo'))978 self.assertEqual('C:\\foo', osutils._win32_fixdrive('c:\\foo'))
978979
979 def test_win98_abspath(self):980 def test_win98_abspath(self):
981 self.requireFeature(features.win32_feature)
980 # absolute path982 # absolute path
981 self.assertEqual('C:/foo', osutils._win98_abspath('C:\\foo'))983 self.assertEqual('C:/foo', osutils._win98_abspath('C:\\foo'))
982 self.assertEqual('C:/foo', osutils._win98_abspath('C:/foo'))984 self.assertEqual('C:/foo', osutils._win98_abspath('C:/foo'))
983985
=== modified file 'bzrlib/tests/test_transport.py'
--- bzrlib/tests/test_transport.py 2011-12-14 19:44:40 +0000
+++ bzrlib/tests/test_transport.py 2015-09-08 08:00:02 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2005-2011 Canonical Ltd1# Copyright (C) 2005-2011, 2015 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -815,6 +815,7 @@
815class TestWin32LocalTransport(tests.TestCase):815class TestWin32LocalTransport(tests.TestCase):
816816
817 def test_unc_clone_to_root(self):817 def test_unc_clone_to_root(self):
818 self.requireFeature(features.win32_feature)
818 # Win32 UNC path like \\HOST\path819 # Win32 UNC path like \\HOST\path
819 # clone to root should stop at least at \\HOST part820 # clone to root should stop at least at \\HOST part
820 # not on \\821 # not on \\
821822
=== modified file 'bzrlib/tests/test_urlutils.py'
--- bzrlib/tests/test_urlutils.py 2012-01-05 13:02:31 +0000
+++ bzrlib/tests/test_urlutils.py 2015-09-08 08:00:02 +0000
@@ -1,4 +1,4 @@
1# Copyright (C) 2006-2012 Canonical Ltd1# Copyright (C) 2006-2012, 2015 Canonical Ltd
2#2#
3# This program is free software; you can redistribute it and/or modify3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by4# it under the terms of the GNU General Public License as published by
@@ -26,7 +26,7 @@
26 InvalidRebaseURLs,26 InvalidRebaseURLs,
27 PathNotChild,27 PathNotChild,
28 )28 )
29from bzrlib.tests import TestCaseInTempDir, TestCase, TestSkipped29from bzrlib.tests import features, TestCaseInTempDir, TestCase, TestSkipped
3030
3131
32class TestUrlToPath(TestCase):32class TestUrlToPath(TestCase):
@@ -411,6 +411,7 @@
411 self.assertFalse(isinstance(result, unicode))411 self.assertFalse(isinstance(result, unicode))
412412
413 def test_win32_unc_path_to_url(self):413 def test_win32_unc_path_to_url(self):
414 self.requireFeature(features.win32_feature)
414 to_url = urlutils._win32_local_path_to_url415 to_url = urlutils._win32_local_path_to_url
415 self.assertEqual('file://HOST/path',416 self.assertEqual('file://HOST/path',
416 to_url(r'\\HOST\path'))417 to_url(r'\\HOST\path'))
417418
=== modified file 'doc/en/release-notes/bzr-2.7.txt'
--- doc/en/release-notes/bzr-2.7.txt 2014-12-15 20:24:42 +0000
+++ doc/en/release-notes/bzr-2.7.txt 2015-09-08 08:00:02 +0000
@@ -76,6 +76,11 @@
76 suite. This can include new facilities for writing tests, fixes to 76 suite. This can include new facilities for writing tests, fixes to
77 spurious test failures and changes to the way things should be tested.77 spurious test failures and changes to the way things should be tested.
7878
79* Fix racy http tests (TestBadStatusServer is so simple, it exposes a race
80 in python 2.7.9. This happens only when both the http server and client
81 are run in the same process.). Only tests are affected.
82 (Vincent Ladeuil, #1451448)
83
79* Fix warnings on stderr caused by the atexit handler triggering for the84* Fix warnings on stderr caused by the atexit handler triggering for the
80 wrong reason: the 'config' command should explicitly save the changes when85 wrong reason: the 'config' command should explicitly save the changes when
81 modifying or removing an option and not rely on the atexit86 modifying or removing an option and not rely on the atexit
@@ -93,5 +98,9 @@
93* Restrict access to '.netrc' in tests or recent python (2.7.5-8) will98* Restrict access to '.netrc' in tests or recent python (2.7.5-8) will
94 complain. (Vincent Ladeuil, #1233413)99 complain. (Vincent Ladeuil, #1233413)
95100
101* Skip windows-only tests that start failing with python 2.7.9, there is no
102 way to fix them without testing on windows itself.
103 (Vincent Ladeuil, #1451448)
104
96..105..
97 vim: tw=74 ft=rst ff=unix106 vim: tw=74 ft=rst ff=unix