Mercurial > p > roundup > code
diff test/test_liveserver.py @ 6747:d32d43e4a5ba
wsgi can cache tracker instance enabled by feature flag.
Patch by Marcus Priesch caches a loaded tracker instance and reuse it
for future client sessions.
It is enabled by a feature flag in wsgi.py since it arrived during the
2.2.0 beta period.
The provided wsgi.py is modified to enable it. Testing is run with
flag enabled and disabled.
Ralf Schlatterbeck and Marcus tested it on one of their larger more
complex trackers and it sped up the response time to a client request
by a factor of 3 (270ms down to about 80-85ms).
| author | John Rouillard <rouilj@ieee.org> |
|---|---|
| date | Sat, 02 Jul 2022 14:04:00 -0400 |
| parents | 9a1f5e496e6c |
| children | be3fd5e9577e |
line wrap: on
line diff
--- a/test/test_liveserver.py Sat Jul 02 13:52:52 2022 -0400 +++ b/test/test_liveserver.py Sat Jul 02 14:04:00 2022 -0400 @@ -38,7 +38,7 @@ _py3 = sys.version_info[0] > 2 @skip_requests -class SimpleTest(LiveServerTestCase): +class WsgiSetup(LiveServerTestCase): # have chicken and egg issue here. Need to encode the base_url # in the config file but we don't know it until after # the server is started and has read the config.ini. @@ -103,7 +103,8 @@ i18n.DOMAIN = cls.backup_domain def create_app(self): - '''The wsgi app to start''' + '''The wsgi app to start - no feature_flags set.''' + if _py3: return validator(RequestDispatcher(self.dirname)) else: @@ -112,6 +113,11 @@ return RequestDispatcher(self.dirname) +class BaseTestCases(WsgiSetup): + """Class with all tests to run against wsgi server. Is reused when + wsgi server is started with various feature flags + """ + def test_start_page(self): """ simple test that verifies that the server can serve a start page. """ @@ -973,4 +979,16 @@ self.assertEqual(r.status_code, 201) print(r.status_code) - +class TestFeatureFlagCacheTrackerOn(BaseTestCases, WsgiSetup): + """Class to run all test in BaseTestCases with the cache_tracker + feature flag enabled when starting the wsgi server + """ + def create_app(self): + '''The wsgi app to start with feature flag enabled''' + ff = { "cache_tracker": "" } + if _py3: + return validator(RequestDispatcher(self.dirname, feature_flags=ff)) + else: + # wsgiref/validator.py InputWrapper::readline is broke and + # doesn't support the max bytes to read argument. + return RequestDispatcher(self.dirname, feature_flags=ff)
