Merge lp:~frankban/launchpad/bug-1014907 into lp:launchpad

Proposed by Francesco Banconi on 2012-06-19
Status: Merged
Approved by: Graham Binns on 2012-06-19
Approved revision: no longer in the source branch.
Merged at revision: 15442
Proposed branch: lp:~frankban/launchpad/bug-1014907
Merge into: lp:launchpad
Diff against target: 30 lines (+5/-7)
1 file modified
lib/lp/services/webapp/tests/test_sigusr2.py (+5/-7)
To merge this branch: bzr merge lp:~frankban/launchpad/bug-1014907
Reviewer Review Type Date Requested Status
Graham Binns (community) code 2012-06-19 Approve on 2012-06-19
Review via email: mp+110987@code.launchpad.net

Commit Message

Fixed SIGUSR2TestCase.test_sigusr2 intermittent failure.

Description of the Change

= Summary =

SIGUSR2TestCase.test_sigusr2 fails intermittently/rarely in parallel tests.
This is another timeout issue we are encountering in parallel tests.

== Proposed fix ==

Replace timeout with retries and increase the overall time before raising a
failure.

== Pre-implementation notes ==

I've reproduced the bug using stress, e.g.::

    $ stress --cpu 8 --io 8 --vm 4 --vm-bytes 1000M
    $ w
    09:47:01 up 19:29, 3 users, load average: 20.82, 20.52, 18.39

== Implementation details ==

See proposed fix.

== Tests ==

$ bin/test -cvvt lp.services.webapp.tests.test_sigusr2.SIGUSR2TestCase

NO QA

Linting changed files:
  lib/lp/services/webapp/tests/test_sigusr2.py

To post a comment you must log in.
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/services/webapp/tests/test_sigusr2.py'
2--- lib/lp/services/webapp/tests/test_sigusr2.py 2010-08-20 20:31:18 +0000
3+++ lib/lp/services/webapp/tests/test_sigusr2.py 2012-06-19 09:54:26 +0000
4@@ -31,7 +31,6 @@
5 sys.executable,
6 os.path.join(os.path.dirname(__file__), 'sigusr2.py'),
7 main_log]
8-
9 proc = subprocess.Popen(
10 helper_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
11 try:
12@@ -69,13 +68,12 @@
13 self.assertEqual(open(main_log, 'r').read(), 'Message 3\n')
14
15 def sync(self, step):
16- timeout = 10
17+ retries = 200
18 event_filename = os.path.join(self.logdir, step)
19- start_time = time.time()
20- while time.time() < start_time + timeout:
21+ for i in range(retries):
22 if os.path.exists(event_filename):
23 os.unlink(event_filename)
24 return
25- self.fail("sync step %s didn't happen in %d seconds." % (
26- step, timeout))
27-
28+ time.sleep(0.3)
29+ self.fail("sync step %s didn't happen after %d retries." % (
30+ step, retries))