[Django] #27124: caches_setting_for_tests passes cull related options to memcached tests

3 views
Skip to first unread message

Django

unread,
Aug 25, 2016, 1:55:41 PM8/25/16
to django-...@googlegroups.com
#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.

Django

unread,
Aug 25, 2016, 2:06:45 PM8/25/16
to django-...@googlegroups.com
#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 | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by timgraham):

* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
* stage: Unreviewed => Accepted


--
Ticket URL: <https://code.djangoproject.com/ticket/27124#comment:1>

Django

unread,
Aug 25, 2016, 5:55:41 PM8/25/16
to django-...@googlegroups.com
#27124: caches_setting_for_tests passes cull related options to memcached tests
--------------------------------------+------------------------------------
Reporter: edmorley | Owner: edmorley
Type: Cleanup/optimization | Status: assigned

Component: Core (Cache system) | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by edmorley):

* owner: nobody => edmorley
* status: new => assigned
* has_patch: 0 => 1


Comment:

PR opened. I decided to go with a new argument named `exclude` instead,
which takes a tuple of test cache key names that will be excluded from the
generated cache settings.

--
Ticket URL: <https://code.djangoproject.com/ticket/27124#comment:2>

Django

unread,
Aug 26, 2016, 2:29:40 PM8/26/16
to django-...@googlegroups.com
#27124: caches_setting_for_tests passes cull related options to memcached tests
--------------------------------------+------------------------------------
Reporter: edmorley | Owner: edmorley
Type: Cleanup/optimization | Status: closed

Component: Core (Cache system) | Version: master
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------
Changes (by Tim Graham <timograham@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"606a303856afee684563f9349c2a55578854f1ba" 606a303]:
{{{
#!CommitTicketReference repository=""
revision="606a303856afee684563f9349c2a55578854f1ba"
Fixed #27124 -- Excluded cull-related cache configs from memcached tests.

Since the `cull` and `zero_cull` test cache configs set `MAX_ENTRIES`
and `CULL_FREQUENCY` in `OPTIONS`, which are only intended for use with
the locmem, filesystem, and database backends. This prevents test
failures once refs #20892 is fixed.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27124#comment:3>

Django

unread,
Aug 29, 2016, 10:37:20 AM8/29/16
to django-...@googlegroups.com
#27124: caches_setting_for_tests passes cull related options to memcached tests
--------------------------------------+------------------------------------
Reporter: edmorley | Owner: edmorley
Type: Cleanup/optimization | Status: closed
Component: Core (Cache system) | Version: master
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
--------------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"fb8eea5680f20d3df50eb6a7d972645a388cb196" fb8eea56]:
{{{
#!CommitTicketReference repository=""
revision="fb8eea5680f20d3df50eb6a7d972645a388cb196"
[1.10.x] Fixed #27124 -- Excluded cull-related cache configs from
memcached tests.

Since the `cull` and `zero_cull` test cache configs set `MAX_ENTRIES`
and `CULL_FREQUENCY` in `OPTIONS`, which are only intended for use with
the locmem, filesystem, and database backends. This prevents test
failures once refs #20892 is fixed.

Backport of 606a303856afee684563f9349c2a55578854f1ba from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/27124#comment:4>

Reply all
Reply to author
Forward
0 new messages