Merge lp:~frankban/launchpad/bug-1001520-memcache-warnings into lp:launchpad

Proposed by Francesco Banconi on 2012-06-04
Status: Merged
Approved by: Francesco Banconi on 2012-06-05
Approved revision: no longer in the source branch.
Merged at revision: 15363
Proposed branch: lp:~frankban/launchpad/bug-1001520-memcache-warnings
Merge into: lp:launchpad
Diff against target: 338 lines (+85/-1)
11 files modified
lib/lp/app/browser/tests/test_launchpadroot.py (+10/-0)
lib/lp/blueprints/browser/tests/test_specificationtarget.py (+13/-0)
lib/lp/blueprints/browser/tests/test_views.py (+7/-0)
lib/lp/bugs/browser/tests/test_bugcomment.py (+19/-0)
lib/lp/bugs/tests/test_bugs_webservice.py (+5/-0)
lib/lp/registry/browser/tests/test_distribution.py (+4/-0)
lib/lp/registry/browser/tests/test_distroseries.py (+7/-0)
lib/lp/registry/browser/tests/test_pillar_sharing.py (+4/-0)
lib/lp/registry/browser/tests/test_projectgroup.py (+4/-0)
lib/lp/registry/browser/tests/test_subscription_links.py (+8/-1)
lib/lp/registry/tests/test_distribution.py (+4/-0)
To merge this branch: bzr merge lp:~frankban/launchpad/bug-1001520-memcache-warnings
Reviewer Review Type Date Requested Status
Benji York (community) code 2012-06-04 Approve on 2012-06-05
Review via email: mp+108592@code.launchpad.net

Commit Message

Updated tests generating Memcached warnings in test run output.

Description of the Change

= Summary =

We started seeing Memcached warnings in the stdout of test runs, both parallel and lpbuildbot tests.
This is caused by tests indirectly calling `memcache_client.set` (e.g. by browsing a cached page) without using the memcache layer.
lp.services.memcache.client.TimelineRecordingClient.set just imports logging and warn if the operation fails.

== Proposed fix ==

As Robert suggested in his comment to bug 1001520, we can use `fixtures.FakeLogger` to capture those logs.
This way we can attach the logs to the test result, and if the test fails, we still can retrieve logging info taking advantage of the testtools/fixtures details machinery. A `getDetails` method needs to be implemented in the FakeLogger: I am currently taking care of this, see https://code.launchpad.net/~frankban/python-fixtures/fakelogger-getdetails .

== Implementation details ==

With I full test run I've found 69 tests generating 92 warnings, the list is here:
http://pastebin.ubuntu.com/1023139/
Now the FakeLogger fixture is used by them all.

== Tests ==

Download the full list of tests (see above) and then run::

    bin/test -vv --load-list my_list

You should not see memcache warnings.

== Demo and Q/A ==

no qa

To post a comment you must log in.
Benji York (benji) wrote :

Looks good.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'lib/canonical/launchpad/icing/icon-sprites.png'
2Binary files lib/canonical/launchpad/icing/icon-sprites.png 1970-01-01 00:00:00 +0000 and lib/canonical/launchpad/icing/icon-sprites.png 2012-06-04 17:02:19 +0000 differ
3=== modified file 'lib/lp/app/browser/tests/test_launchpadroot.py'
4--- lib/lp/app/browser/tests/test_launchpadroot.py 2012-03-23 21:05:07 +0000
5+++ lib/lp/app/browser/tests/test_launchpadroot.py 2012-06-04 17:02:19 +0000
6@@ -10,6 +10,7 @@
7 BeautifulSoup,
8 SoupStrainer,
9 )
10+from fixtures import FakeLogger
11 from zope.component import getUtility
12 from zope.security.checker import selectChecker
13
14@@ -38,6 +39,9 @@
15 self.root = getUtility(ILaunchpadRoot)
16 self.admin = getUtility(IPersonSet).getByEmail(
17 'foo.bar@canonical.com')
18+ # Use a FakeLogger fixture to prevent Memcached warnings to be
19+ # printed to stdout while browsing pages.
20+ self.useFixture(FakeLogger())
21
22 def setUpRegistryExpert(self):
23 """Create a registry expert and logs in as them."""
24@@ -114,6 +118,12 @@
25
26 layer = DatabaseFunctionalLayer
27
28+ def setUp(self):
29+ super(LaunchpadRootIndexViewTestCase, self).setUp()
30+ # Use a FakeLogger fixture to prevent Memcached warnings to be
31+ # printed to stdout while browsing pages.
32+ self.useFixture(FakeLogger())
33+
34 def test_has_logo_without_watermark(self):
35 root = getUtility(ILaunchpadRoot)
36 user = self.factory.makePerson()
37
38=== modified file 'lib/lp/blueprints/browser/tests/test_specificationtarget.py'
39--- lib/lp/blueprints/browser/tests/test_specificationtarget.py 2012-02-17 04:09:06 +0000
40+++ lib/lp/blueprints/browser/tests/test_specificationtarget.py 2012-06-04 17:02:19 +0000
41@@ -5,6 +5,7 @@
42
43
44 from BeautifulSoup import BeautifulSoup
45+from fixtures import FakeLogger
46 from zope.component import getUtility
47 from zope.security.proxy import removeSecurityProxy
48
49@@ -69,6 +70,9 @@
50 TestCaseWithFactory.setUp(self)
51 self.user = self.factory.makePerson(name="macadamia")
52 login_person(self.user)
53+ # Use a FakeLogger fixture to prevent Memcached warnings to be
54+ # printed to stdout while browsing pages.
55+ self.useFixture(FakeLogger())
56
57 def verify_involvment(self, context):
58 self.assertTrue(IHasSpecifications.providedBy(context))
59@@ -122,6 +126,12 @@
60
61 layer = DatabaseFunctionalLayer
62
63+ def setUp(self):
64+ super(TestAssignments, self).setUp()
65+ # Use a FakeLogger fixture to prevent Memcached warnings to be
66+ # printed to stdout while browsing pages.
67+ self.useFixture(FakeLogger())
68+
69 def test_assignments_are_batched(self):
70 product = self.factory.makeProduct()
71 self.factory.makeSpecification(product=product)
72@@ -246,6 +256,9 @@
73 super(TestSpecificationsRobots, self).setUp()
74 self.product = self.factory.makeProduct()
75 self.naked_product = removeSecurityProxy(self.product)
76+ # Use a FakeLogger fixture to prevent Memcached warnings to be
77+ # printed to stdout while browsing pages.
78+ self.useFixture(FakeLogger())
79
80 def _configure_project(self, usage):
81 self.naked_product.blueprints_usage = usage
82
83=== modified file 'lib/lp/blueprints/browser/tests/test_views.py'
84--- lib/lp/blueprints/browser/tests/test_views.py 2012-01-15 13:32:27 +0000
85+++ lib/lp/blueprints/browser/tests/test_views.py 2012-06-04 17:02:19 +0000
86@@ -9,6 +9,7 @@
87 import os
88 import unittest
89
90+from fixtures import FakeLogger
91 from storm.store import Store
92 from testtools.matchers import LessThan
93
94@@ -33,6 +34,12 @@
95
96 layer = DatabaseFunctionalLayer
97
98+ def setUp(self):
99+ super(TestAssignments, self).setUp()
100+ # Use a FakeLogger fixture to prevent Memcached warnings to be
101+ # printed to stdout while browsing pages.
102+ self.useFixture(FakeLogger())
103+
104 def invalidate_and_render(self, browser, dbobj, url):
105 # Ensure caches have been flushed.
106 store = Store.of(dbobj)
107
108=== modified file 'lib/lp/bugs/browser/tests/test_bugcomment.py'
109--- lib/lp/bugs/browser/tests/test_bugcomment.py 2012-02-28 04:24:19 +0000
110+++ lib/lp/bugs/browser/tests/test_bugcomment.py 2012-06-04 17:02:19 +0000
111@@ -11,6 +11,7 @@
112 )
113 from itertools import count
114
115+from fixtures import FakeLogger
116 from pytz import utc
117 from soupmatchers import (
118 HTMLContains,
119@@ -209,6 +210,12 @@
120
121 layer = DatabaseFunctionalLayer
122
123+ def setUp(self):
124+ super(TestBugCommentVisibility, self).setUp()
125+ # Use a FakeLogger fixture to prevent Memcached warnings to be
126+ # printed to stdout while browsing pages.
127+ self.useFixture(FakeLogger())
128+
129 def makeHiddenMessage(self):
130 """Required by the mixin."""
131 with celebrity_logged_in('admin'):
132@@ -234,6 +241,12 @@
133
134 feature_flag = {'disclosure.users_hide_own_bug_comments.enabled': 'on'}
135
136+ def setUp(self):
137+ super(TestBugHideCommentControls, self).setUp()
138+ # Use a FakeLogger fixture to prevent Memcached warnings to be
139+ # printed to stdout while browsing pages.
140+ self.useFixture(FakeLogger())
141+
142 def getContext(self, comment_owner=None):
143 """Required by the mixin."""
144 bug = self.factory.makeBug()
145@@ -299,6 +312,12 @@
146
147 layer = DatabaseFunctionalLayer
148
149+ def setUp(self):
150+ super(TestBugCommentMicroformats, self).setUp()
151+ # Use a FakeLogger fixture to prevent Memcached warnings to be
152+ # printed to stdout while browsing pages.
153+ self.useFixture(FakeLogger())
154+
155 def test_bug_comment_metadata(self):
156 owner = self.factory.makePerson()
157 login_person(owner)
158
159=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
160--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-04-04 05:46:26 +0000
161+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-06-04 17:02:19 +0000
162@@ -8,6 +8,7 @@
163 import re
164
165 from BeautifulSoup import BeautifulSoup
166+from fixtures import FakeLogger
167 from lazr.lifecycle.interfaces import IDoNotSnapshot
168 from lazr.restfulclient.errors import (
169 BadRequest,
170@@ -133,10 +134,14 @@
171
172 class TestBugCommentRepresentation(TestCaseWithFactory):
173 """Test ways of interacting with BugComment webservice representations."""
174+
175 layer = DatabaseFunctionalLayer
176
177 def setUp(self):
178 TestCaseWithFactory.setUp(self)
179+ # Use a FakeLogger fixture to prevent Memcached warnings to be
180+ # printed to stdout while browsing pages.
181+ self.useFixture(FakeLogger())
182 login('guilherme.salgado@canonical.com ')
183 self.bug = self.factory.makeBug()
184 commenter = self.factory.makePerson()
185
186=== modified file 'lib/lp/registry/browser/tests/test_distribution.py'
187--- lib/lp/registry/browser/tests/test_distribution.py 2012-01-01 02:58:52 +0000
188+++ lib/lp/registry/browser/tests/test_distribution.py 2012-06-04 17:02:19 +0000
189@@ -4,6 +4,7 @@
190
191 __metaclass__ = type
192
193+from fixtures import FakeLogger
194 import soupmatchers
195 from testtools.matchers import (
196 MatchesAny,
197@@ -31,6 +32,9 @@
198 self.distro = self.factory.makeDistribution(
199 name="distro", displayname=u'distro')
200 self.simple_user = self.factory.makePerson()
201+ # Use a FakeLogger fixture to prevent Memcached warnings to be
202+ # printed to stdout while browsing pages.
203+ self.useFixture(FakeLogger())
204
205 def test_distributionpage_addseries_link(self):
206 # An admin sees the +addseries link.
207
208=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
209--- lib/lp/registry/browser/tests/test_distroseries.py 2012-03-02 16:17:46 +0000
210+++ lib/lp/registry/browser/tests/test_distroseries.py 2012-06-04 17:02:19 +0000
211@@ -13,6 +13,7 @@
212 from urlparse import urlparse
213
214 from BeautifulSoup import BeautifulSoup
215+from fixtures import FakeLogger
216 from lazr.restful.interfaces import IJSONRequestCache
217 from lxml import html
218 import soupmatchers
219@@ -270,6 +271,12 @@
220
221 layer = DatabaseFunctionalLayer
222
223+ def setUp(self):
224+ super(DistroSeriesIndexFunctionalTestCase, self).setUp()
225+ # Use a FakeLogger fixture to prevent Memcached warnings to be
226+ # printed to stdout while browsing pages.
227+ self.useFixture(FakeLogger())
228+
229 def _setupDifferences(self, name, parent_names, nb_diff_versions,
230 nb_diff_child, nb_diff_parent):
231 # Helper to create DSDs of the different types.
232
233=== modified file 'lib/lp/registry/browser/tests/test_pillar_sharing.py'
234--- lib/lp/registry/browser/tests/test_pillar_sharing.py 2012-06-01 02:33:27 +0000
235+++ lib/lp/registry/browser/tests/test_pillar_sharing.py 2012-06-04 17:02:19 +0000
236@@ -6,6 +6,7 @@
237 __metaclass__ = type
238
239 from BeautifulSoup import BeautifulSoup
240+from fixtures import FakeLogger
241 from lazr.restful.interfaces import IJSONRequestCache
242 from lazr.restful.utils import get_current_web_service_request
243 import simplejson
244@@ -402,6 +403,9 @@
245 super(TestProductSharingView, self).setUp()
246 self.setupSharing(self.grantees)
247 login_person(self.driver)
248+ # Use a FakeLogger fixture to prevent Memcached warnings to be
249+ # printed to stdout while browsing pages.
250+ self.useFixture(FakeLogger())
251
252
253 class TestDistributionSharingView(PillarSharingViewTestMixin,
254
255=== modified file 'lib/lp/registry/browser/tests/test_projectgroup.py'
256--- lib/lp/registry/browser/tests/test_projectgroup.py 2012-01-01 02:58:52 +0000
257+++ lib/lp/registry/browser/tests/test_projectgroup.py 2012-06-04 17:02:19 +0000
258@@ -5,6 +5,7 @@
259
260 __metaclass__ = type
261
262+from fixtures import FakeLogger
263 from testtools.matchers import Not
264 from zope.component import getUtility
265 from zope.security.interfaces import Unauthorized
266@@ -31,6 +32,9 @@
267 def setUp(self):
268 super(TestProjectGroupEditView, self).setUp()
269 self.project_group = self.factory.makeProject(name='grupo')
270+ # Use a FakeLogger fixture to prevent Memcached warnings to be
271+ # printed to stdout while browsing pages.
272+ self.useFixture(FakeLogger())
273
274 def test_links_admin(self):
275 # An admin can change details and administer a project group.
276
277=== modified file 'lib/lp/registry/browser/tests/test_subscription_links.py'
278--- lib/lp/registry/browser/tests/test_subscription_links.py 2012-04-19 20:45:21 +0000
279+++ lib/lp/registry/browser/tests/test_subscription_links.py 2012-06-04 17:02:19 +0000
280@@ -8,6 +8,7 @@
281 import unittest
282
283 from BeautifulSoup import BeautifulSoup
284+from fixtures import FakeLogger
285 from zope.component import getUtility
286
287 from lp.bugs.browser.structuralsubscription import (
288@@ -88,6 +89,9 @@
289 def setUp(self):
290 super(_TestStructSubs, self).setUp()
291 self.regular_user = self.factory.makePerson()
292+ # Use a FakeLogger fixture to prevent Memcached warnings to be
293+ # printed to stdout while browsing pages.
294+ self.useFixture(FakeLogger())
295
296 def _create_scenario(self, user):
297 with person_logged_in(user):
298@@ -244,6 +248,9 @@
299 with person_logged_in(self.target.owner):
300 self.target.official_malone = True
301 self.regular_user = self.factory.makePerson()
302+ # Use a FakeLogger fixture to prevent Memcached warnings to be
303+ # printed to stdout while browsing pages.
304+ self.useFixture(FakeLogger())
305
306 def _create_scenario(self, user):
307 with person_logged_in(user):
308@@ -635,7 +642,7 @@
309 class ProductMilestoneDoesNotUseLPView(ProductMilestoneView):
310
311 def setUp(self):
312- BrowserTestCase.setUp(self)
313+ super(ProductMilestoneDoesNotUseLPView, self).setUp()
314 self.product = self.factory.makeProduct()
315 with person_logged_in(self.product.owner):
316 self.product.official_malone = False
317
318=== modified file 'lib/lp/registry/tests/test_distribution.py'
319--- lib/lp/registry/tests/test_distribution.py 2012-03-08 01:07:47 +0000
320+++ lib/lp/registry/tests/test_distribution.py 2012-06-04 17:02:19 +0000
321@@ -7,6 +7,7 @@
322
323 import datetime
324
325+from fixtures import FakeLogger
326 from lazr.lifecycle.snapshot import Snapshot
327 import pytz
328 import soupmatchers
329@@ -433,6 +434,9 @@
330 self.admin = getUtility(IPersonSet).getByEmail(
331 'admin@canonical.com')
332 self.simple_user = self.factory.makePerson()
333+ # Use a FakeLogger fixture to prevent Memcached warnings to be
334+ # printed to stdout while browsing pages.
335+ self.useFixture(FakeLogger())
336
337 def test_distributionpage_addseries_link(self):
338 """ Verify that an admin sees the +addseries link."""