~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/browser/tests/test_distroseries.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-06-09 10:49:32 UTC
  • mfrom: (7675.1190.7 db-bug-793382)
  • Revision ID: launchpad@pqm.canonical.com-20110609104932-ctzgwbfn80x1c9ll
[r=henninge][bug=793382] Bring requestUpgrades back to constant query
 count.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1102
1102
        observed = map(vars, view.request.response.notifications)
1103
1103
        self.assertEqual([expected], observed)
1104
1104
 
1105
 
    def test_requestUpgrade_is_efficient(self):
 
1105
    def test_requestUpgrades_is_efficient(self):
1106
1106
        # A single web request may need to schedule large numbers of
1107
1107
        # package upgrades.  It must do so without issuing large numbers
1108
1108
        # of database queries.
1112
1112
        flush_database_caches()
1113
1113
        with StormStatementRecorder() as recorder1:
1114
1114
            self.makeView(derived_series).requestUpgrades()
1115
 
        self.assertThat(recorder1, HasQueryCount(LessThan(10)))
1116
 
        # Creating Jobs and DistributionJobs takes 2 extra queries per
1117
 
        # requested sync.
1118
 
        requested_syncs = 3
1119
 
        for index in xrange(requested_syncs):
 
1115
        self.assertThat(recorder1, HasQueryCount(LessThan(12)))
 
1116
 
 
1117
        # The query count does not increase with the number of upgrades.
 
1118
        for index in xrange(3):
1120
1119
            self.makePackageUpgrade(derived_series=derived_series)
1121
1120
        flush_database_caches()
1122
1121
        with StormStatementRecorder() as recorder2:
1123
1122
            self.makeView(derived_series).requestUpgrades()
1124
1123
        self.assertThat(
1125
1124
            recorder2,
1126
 
            HasQueryCount(Equals(recorder1.count + 2 * requested_syncs)))
 
1125
            HasQueryCount(Equals(recorder1.count)))
1127
1126
 
1128
1127
 
1129
1128
class TestDistroSeriesLocalDifferencesFunctional(TestCaseWithFactory,