test_cache_layer_*_crud depend on test execution order

Bug #1251300 reported by Peter Feiner
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Low
Morgan Fainberg

Bug Description

The tests test_cache_layer_domain_crud, test_cache_layer_project_crud, and test_cache_layer_role_crud in keystone.tests.test_backend.IdentityTests may fail depending on which tests have run previously. In particular, if no tests have run previously, then they all fail. Here's an example running each test separately using the KVS backend:

% tox -e py27 -- keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_role_crud
py27 develop-inst-nodeps: /opt/stack/keystone
py27 runtests: commands[0] | python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_role_crud
running testr
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
--list
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
 --load-list /tmp/tmpCi8sRv
======================================================================
FAIL: keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_role_crud
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "keystone/tests/test_backend.py", line 2682, in test_cache_layer_role_crud
    self.assertDictEqual(role_ref, self.assignment_api.get_role(role_id))
  File "keystone/tests/core.py", line 423, in assertDictEqual
    self.assertEqual(d1, d2, msg)
  File "/opt/stack/keystone/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 322, in assertEqual
    self.assertThat(observed, matcher, message)
  File "/opt/stack/keystone/.tox/py27/local/lib/python2.7/site-packages/testtools/testcase.py", line 417, in assertThat
    raise MismatchError(matchee, matcher, mismatch, verbose)
MismatchError: !=:
reference = {'id': u'bf17c51445794329987eda59f9ffd64f',
 'name': u'ea760f7d48aa4c22a6dcaa54098fd2a5'}
actual = {'id': u'bf17c51445794329987eda59f9ffd64f',
 'name': u'815c02c26b3048308b1fb4be22412882'}
======================================================================
FAIL: process-returncode
tags: worker-0
----------------------------------------------------------------------
Binary content:
  traceback (test/plain; charset="utf8")
Ran 3 (+1) tests in 0.143s (+0.004s)
FAILED (id=151, failures=2)
error: testr failed (1)
ERROR: InvocationError: '/opt/stack/keystone/.tox/py27/bin/python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_role_crud'
____________________________________________________________________________________ summary _____________________________________________________________________________________
ERROR: py27: commands failed
% tox -e py27 -- keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_project_crud
py27 develop-inst-nodeps: /opt/stack/keystone
py27 runtests: commands[0] | python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_project_crud
running testr
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
--list
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
 --load-list /tmp/tmp4QfzG9
======================================================================
FAIL: keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_project_crud
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "keystone/tests/test_backend.py", line 2636, in test_cache_layer_project_crud
    project, self.assignment_api.get_project(project_id))
  File "keystone/tests/core.py", line 480, in assertDictContainsSubset
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python2.7/unittest/case.py", line 412, in fail
    raise self.failureException(msg)
AssertionError: Mismatched values: 'name', expected: '4c6b94aaf6324a2c8d3da20fc19ced63', actual: u'aebeb924708f4cc7a326043d240be3af'
======================================================================
FAIL: process-returncode
tags: worker-0
----------------------------------------------------------------------
Binary content:
  traceback (test/plain; charset="utf8")
Ran 3 (+1) tests in 0.180s (+0.040s)
FAILED (id=152, failures=2)
error: testr failed (1)
ERROR: InvocationError: '/opt/stack/keystone/.tox/py27/bin/python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_project_crud'
____________________________________________________________________________________ summary _____________________________________________________________________________________
ERROR: py27: commands failed
% tox -e py27 -- keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_domain_crud
py27 develop-inst-nodeps: /opt/stack/keystone
py27 runtests: commands[0] | python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_domain_crud
running testr
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
--list
running=${PYTHON:-python} -m subunit.run discover \
-t ./ ./keystone/tests \
 --load-list /tmp/tmpY27vIC
======================================================================
FAIL: keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_domain_crud
tags: worker-0
----------------------------------------------------------------------
Traceback (most recent call last):
  File "keystone/tests/test_backend.py", line 2586, in test_cache_layer_domain_crud
    domain_ref, self.assignment_api.get_domain(domain_id))
  File "keystone/tests/core.py", line 480, in assertDictContainsSubset
    self.fail(self._formatMessage(msg, standardMsg))
  File "/usr/lib/python2.7/unittest/case.py", line 412, in fail
    raise self.failureException(msg)
AssertionError: Mismatched values: 'name', expected: u'2414056b220a4e44ae11c9f4fb00376e', actual: u'a9e3a4ff47844a0f9f4911c9d7dbfa0e'
======================================================================
FAIL: process-returncode
tags: worker-0
----------------------------------------------------------------------
Binary content:
  traceback (test/plain; charset="utf8")
Ran 3 (+1) tests in 0.143s (-0.034s)
FAILED (id=153, failures=2)
error: testr failed (1)
ERROR: InvocationError: '/opt/stack/keystone/.tox/py27/bin/python setup.py testr --testr-args=keystone.tests.test_backend_sql.SqlIdentity.test_cache_layer_domain_crud'
____________________________________________________________________________________ summary _____________________________________________________________________________________
ERROR: py27: commands failed

The results are similar for the SQL backend. I haven't tried the other backends.

This test order dependency is particularly when running the tests in parallel since the test execution order is nondeterministic.

Revision history for this message
Peter Feiner (pete5) wrote :

Whoops, I ran the SQL backend in the example instead of the KVS as stated. Anyhow, the results are the same.

Dolph Mathews (dolph)
Changed in keystone:
importance: Undecided → Low
David Stanek (dstanek)
Changed in keystone:
assignee: nobody → David Stanek (dstanek)
Revision history for this message
David Stanek (dstanek) wrote :

The issue is that the configuring of the cache happens at import time. If these tests are run in isolation the cache has already been configured to be a no-op so it won't work. Running two or more of the broken tests shows that the first one fails and all of the others pass. There are actually 3 different ways to fix this:

1. In keystone.tests.test_singular_plural move the services import into the test method (a lazy import)
2. Modify keystone.services to not configure the cache on import
3. Modify setUp keystone.tests.core to delete the backend before trying to configure it

I'm going to submit a review that implements #3 because I think that is the most correct. I would rather stop the configuration during import, but it looks like that may just end up messy.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (master)

Fix proposed to branch: master
Review: https://review.openstack.org/58311

Changed in keystone:
status: New → In Progress
Changed in keystone:
assignee: David Stanek (dstanek) → Dolph Mathews (dolph)
Changed in keystone:
assignee: Dolph Mathews (dolph) → Morgan Fainberg (mdrnstm)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/58311
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=99efc2296c54e1332795f9f926fce0a202380f04
Submitter: Jenkins
Branch: master

commit 99efc2296c54e1332795f9f926fce0a202380f04
Author: David Stanek <email address hidden>
Date: Mon Nov 25 15:10:44 2013 +0000

    Adds a fixture for setting up the cache

    Certain tests will fail in isolation becasue the cache isn't properly
    configured. This fixture will clear out any old configuration and
    correctly configure the cache.

    Change-Id: I6ec944880dea930771906a63a76400fe3d10e299
    Closes-Bug: #1251300

Changed in keystone:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in keystone:
milestone: none → icehouse-3
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in keystone:
milestone: icehouse-3 → 2014.1
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.