Issue #425 resolved

CacheFilter test failing on --all

Robert Brewer
created an issue

When running the cachefilter test once, no problems occur. When running test_cache_filter.CacheFilterTest more than once (as with {{{ --all}}}), the test fails on subsequent runs (even if you change the order of servers).

Here are the various error messages:

Serverless {{{ testCaching (test_cache_filter.CacheFilterTest) ... ERROR

====================================================================== ERROR: testCaching (test_cache_filter.CacheFilterTest)

Traceback (most recent call last): File "C:\Python23\Lib\site-packages\cherrypy\test\", line 32, in testCaching self.getPage("/") File "C:\Python23\Lib\site-packages\cherrypy\test\", line 159, in getPage self._getRequest(url, headers, method, body) File "C:\Python23\Lib\site-packages\cherrypy\test\", line 109, in _getRequest self.cookies = [('Cookie', v) for k, v in self.headers TypeError: iteration over non-sequence }}}

Native HTTP Server {{{ testCaching (test_cache_filter.CacheFilterTest) ... ERROR: expected body: 'visit #1'

actual body: '' Show: [B]ody [H]eaders [S]tatus [U]RL; [I]gnore, [R]aise, or sys.e[X]it >> }}}

Native WSGI Server {{{ testCaching (test_cache_filter.CacheFilterTest) ... ERROR

====================================================================== ERROR: testCaching (test_cache_filter.CacheFilterTest)

Traceback (most recent call last): File "C:\Python23\Lib\site-packages\cherrypy\test\", line 32, in testCaching self.getPage("/") File "C:\Python23\Lib\site-packages\cherrypy\test\", line 161, in getPage webtest.WebCase.getPage(self, url, headers, method, body) File "C:\Python23\Lib\site-packages\cherrypy\test\", line 150, in getPage self.HTTP_CONN) File "C:\Python23\Lib\site-packages\cherrypy\test\", line 362, in openURL response = conn.getresponse() File "C:\Python23\lib\", line 779, in getresponse response.begin() File "C:\Python23\lib\", line 273, in begin version, status, reason = self._read_status() File "C:\Python23\lib\", line 237, in _read_status raise BadStatusLine(line) BadStatusLine }}}

I'm seeing this on Win2k, Python 2.3.2. Current CP rev is 897, but this has been failing for quite some time.

Comments (3)

  1. Robert Brewer reporter

    [902] made the tests pass, but unfortunately by changing the semantic of the test. The output for each pass of the xrange loop should be the same (because it's being cached)! Fixed in [906].

    I also reworked the cachefilter implementation quite a bit. It seems like the design was originally to allow multiple caches, defined at separate points on the cherrypy tree. Unfortunately, that was broken, since the cache was always attached at cherrypy._cache--if you defined cache_filter config entries at multiple points, whichever URL was requested first would define the settings for the singleton cherrypy._cache, and therefore for all other paths. Funky. At the same time, the config values for key, delay, maxobjsize, etc., were being defined only in the [global] context.

    I refactored and simplified cachefilter before I discovered the broken test, so I'm not really sure what the ''original'' problem prompting this ticket was. I kept the MemoryCache.clear() method anyway, even though it's not called anymore by the (fixed) test.

    There was also a bug in cachefilter relating to the new lowercase names. The cachefilter was caching and replaying response.headers (a dict), but the servers all inspect response.header_list (a list). Since RequestHandled is raised, response.finalize() isn't called, and the dict is never changed to the list, so stale headers were being returned.

  2. Log in to comment