#27124: caches_setting_for_tests passes cull related options to memcached tests
--------------------------------------+--------------------
     Reporter:  edmorley              |      Owner:  nobody
         Type:  Cleanup/optimization  |     Status:  new
    Component:  Core (Cache system)   |    Version:  master
     Severity:  Normal                |   Keywords:
 Triage Stage:  Unreviewed            |  Has patch:  0
Easy pickings:  0                     |      UI/UX:  0
--------------------------------------+--------------------
 The cache tests have a helper named `caches_setting_for_tests()`
 
([https://github.com/django/django/blob/989f6108d349e0eebdc5ad26b5cb4e882cb32e47/tests/cache/tests.py#L242-L253
 source]), that generates the config that is used to override `CACHES` at
 various points during the test run.

 However it uses `_caches_setting_base`, which contains cache `OPTIONS`
 such as `MAX_ENTRIES` and `CULL_FREQUENCY` that are only relevant to the
 locmem, filesystem and database backends
 ([https://docs.djangoproject.com/en/1.9/topics/cache/#cache-arguments
 docs]).

 This is problematic, since in #20892 we're going to start passing the
 contents of `OPTIONS` verbatim to the memcache client constructors, which
 causes the tests to fail like so:
 {{{
 ERROR: test_memcached_uses_highest_pickle_version
 (cache.tests.MemcachedCacheTests)
 ----------------------------------------------------------------------
 Traceback (most recent call last):
   File "/home/vagrant/src/_todo/django/tests/cache/tests.py", line 1198,
 in test_memcached_uses_highest_pickle_version
     self.assertEqual(caches[cache_key]._cache.pickleProtocol,
   File
 "/home/vagrant/src/_todo/django/django/core/cache/backends/memcached.py",
 line 169, in _cache
     self._client = self._lib.Client(self._servers, **client_kwargs)
 TypeError: __init__() got an unexpected keyword argument 'MAX_ENTRIES'
 }}}

 As such, the cache tests need to be adjusted to only pass those options to
 the backends that support them.

 One way of doing this might be for `caches_setting_for_tests()` to take an
 additional `include_cull_settings` bool parameter, which would determine
 whether the problematic `cull` and `zero_cull` cache keys
 
([https://github.com/django/django/blob/989f6108d349e0eebdc5ad26b5cb4e882cb32e47/tests/cache/tests.py#L237-L238
 source]) were included. This parameter would default to `True`, but then
 be set to `False` in `MemcachedCacheTests`.

 Thoughts?

 Many thanks :-)

--
Ticket URL: <https://code.djangoproject.com/ticket/27124>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.f9eeec62b0b929c74633a73daac6a0d2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to