Merge lp:~jml/canonical-identity-provider/reliable-tests into lp:canonical-identity-provider/release
Status: | Merged |
---|---|
Approved by: | Michael Foord |
Approved revision: | no longer in the source branch. |
Merged at revision: | 549 |
Proposed branch: | lp:~jml/canonical-identity-provider/reliable-tests |
Merge into: | lp:canonical-identity-provider/release |
Diff against target: |
98 lines (+27/-5) 4 files modified
django_project/config_dev/config/devel.cfg (+1/-1) identityprovider/tests/runner.py (+13/-2) identityprovider/tests/unit/test_command_cleanup.py (+2/-2) webui/tests/test_decorators.py (+11/-0) |
To merge this branch: | bzr merge lp:~jml/canonical-identity-provider/reliable-tests |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Foord (community) | Approve | ||
Ricardo Kirkner (community) | Approve | ||
Review via email: mp+136932@code.launchpad.net |
Commit message
Make decorator tests more reliable and suppress "cleaning nonces" message during test run
Description of the change
Two tests currently fail intermittently: identityprovide
They do so because they rely on a feature flag being in a certain state, and because gargoyle's implementation makes feature flag state in tests unreliable.
It uses modeldict which implements two levels of caching: an internal Python cache in a dict and the django cache, which is set to a system memcache in canonical-
The flag in question is 'TWOFACTOR', and it is enabled by the twofactor fixture in test_views_server. This enables the flag in the database, in the django cache and in modeldict's custom cache. Django correctly cleans up the change to the database, but leaves the django cache and modeldict's cache with the flag enabled.
Thus, when test_decoration
To reliably trigger this failure, do either:
$ python django_
identitypro
identitypro
Or:
$ python django_
identitypro
$ python django_
identitypro
They both exercise different caching bugs.
This branch begins to address the problem by setting the timeout of modeldict's own cache to 0, thus effectively disabling its cache in unit tests.
It does not address the problem of django's cache containing invalid data. That is work-in-progress.
Options:
1. disable django's cache in tests using the dummy cache
2. run cache.clear() after each test
3. write a cache decorator that records all keys added, set & deleted and then provides a mechanism for reversing those operations. call this mechanism after each test
4. work-around the problem in the failing tests (e.g. rewrite them to expect redirects sometimes, have them flush the cache, etc.)
Option 1 breaks many, many tests. I haven't dug into why.
Options 2 & 3 are slightly more difficult due to identityprovider not having a standard base TestCase, thus having no easy way to do something after every test.
Option 4 just means this problem will bite us later.
Option 3 is currently my favourite.
I hope to return to this tomorrow, but will be happy if someone takes it from me.
See also:
https:/
jml
The changes to identityprovide r/tests/ unit/test_ command_ cleanup. py are to prevent unnecessary writing to stdout. The noise made the problem harder to debug.