Merge lp:~mars/launchpad/add-profiling-feature-flag into lp:launchpad

Proposed by Māris Fogels
Status: Work in progress
Proposed branch: lp:~mars/launchpad/add-profiling-feature-flag
Merge into: lp:launchpad
Prerequisite: lp:~mars/launchpad/feature-flag-fixture
Diff against target: 408 lines (+88/-51)
3 files modified
lib/canonical/launchpad/doc/profiling.txt (+21/-5)
lib/lp/services/profile/profile.py (+13/-2)
lib/lp/services/profile/tests.py (+54/-44)
To merge this branch: bzr merge lp:~mars/launchpad/add-profiling-feature-flag
Reviewer Review Type Date Requested Status
Launchpad code reviewers Pending
Review via email: mp+39179@code.launchpad.net

Description of the change

Hi,

This branch changes our profiling code to use feature flags instead of config values. The code takes advantage of the new FeatureFixture, added in the prerequisite branch, to do the heavy lifting. Later we will be able to turn profiling on and off from the Launchpad UI.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

Hi, we still need a config setting to control profiling because we do
not ever want it on in prod.

Here's what I think we need, for clarity:
C - config
F - flags
 - on prod
   C - allow_profiling False: no profiling, no how, no way
 - no devel
   C - allow_profiling true: profiling anytime
 - on staging
   C - allow_profiling True:
   F - profiling on request by developers [use a team scope to id the developer]
   F - profiling of all requests [use the default scope to turn it on
for all requests]

That is, the check for 'should we profile' is:
config.allow_profiling and getFeatureFlag('profile') == 'on'

-Rob

Unmerged revisions

11598. By Māris Fogels

Typo

11597. By Māris Fogels

Better comments

11596. By Māris Fogels

Merged feature-flag-fixture into add-profiling-feature-flag.

11595. By Māris Fogels

Merged feature-flag-fixture into add-profiling-feature-flag.

11594. By Māris Fogels

Merged feature-flag-fixture into add-profiling-feature-flag.

11593. By Māris Fogels

Merged in Graham's fixes for the feature flags helper setting None values. Added a test to verify the fix.

11592. By Māris Fogels

Merge from devel

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/doc/profiling.txt'
--- lib/canonical/launchpad/doc/profiling.txt 2010-08-26 15:57:56 +0000
+++ lib/canonical/launchpad/doc/profiling.txt 2010-10-22 20:36:24 +0000
@@ -100,11 +100,10 @@
100100
101The feature has two modes.101The feature has two modes.
102102
103- It can be configured to optionally profile requests. To turn this on, in103- It can be configured to optionally profile requests. To turn this on you
104 ``launchpad-lazr.conf`` (e.g.,104 must add a feature flag that sets the 'request_profiling' flag to 'on'.
105 ``configs/development/launchpad-lazr.conf``) , in the ``[profiling]``105 This flag can be set directly in the database or using bin/harness. See
106 section, set ``profiling_allowed: True``. As of this writing, this106 https://dev.launchpad.net/LEP/FeatureFlags for the details.
107 is the default value for development.
108107
109 Once it is turned on, you can insert /++profile++/ in the URL to get108 Once it is turned on, you can insert /++profile++/ in the URL to get
110 basic instructions on how to use the feature. You use the109 basic instructions on how to use the feature. You use the
@@ -123,6 +122,19 @@
123 lp/services/profile is hooked up properly. This is intended to be a122 lp/services/profile is hooked up properly. This is intended to be a
124 smoke test. The unit tests verify further functionality.123 smoke test. The unit tests verify further functionality.
125124
125 # XXX mars 2010-09-23
126 # We will temporarily turn on the profiling feature so that this test
127 # still passes. Profiling used to be active for all developers, but the
128 # feature flags work has shut it off. This fixture can be removed once
129 # profiling for developers is active by default once again.
130 >>> from lp.services.features.testing import FeatureFixture
131 >>> fixture = FeatureFixture({'request_profiling': 'on'})
132 >>> fixture.setUp()
133
134 >>> from lp.services.features import getFeatureFlag
135 >>> getFeatureFlag('request_profiling')
136 u'on'
137
126 >>> response = http('GET /++profile++ HTTP/1.0')138 >>> response = http('GET /++profile++ HTTP/1.0')
127 >>> '<h1>Profiling Information</h1>' in response.getBody()139 >>> '<h1>Profiling Information</h1>' in response.getBody()
128 True140 True
@@ -214,3 +226,7 @@
214 >>> shutil.rmtree(pagetests_profile_dir)226 >>> shutil.rmtree(pagetests_profile_dir)
215 >>> shutil.rmtree(profile_dir)227 >>> shutil.rmtree(profile_dir)
216 >>> old_config = config.pop('memory_profile')228 >>> old_config = config.pop('memory_profile')
229
230
231 # Turn profiling off
232 >>> fixture.cleanUp()
217233
=== modified file 'lib/lp/services/profile/profile.py'
--- lib/lp/services/profile/profile.py 2010-08-27 14:20:28 +0000
+++ lib/lp/services/profile/profile.py 2010-10-22 20:36:24 +0000
@@ -30,12 +30,15 @@
30 memory,30 memory,
31 resident,31 resident,
32 )32 )
33from lp.services import features
3334
3435
35class ProfilingOops(Exception):36class ProfilingOops(Exception):
36 """Fake exception used to log OOPS information when profiling pages."""37 """Fake exception used to log OOPS information when profiling pages."""
3738
3839
40# This variable holds all of the data about an active profile run for the
41# duration of the request.
39_profilers = threading.local()42_profilers = threading.local()
4043
4144
@@ -46,8 +49,16 @@
46 If profiling is enabled, start a profiler for this thread. If memory49 If profiling is enabled, start a profiler for this thread. If memory
47 profiling is requested, save the VSS and RSS.50 profiling is requested, save the VSS and RSS.
48 """51 """
49 if not config.profiling.profiling_allowed:52 if features.getFeatureFlag('request_profiling'):
53 # Set a flag so that the end_request hook knows it has some work to
54 # do. We can not use the feature flag itself to control our
55 # end_request event handlers because the handler that tears down the
56 # feature flags and the handler that ends the profiling run do not
57 # fire in a predictable order.
58 _profilers.active = True
59 else:
50 return60 return
61
51 actions = get_desired_profile_actions(event.request)62 actions = get_desired_profile_actions(event.request)
52 if config.profiling.profile_all_requests:63 if config.profiling.profile_all_requests:
53 actions.add('log')64 actions.add('log')
@@ -71,7 +82,7 @@
71@adapter(IEndRequestEvent)82@adapter(IEndRequestEvent)
72def end_request(event):83def end_request(event):
73 """If profiling is turned on, save profile data for the request."""84 """If profiling is turned on, save profile data for the request."""
74 if not config.profiling.profiling_allowed:85 if not getattr(_profilers, 'active', False):
75 return86 return
76 try:87 try:
77 actions = _profilers.actions88 actions = _profilers.actions
7889
=== modified file 'lib/lp/services/profile/tests.py'
--- lib/lp/services/profile/tests.py 2010-08-26 22:10:56 +0000
+++ lib/lp/services/profile/tests.py 2010-10-22 20:36:24 +0000
@@ -14,7 +14,6 @@
14import time14import time
15import unittest15import unittest
1616
17from lp.testing import TestCase
18from bzrlib.lsprof import BzrProfiler17from bzrlib.lsprof import BzrProfiler
19from zope.app.publication.interfaces import EndRequestEvent18from zope.app.publication.interfaces import EndRequestEvent
20from zope.component import getSiteManager19from zope.component import getSiteManager
@@ -26,7 +25,11 @@
26 )25 )
27from canonical.launchpad.webapp.servers import LaunchpadTestRequest26from canonical.launchpad.webapp.servers import LaunchpadTestRequest
28from canonical.launchpad.webapp.interfaces import StartRequestEvent27from canonical.launchpad.webapp.interfaces import StartRequestEvent
28from canonical.testing import layers
29from lp.services.profile import profile29from lp.services.profile import profile
30from lp.services.features.testing import FeatureFixture
31from lp.testing import TestCase
32
3033
31EXAMPLE_HTML_START = '''\34EXAMPLE_HTML_START = '''\
32<html><head><title>Random!</title></head>35<html><head><title>Random!</title></head>
@@ -43,6 +46,8 @@
4346
44class BaseTest(TestCase):47class BaseTest(TestCase):
4548
49 layer = layers.DatabaseFunctionalLayer
50
46 def _get_request(self, path='/'):51 def _get_request(self, path='/'):
47 """Return a test request for the given path."""52 """Return a test request for the given path."""
48 return LaunchpadTestRequest(PATH_INFO=path)53 return LaunchpadTestRequest(PATH_INFO=path)
@@ -58,13 +63,19 @@
58 getattr(profile._profilers, name, None), None,63 getattr(profile._profilers, name, None), None,
59 'Profiler state (%s) is dirty; %s.' % (name, message))64 'Profiler state (%s) is dirty; %s.' % (name, message))
6065
66 def turnOnProfiling(self):
67 """Turn on the request_profiling feature flag."""
68 self.useFixture(FeatureFixture({'request_profiling': 'on'}))
69
70 def turnOffProfiling(self):
71 """Turn off the request_profiling feature flag."""
72 self.useFixture(FeatureFixture({'request_profiling': None}))
73
61 def pushProfilingConfig(74 def pushProfilingConfig(
62 self, profiling_allowed='False', profile_all_requests='False',75 self, profile_all_requests='False', memory_profile_log=''):
63 memory_profile_log=''):
64 """This is a convenience for setting profile configs."""76 """This is a convenience for setting profile configs."""
65 self.pushConfig(77 self.pushConfig(
66 'profiling',78 'profiling',
67 profiling_allowed=profiling_allowed,
68 profile_all_requests=profile_all_requests,79 profile_all_requests=profile_all_requests,
69 memory_profile_log=memory_profile_log)80 memory_profile_log=memory_profile_log)
7081
@@ -86,11 +97,12 @@
86 delattr(profile._profilers, name)97 delattr(profile._profilers, name)
87 TestCase.tearDown(self)98 TestCase.tearDown(self)
8899
89 def test_config_stops_profiling(self):100 def test_feature_flag_stops_profiling(self):
90 """The ``profiling_allowed`` configuration should disable all101 """The ``request_profiling`` feature flag should disable all
91 profiling, even if it is requested"""102 profiling, even if it is requested"""
103 self.turnOffProfiling()
92 self.pushProfilingConfig(104 self.pushProfilingConfig(
93 profiling_allowed='False', profile_all_requests='True',105 profile_all_requests='True',
94 memory_profile_log='.')106 memory_profile_log='.')
95 profile.start_request(self._get_start_event('/++profile++show,log'))107 profile.start_request(self._get_start_event('/++profile++show,log'))
96 self.assertCleanProfilerState('config was ignored')108 self.assertCleanProfilerState('config was ignored')
@@ -98,7 +110,7 @@
98 def test_optional_profiling_without_marked_request_has_no_profile(self):110 def test_optional_profiling_without_marked_request_has_no_profile(self):
99 """Even if profiling is allowed, it does not happen with a normal111 """Even if profiling is allowed, it does not happen with a normal
100 request."""112 request."""
101 self.pushProfilingConfig(profiling_allowed='True')113 self.turnOnProfiling()
102 profile.start_request(self._get_start_event('/'))114 profile.start_request(self._get_start_event('/'))
103 self.assertEqual(profile._profilers.actions, set())115 self.assertEqual(profile._profilers.actions, set())
104 self.assertIs(getattr(profile._profilers, 'profiler', None), None)116 self.assertIs(getattr(profile._profilers, 'profiler', None), None)
@@ -108,7 +120,7 @@
108 def test_optional_profiling_with_show_request_starts_profiling(self):120 def test_optional_profiling_with_show_request_starts_profiling(self):
109 """If profiling is allowed and a request with the "show" marker121 """If profiling is allowed and a request with the "show" marker
110 URL segment is made, profiling starts."""122 URL segment is made, profiling starts."""
111 self.pushProfilingConfig(profiling_allowed='True')123 self.turnOnProfiling()
112 profile.start_request(self._get_start_event('/++profile++show/'))124 profile.start_request(self._get_start_event('/++profile++show/'))
113 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)125 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
114 self.assertIs(126 self.assertIs(
@@ -119,7 +131,7 @@
119 def test_optional_profiling_with_log_request_starts_profiling(self):131 def test_optional_profiling_with_log_request_starts_profiling(self):
120 """If profiling is allowed and a request with the "log" marker132 """If profiling is allowed and a request with the "log" marker
121 URL segment is made, profiling starts."""133 URL segment is made, profiling starts."""
122 self.pushProfilingConfig(profiling_allowed='True')134 self.turnOnProfiling()
123 profile.start_request(self._get_start_event('/++profile++log/'))135 profile.start_request(self._get_start_event('/++profile++log/'))
124 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)136 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
125 self.assertIs(137 self.assertIs(
@@ -130,7 +142,7 @@
130 def test_optional_profiling_with_combined_request_starts_profiling(self):142 def test_optional_profiling_with_combined_request_starts_profiling(self):
131 """If profiling is allowed and a request with the "log" and143 """If profiling is allowed and a request with the "log" and
132 "show" marker URL segment is made, profiling starts."""144 "show" marker URL segment is made, profiling starts."""
133 self.pushProfilingConfig(profiling_allowed='True')145 self.turnOnProfiling()
134 profile.start_request(self._get_start_event('/++profile++log,show/'))146 profile.start_request(self._get_start_event('/++profile++log,show/'))
135 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)147 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
136 self.assertIs(148 self.assertIs(
@@ -141,7 +153,7 @@
141 def test_optional_profiling_with_reversed_request_starts_profiling(self):153 def test_optional_profiling_with_reversed_request_starts_profiling(self):
142 """If profiling is allowed and a request with the "show" and154 """If profiling is allowed and a request with the "show" and
143 "log" marker URL segment is made, profiling starts."""155 "log" marker URL segment is made, profiling starts."""
144 self.pushProfilingConfig(profiling_allowed='True')156 self.turnOnProfiling()
145 # The fact that this is reversed from the previous request is the only157 # The fact that this is reversed from the previous request is the only
146 # difference from the previous test. Also, it doesn't have a158 # difference from the previous test. Also, it doesn't have a
147 # trailing slash. :-P159 # trailing slash. :-P
@@ -154,8 +166,8 @@
154166
155 def test_forced_profiling_registers_action(self):167 def test_forced_profiling_registers_action(self):
156 """profile_all_requests should register as a log action"""168 """profile_all_requests should register as a log action"""
157 self.pushProfilingConfig(169 self.turnOnProfiling()
158 profiling_allowed='True', profile_all_requests='True')170 self.pushProfilingConfig(profile_all_requests='True')
159 profile.start_request(self._get_start_event('/'))171 profile.start_request(self._get_start_event('/'))
160 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)172 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
161 self.assertIs(173 self.assertIs(
@@ -167,7 +179,7 @@
167 """If profiling is allowed and a request with the marker URL segment179 """If profiling is allowed and a request with the marker URL segment
168 is made incorrectly, profiling does not start and help is an action.180 is made incorrectly, profiling does not start and help is an action.
169 """181 """
170 self.pushProfilingConfig(profiling_allowed='True')182 self.turnOnProfiling()
171 profile.start_request(self._get_start_event('/++profile++/'))183 profile.start_request(self._get_start_event('/++profile++/'))
172 self.assertIs(getattr(profile._profilers, 'profiler', None), None)184 self.assertIs(getattr(profile._profilers, 'profiler', None), None)
173 self.assertIs(185 self.assertIs(
@@ -179,8 +191,8 @@
179 """If profiling is forced and a request with the marker URL segment191 """If profiling is forced and a request with the marker URL segment
180 is made incorrectly, profiling starts and help is an action.192 is made incorrectly, profiling starts and help is an action.
181 """193 """
182 self.pushProfilingConfig(194 self.turnOnProfiling()
183 profiling_allowed='True', profile_all_requests='True')195 self.pushProfilingConfig(profile_all_requests='True')
184 profile.start_request(self._get_start_event('/++profile++/'))196 profile.start_request(self._get_start_event('/++profile++/'))
185 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)197 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
186 self.assertIs(198 self.assertIs(
@@ -189,8 +201,8 @@
189 self.assertEquals(profile._profilers.actions, set(('help', 'log')))201 self.assertEquals(profile._profilers.actions, set(('help', 'log')))
190202
191 def test_memory_profile_start(self):203 def test_memory_profile_start(self):
192 self.pushProfilingConfig(204 self.turnOnProfiling()
193 profiling_allowed='True', memory_profile_log='.')205 self.pushProfilingConfig(memory_profile_log='.')
194 profile.start_request(self._get_start_event('/'))206 profile.start_request(self._get_start_event('/'))
195 self.assertIs(getattr(profile._profilers, 'profiler', None), None)207 self.assertIs(getattr(profile._profilers, 'profiler', None), None)
196 self.assertIsInstance(profile._profilers.memory_profile_start, tuple)208 self.assertIsInstance(profile._profilers.memory_profile_start, tuple)
@@ -198,8 +210,8 @@
198 self.assertEqual(profile._profilers.actions, set())210 self.assertEqual(profile._profilers.actions, set())
199211
200 def test_combo_memory_and_profile_start(self):212 def test_combo_memory_and_profile_start(self):
201 self.pushProfilingConfig(213 self.turnOnProfiling()
202 profiling_allowed='True', memory_profile_log='.')214 self.pushProfilingConfig(memory_profile_log='.')
203 profile.start_request(self._get_start_event('/++profile++show/'))215 profile.start_request(self._get_start_event('/++profile++show/'))
204 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)216 self.assertIsInstance(profile._profilers.profiler, BzrProfiler)
205 self.assertIsInstance(profile._profilers.memory_profile_start, tuple)217 self.assertIsInstance(profile._profilers.memory_profile_start, tuple)
@@ -267,10 +279,11 @@
267 #########################################################################279 #########################################################################
268 # Tests280 # Tests
269 def test_config_stops_profiling(self):281 def test_config_stops_profiling(self):
270 """The ``profiling_allowed`` configuration should disable all282 """The ``request_profiling`` feature should disable all
271 profiling, even if it is requested"""283 profiling, even if it is requested"""
284 self.turnOffProfiling()
272 self.pushProfilingConfig(285 self.pushProfilingConfig(
273 profiling_allowed='False', profile_all_requests='True',286 profile_all_requests='True',
274 memory_profile_log=self.memory_profile_log)287 memory_profile_log=self.memory_profile_log)
275 request = self.endRequest('/++profile++show,log')288 request = self.endRequest('/++profile++show,log')
276 self.assertIs(getattr(request, 'oops', None), None)289 self.assertIs(getattr(request, 'oops', None), None)
@@ -282,7 +295,7 @@
282 def test_optional_profiling_without_marked_request_has_no_profile(self):295 def test_optional_profiling_without_marked_request_has_no_profile(self):
283 """Even if profiling is allowed, it does not happen with a normal296 """Even if profiling is allowed, it does not happen with a normal
284 request."""297 request."""
285 self.pushProfilingConfig(profiling_allowed='True')298 self.turnOnProfiling()
286 request = self.endRequest('/')299 request = self.endRequest('/')
287 self.assertIs(getattr(request, 'oops', None), None)300 self.assertIs(getattr(request, 'oops', None), None)
288 self.assertEqual(self.getAddedResponse(request), '')301 self.assertEqual(self.getAddedResponse(request), '')
@@ -293,7 +306,7 @@
293 def test_optional_profiling_with_show_request_profiles(self):306 def test_optional_profiling_with_show_request_profiles(self):
294 """If profiling is allowed and a request with the "show" marker307 """If profiling is allowed and a request with the "show" marker
295 URL segment is made, profiling starts."""308 URL segment is made, profiling starts."""
296 self.pushProfilingConfig(profiling_allowed='True')309 self.turnOnProfiling()
297 request = self.endRequest('/++profile++show/')310 request = self.endRequest('/++profile++show/')
298 self.assertIsInstance(request.oops, ErrorReport)311 self.assertIsInstance(request.oops, ErrorReport)
299 self.assertIn('Top Inline Time', self.getAddedResponse(request))312 self.assertIn('Top Inline Time', self.getAddedResponse(request))
@@ -304,7 +317,7 @@
304 def test_optional_profiling_with_log_request_profiles(self):317 def test_optional_profiling_with_log_request_profiles(self):
305 """If profiling is allowed and a request with the "log" marker318 """If profiling is allowed and a request with the "log" marker
306 URL segment is made, profiling starts."""319 URL segment is made, profiling starts."""
307 self.pushProfilingConfig(profiling_allowed='True')320 self.turnOnProfiling()
308 request = self.endRequest('/++profile++log/')321 request = self.endRequest('/++profile++log/')
309 self.assertIsInstance(request.oops, ErrorReport)322 self.assertIsInstance(request.oops, ErrorReport)
310 response = self.getAddedResponse(request)323 response = self.getAddedResponse(request)
@@ -319,7 +332,7 @@
319 def test_optional_profiling_with_combined_request_profiles(self):332 def test_optional_profiling_with_combined_request_profiles(self):
320 """If profiling is allowed and a request with the "log" and333 """If profiling is allowed and a request with the "log" and
321 "show" marker URL segment is made, profiling starts."""334 "show" marker URL segment is made, profiling starts."""
322 self.pushProfilingConfig(profiling_allowed='True')335 self.turnOnProfiling()
323 request = self.endRequest('/++profile++log,show')336 request = self.endRequest('/++profile++log,show')
324 self.assertIsInstance(request.oops, ErrorReport)337 self.assertIsInstance(request.oops, ErrorReport)
325 response = self.getAddedResponse(request)338 response = self.getAddedResponse(request)
@@ -333,8 +346,8 @@
333346
334 def test_forced_profiling_logs(self):347 def test_forced_profiling_logs(self):
335 """profile_all_requests should register as a log action"""348 """profile_all_requests should register as a log action"""
336 self.pushProfilingConfig(349 self.turnOnProfiling()
337 profiling_allowed='True', profile_all_requests='True')350 self.pushProfilingConfig(profile_all_requests='True')
338 request = self.endRequest('/')351 request = self.endRequest('/')
339 self.assertIsInstance(request.oops, ErrorReport)352 self.assertIsInstance(request.oops, ErrorReport)
340 response = self.getAddedResponse(request)353 response = self.getAddedResponse(request)
@@ -351,7 +364,7 @@
351 """If profiling is allowed and a request with the marker URL segment364 """If profiling is allowed and a request with the marker URL segment
352 is made incorrectly, profiling does not start and help is an action.365 is made incorrectly, profiling does not start and help is an action.
353 """366 """
354 self.pushProfilingConfig(profiling_allowed='True')367 self.turnOnProfiling()
355 request = self.endRequest('/++profile++')368 request = self.endRequest('/++profile++')
356 self.assertIs(getattr(request, 'oops', None), None)369 self.assertIs(getattr(request, 'oops', None), None)
357 response = self.getAddedResponse(request)370 response = self.getAddedResponse(request)
@@ -365,8 +378,8 @@
365 """If profiling is forced and a request with the marker URL segment378 """If profiling is forced and a request with the marker URL segment
366 is made incorrectly, profiling starts and help is an action.379 is made incorrectly, profiling starts and help is an action.
367 """380 """
368 self.pushProfilingConfig(381 self.turnOnProfiling()
369 profiling_allowed='True', profile_all_requests='True')382 self.pushProfilingConfig(profile_all_requests='True')
370 request = self.endRequest('/++profile++')383 request = self.endRequest('/++profile++')
371 self.assertIsInstance(request.oops, ErrorReport)384 self.assertIsInstance(request.oops, ErrorReport)
372 response = self.getAddedResponse(request)385 response = self.getAddedResponse(request)
@@ -382,9 +395,8 @@
382395
383 def test_memory_profile(self):396 def test_memory_profile(self):
384 "Does the memory profile work?"397 "Does the memory profile work?"
385 self.pushProfilingConfig(398 self.turnOnProfiling()
386 profiling_allowed='True',399 self.pushProfilingConfig(memory_profile_log=self.memory_profile_log)
387 memory_profile_log=self.memory_profile_log)
388 request = self.endRequest('/')400 request = self.endRequest('/')
389 self.assertIs(getattr(request, 'oops', None), None)401 self.assertIs(getattr(request, 'oops', None), None)
390 self.assertEqual(self.getAddedResponse(request), '')402 self.assertEqual(self.getAddedResponse(request), '')
@@ -400,9 +412,8 @@
400412
401 def test_memory_profile_with_non_defaults(self):413 def test_memory_profile_with_non_defaults(self):
402 "Does the memory profile work with an oops and pageid?"414 "Does the memory profile work with an oops and pageid?"
403 self.pushProfilingConfig(415 self.turnOnProfiling()
404 profiling_allowed='True',416 self.pushProfilingConfig(memory_profile_log=self.memory_profile_log)
405 memory_profile_log=self.memory_profile_log)
406 request = self.endRequest('/++profile++show/no-such-file',417 request = self.endRequest('/++profile++show/no-such-file',
407 KeyError(), pageid='Foo')418 KeyError(), pageid='Foo')
408 log = self.getMemoryLog()419 log = self.getMemoryLog()
@@ -413,9 +424,8 @@
413 self.assertCleanProfilerState()424 self.assertCleanProfilerState()
414425
415 def test_combo_memory_and_profile(self):426 def test_combo_memory_and_profile(self):
416 self.pushProfilingConfig(427 self.turnOnProfiling()
417 profiling_allowed='True',428 self.pushProfilingConfig(memory_profile_log=self.memory_profile_log)
418 memory_profile_log=self.memory_profile_log)
419 request = self.endRequest('/++profile++show/')429 request = self.endRequest('/++profile++show/')
420 self.assertIsInstance(request.oops, ErrorReport)430 self.assertIsInstance(request.oops, ErrorReport)
421 self.assertIn('Top Inline Time', self.getAddedResponse(request))431 self.assertIn('Top Inline Time', self.getAddedResponse(request))
@@ -424,7 +434,7 @@
424 self.assertCleanProfilerState()434 self.assertCleanProfilerState()
425435
426 def test_profiling_oops_is_informational(self):436 def test_profiling_oops_is_informational(self):
427 self.pushProfilingConfig(profiling_allowed='True')437 self.turnOnProfiling()
428 request = self.endRequest('/++profile++show/')438 request = self.endRequest('/++profile++show/')
429 response = self.getAddedResponse(request)439 response = self.getAddedResponse(request)
430 self.assertIsInstance(request.oops, ErrorReport)440 self.assertIsInstance(request.oops, ErrorReport)
@@ -433,7 +443,7 @@
433 self.assertCleanProfilerState()443 self.assertCleanProfilerState()
434444
435 def test_real_oops_trumps_profiling_oops(self):445 def test_real_oops_trumps_profiling_oops(self):
436 self.pushProfilingConfig(profiling_allowed='True')446 self.turnOnProfiling()
437 request = self.endRequest('/++profile++show/no-such-file',447 request = self.endRequest('/++profile++show/no-such-file',
438 KeyError('foo'))448 KeyError('foo'))
439 self.assertIsInstance(request.oops, ErrorReport)449 self.assertIsInstance(request.oops, ErrorReport)
@@ -444,7 +454,7 @@
444 self.assertCleanProfilerState()454 self.assertCleanProfilerState()
445455
446 def test_oopsid_is_in_profile_filename(self):456 def test_oopsid_is_in_profile_filename(self):
447 self.pushProfilingConfig(profiling_allowed='True')457 self.turnOnProfiling()
448 request = self.endRequest('/++profile++log/')458 request = self.endRequest('/++profile++log/')
449 self.assertIn("-" + request.oopsid + "-", self.getProfilePaths()[0])459 self.assertIn("-" + request.oopsid + "-", self.getProfilePaths()[0])
450 self.assertCleanProfilerState()460 self.assertCleanProfilerState()