launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #08489
[Merge] lp:~frankban/launchpad/bug-1001520-memcache-warnings into lp:launchpad
Francesco Banconi has proposed merging lp:~frankban/launchpad/bug-1001520-memcache-warnings into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
Related bugs:
Bug #1001520 in Launchpad itself: "Memcache warnings in test run output"
https://bugs.launchpad.net/launchpad/+bug/1001520
For more details, see:
https://code.launchpad.net/~frankban/launchpad/bug-1001520-memcache-warnings/+merge/108592
= 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
--
https://code.launchpad.net/~frankban/launchpad/bug-1001520-memcache-warnings/+merge/108592
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~frankban/launchpad/bug-1001520-memcache-warnings into lp:launchpad.
=== added file 'lib/canonical/launchpad/icing/icon-sprites.png'
Binary 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
=== modified file 'lib/lp/app/browser/tests/test_launchpadroot.py'
--- lib/lp/app/browser/tests/test_launchpadroot.py 2012-03-23 21:05:07 +0000
+++ lib/lp/app/browser/tests/test_launchpadroot.py 2012-06-04 17:02:19 +0000
@@ -10,6 +10,7 @@
BeautifulSoup,
SoupStrainer,
)
+from fixtures import FakeLogger
from zope.component import getUtility
from zope.security.checker import selectChecker
@@ -38,6 +39,9 @@
self.root = getUtility(ILaunchpadRoot)
self.admin = getUtility(IPersonSet).getByEmail(
'foo.bar@xxxxxxxxxxxxx')
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def setUpRegistryExpert(self):
"""Create a registry expert and logs in as them."""
@@ -114,6 +118,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(LaunchpadRootIndexViewTestCase, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def test_has_logo_without_watermark(self):
root = getUtility(ILaunchpadRoot)
user = self.factory.makePerson()
=== modified file 'lib/lp/blueprints/browser/tests/test_specificationtarget.py'
--- lib/lp/blueprints/browser/tests/test_specificationtarget.py 2012-02-17 04:09:06 +0000
+++ lib/lp/blueprints/browser/tests/test_specificationtarget.py 2012-06-04 17:02:19 +0000
@@ -5,6 +5,7 @@
from BeautifulSoup import BeautifulSoup
+from fixtures import FakeLogger
from zope.component import getUtility
from zope.security.proxy import removeSecurityProxy
@@ -69,6 +70,9 @@
TestCaseWithFactory.setUp(self)
self.user = self.factory.makePerson(name="macadamia")
login_person(self.user)
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def verify_involvment(self, context):
self.assertTrue(IHasSpecifications.providedBy(context))
@@ -122,6 +126,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestAssignments, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def test_assignments_are_batched(self):
product = self.factory.makeProduct()
self.factory.makeSpecification(product=product)
@@ -246,6 +256,9 @@
super(TestSpecificationsRobots, self).setUp()
self.product = self.factory.makeProduct()
self.naked_product = removeSecurityProxy(self.product)
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def _configure_project(self, usage):
self.naked_product.blueprints_usage = usage
=== modified file 'lib/lp/blueprints/browser/tests/test_views.py'
--- lib/lp/blueprints/browser/tests/test_views.py 2012-01-15 13:32:27 +0000
+++ lib/lp/blueprints/browser/tests/test_views.py 2012-06-04 17:02:19 +0000
@@ -9,6 +9,7 @@
import os
import unittest
+from fixtures import FakeLogger
from storm.store import Store
from testtools.matchers import LessThan
@@ -33,6 +34,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestAssignments, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def invalidate_and_render(self, browser, dbobj, url):
# Ensure caches have been flushed.
store = Store.of(dbobj)
=== modified file 'lib/lp/bugs/browser/tests/test_bugcomment.py'
--- lib/lp/bugs/browser/tests/test_bugcomment.py 2012-02-28 04:24:19 +0000
+++ lib/lp/bugs/browser/tests/test_bugcomment.py 2012-06-04 17:02:19 +0000
@@ -11,6 +11,7 @@
)
from itertools import count
+from fixtures import FakeLogger
from pytz import utc
from soupmatchers import (
HTMLContains,
@@ -209,6 +210,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestBugCommentVisibility, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def makeHiddenMessage(self):
"""Required by the mixin."""
with celebrity_logged_in('admin'):
@@ -234,6 +241,12 @@
feature_flag = {'disclosure.users_hide_own_bug_comments.enabled': 'on'}
+ def setUp(self):
+ super(TestBugHideCommentControls, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def getContext(self, comment_owner=None):
"""Required by the mixin."""
bug = self.factory.makeBug()
@@ -299,6 +312,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(TestBugCommentMicroformats, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def test_bug_comment_metadata(self):
owner = self.factory.makePerson()
login_person(owner)
=== modified file 'lib/lp/bugs/tests/test_bugs_webservice.py'
--- lib/lp/bugs/tests/test_bugs_webservice.py 2012-04-04 05:46:26 +0000
+++ lib/lp/bugs/tests/test_bugs_webservice.py 2012-06-04 17:02:19 +0000
@@ -8,6 +8,7 @@
import re
from BeautifulSoup import BeautifulSoup
+from fixtures import FakeLogger
from lazr.lifecycle.interfaces import IDoNotSnapshot
from lazr.restfulclient.errors import (
BadRequest,
@@ -133,10 +134,14 @@
class TestBugCommentRepresentation(TestCaseWithFactory):
"""Test ways of interacting with BugComment webservice representations."""
+
layer = DatabaseFunctionalLayer
def setUp(self):
TestCaseWithFactory.setUp(self)
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
login('guilherme.salgado@xxxxxxxxxxxxx ')
self.bug = self.factory.makeBug()
commenter = self.factory.makePerson()
=== modified file 'lib/lp/registry/browser/tests/test_distribution.py'
--- lib/lp/registry/browser/tests/test_distribution.py 2012-01-01 02:58:52 +0000
+++ lib/lp/registry/browser/tests/test_distribution.py 2012-06-04 17:02:19 +0000
@@ -4,6 +4,7 @@
__metaclass__ = type
+from fixtures import FakeLogger
import soupmatchers
from testtools.matchers import (
MatchesAny,
@@ -31,6 +32,9 @@
self.distro = self.factory.makeDistribution(
name="distro", displayname=u'distro')
self.simple_user = self.factory.makePerson()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def test_distributionpage_addseries_link(self):
# An admin sees the +addseries link.
=== modified file 'lib/lp/registry/browser/tests/test_distroseries.py'
--- lib/lp/registry/browser/tests/test_distroseries.py 2012-03-02 16:17:46 +0000
+++ lib/lp/registry/browser/tests/test_distroseries.py 2012-06-04 17:02:19 +0000
@@ -13,6 +13,7 @@
from urlparse import urlparse
from BeautifulSoup import BeautifulSoup
+from fixtures import FakeLogger
from lazr.restful.interfaces import IJSONRequestCache
from lxml import html
import soupmatchers
@@ -270,6 +271,12 @@
layer = DatabaseFunctionalLayer
+ def setUp(self):
+ super(DistroSeriesIndexFunctionalTestCase, self).setUp()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
+
def _setupDifferences(self, name, parent_names, nb_diff_versions,
nb_diff_child, nb_diff_parent):
# Helper to create DSDs of the different types.
=== modified file 'lib/lp/registry/browser/tests/test_pillar_sharing.py'
--- lib/lp/registry/browser/tests/test_pillar_sharing.py 2012-06-01 02:33:27 +0000
+++ lib/lp/registry/browser/tests/test_pillar_sharing.py 2012-06-04 17:02:19 +0000
@@ -6,6 +6,7 @@
__metaclass__ = type
from BeautifulSoup import BeautifulSoup
+from fixtures import FakeLogger
from lazr.restful.interfaces import IJSONRequestCache
from lazr.restful.utils import get_current_web_service_request
import simplejson
@@ -402,6 +403,9 @@
super(TestProductSharingView, self).setUp()
self.setupSharing(self.grantees)
login_person(self.driver)
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
class TestDistributionSharingView(PillarSharingViewTestMixin,
=== modified file 'lib/lp/registry/browser/tests/test_projectgroup.py'
--- lib/lp/registry/browser/tests/test_projectgroup.py 2012-01-01 02:58:52 +0000
+++ lib/lp/registry/browser/tests/test_projectgroup.py 2012-06-04 17:02:19 +0000
@@ -5,6 +5,7 @@
__metaclass__ = type
+from fixtures import FakeLogger
from testtools.matchers import Not
from zope.component import getUtility
from zope.security.interfaces import Unauthorized
@@ -31,6 +32,9 @@
def setUp(self):
super(TestProjectGroupEditView, self).setUp()
self.project_group = self.factory.makeProject(name='grupo')
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def test_links_admin(self):
# An admin can change details and administer a project group.
=== modified file 'lib/lp/registry/browser/tests/test_subscription_links.py'
--- lib/lp/registry/browser/tests/test_subscription_links.py 2012-04-19 20:45:21 +0000
+++ lib/lp/registry/browser/tests/test_subscription_links.py 2012-06-04 17:02:19 +0000
@@ -8,6 +8,7 @@
import unittest
from BeautifulSoup import BeautifulSoup
+from fixtures import FakeLogger
from zope.component import getUtility
from lp.bugs.browser.structuralsubscription import (
@@ -88,6 +89,9 @@
def setUp(self):
super(_TestStructSubs, self).setUp()
self.regular_user = self.factory.makePerson()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def _create_scenario(self, user):
with person_logged_in(user):
@@ -244,6 +248,9 @@
with person_logged_in(self.target.owner):
self.target.official_malone = True
self.regular_user = self.factory.makePerson()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def _create_scenario(self, user):
with person_logged_in(user):
@@ -635,7 +642,7 @@
class ProductMilestoneDoesNotUseLPView(ProductMilestoneView):
def setUp(self):
- BrowserTestCase.setUp(self)
+ super(ProductMilestoneDoesNotUseLPView, self).setUp()
self.product = self.factory.makeProduct()
with person_logged_in(self.product.owner):
self.product.official_malone = False
=== modified file 'lib/lp/registry/tests/test_distribution.py'
--- lib/lp/registry/tests/test_distribution.py 2012-03-08 01:07:47 +0000
+++ lib/lp/registry/tests/test_distribution.py 2012-06-04 17:02:19 +0000
@@ -7,6 +7,7 @@
import datetime
+from fixtures import FakeLogger
from lazr.lifecycle.snapshot import Snapshot
import pytz
import soupmatchers
@@ -433,6 +434,9 @@
self.admin = getUtility(IPersonSet).getByEmail(
'admin@xxxxxxxxxxxxx')
self.simple_user = self.factory.makePerson()
+ # Use a FakeLogger fixture to prevent Memcached warnings to be
+ # printed to stdout while browsing pages.
+ self.useFixture(FakeLogger())
def test_distributionpage_addseries_link(self):
""" Verify that an admin sees the +addseries link."""
Follow ups