Merge lp:~lifeless/launchpad/bug-618367 into lp:launchpad
Proposed by
Robert Collins
on 2010-08-31
| Status: | Merged |
|---|---|
| Approved by: | Robert Collins on 2010-08-31 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 11483 |
| Proposed branch: | lp:~lifeless/launchpad/bug-618367 |
| Merge into: | lp:launchpad |
| Diff against target: |
419 lines (+246/-42) 5 files modified
lib/lp/blueprints/browser/tests/test_views.py (+78/-5) lib/lp/blueprints/model/specification.py (+78/-0) lib/lp/registry/model/distribution.py (+9/-9) lib/lp/registry/model/person.py (+72/-19) lib/lp/registry/model/product.py (+9/-9) |
| To merge this branch: | bzr merge lp:~lifeless/launchpad/bug-618367 |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Michael Nelson (community) | code | 2010-08-31 | Approve on 2010-08-31 |
|
Review via email:
|
|||
Commit Message
Preload is_valid_person for +assignments on Product and Distribution.
Description of the Change
Preload is_valid_person for +assignments on Product and Distribution, should fix bug 618367, according to the observed oopses. It will probably still be slow, but 6 seconds faster.
To post a comment you must log in.

Looks great Robert.
I've got a few questions below, more for my own understanding. And you said you'd update _validity_queries() to return a dict or namedtuple.
Thanks!
> === modified file 'lib/lp/ blueprints/ browser/ tests/test_ views.py' blueprints/ browser/ tests/test_ views.py 2010-08-20 20:31:18 +0000 blueprints/ browser/ tests/test_ views.py 2010-08-31 07:46:51 +0000 launchpad. testing. systemdocs import ( uite, launchpad. webapp import canonical_url nalLayer dirname( os.path. realpath( __file_ _)) tory, sampledata import ADMIN_EMAIL _webservice import QueryCollector
> --- lib/lp/
> +++ lib/lp/
> @@ -9,19 +9,92 @@
> import os
> import unittest
>
> +from storm.store import Store
> +from testtools.matchers import LessThan
> +
> from canonical.
> LayeredDocFileS
> setUp,
> tearDown,
> )
> +from canonical.
> from canonical.testing import DatabaseFunctio
> -
> -
> -here = os.path.
> -
> +from lp.testing import (
> + login,
> + logout,
> + TestCaseWithFac
> + )
> +from lp.testing.matchers import HasQueryCount
> +from lp.testing.
> +from lp.testing.
Should this be exported from lp.testing. __init_ _.py instead of importing from
_webservice?
> + (TestCaseWithFa ctory): nalLayer and_render( self, browser, dbobj, url): counts_ scaling_ with_unique_ people( self,
> +
> +class TestAssignments
> +
> + layer = DatabaseFunctio
> +
> + def invalidate_
> + # Ensure caches have been flushed.
> + store = Store.of(dbobj)
> + store.flush()
> + store.invalidate()
> + browser.open(url)
> +
> + def check_query_
> + target, targettype):
> + """Check that a particular hasSpecifications target scales well.
> +
> + :param target: A spec target like a product.
> + :param targettype: The parameter to pass to makeSpecification to
> + associate the target. e.g. 'product'.
> + """
> + query_baseline = 40
> + people = []
> + for _ in range(10):
Up to you, but JFYI, our style guide says:
Single character names should be avoided for both variables and methods. Even
list comprehensions and generator expressions should not use them.
> + people. append( self.factory. makePerson( ))
> + specs = []
> + for _ in range(10):
ditto.
> + specs.append( self.factory. makeSpecificati on( target} )) register( ) (collector. unregister) makePerson( password= "test") wser(user= viewer) url(target) + "/+assignments" launchpad. webapp. serssion: _get_secret. _and_render( browser, target, url) (collector, HasQueryCount( LessThan( query_baseline) ))
> + **{targettype:
> + collector = QueryCollector()
> + collector.
> + self.addCleanup
> + viewer = self.factory.
> + browser = self.getUserBro
> + url = canonical_
> + # Seed the cookie cache and any other cross-request state we may gain
> + # in future. See canonical.
> + browser.open(url)
> + self.invalidate
> + # Set a baseline
> + self.assertThat
> + no_assignees_count = collector.count
> + # Assign many unique people, which shouldn't change the page queries.
> + # Due to storm bug 619017 additional...