Quotas tests fail when run as a subset

Bug #1209177 reported by Julie Pichon
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Dashboard (Horizon)
Fix Released
Low
Julie Pichon

Bug Description

Although the tests pass when run as part of the full openstack_dashboard test suite, the quota tests behave differently when run as a subset and fail.

$ ./run_tests.sh openstack_dashboard.test.tests.quotas
...
======================================================================
ERROR: test_tenant_quota_usages_no_instances_running (openstack_dashboard.test.tests.quotas.QuotaTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/jpichon/devel/horizon/openstack_dashboard/test/helpers.py", line 77, in instance_stub_out
    return fn(self)
  File "/home/jpichon/devel/horizon/openstack_dashboard/test/tests/quotas.py", line 136, in test_tenant_quota_usages_no_instances_running
    quota_usages = quotas.tenant_quota_usages(self.request)
  File "/home/jpichon/devel/horizon/horizon/utils/memoized.py", line 33, in __call__
    value = self.func(*args)
  File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 120, in tenant_quota_usages
    disabled_quotas=disabled_quotas):
  File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 103, in get_tenant_quota_data
    tenant_id=tenant_id)
  File "/home/jpichon/devel/horizon/openstack_dashboard/usage/quotas.py", line 79, in _get_quota_data
    tenant_id = request.user.tenant_id
  File "/home/jpichon/devel/horizon/.venv/lib/python2.7/site-packages/django/utils/functional.py", line 203, in inner
    return func(self._wrapped, *args)
AttributeError: 'AnonymousUser' object has no attribute 'tenant_id'
...

Changed in horizon:
status: New → Confirmed
Revision history for this message
Julie Pichon (jpichon) wrote :

It happens for other api_tests as well (e.g. swift_tests, lbaas_tests), different errors relating to the AnonymousUser being returned.

It looks like when running this subset of the tests, openstack_auth.urls doesn't get loaded, therefore the middleware get_user monkey patching doesn't happen and we call directly to django.contrib.auth.middleware later on.

While waiting for bug 1207840 to be resolved, we could force the monkey patching to happen in the helpers.TestCase's setUp() method.

Changed in horizon:
assignee: nobody → Julie Pichon (jpichon)
importance: Undecided → Low
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to horizon (master)

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

Changed in horizon:
status: Confirmed → In Progress
Changed in horizon:
milestone: none → havana-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to horizon (master)

Reviewed: https://review.openstack.org/40656
Committed: http://github.com/openstack/horizon/commit/589092c5f21124c7025360b284ed1dbc2a125c8a
Submitter: Jenkins
Branch: master

commit 589092c5f21124c7025360b284ed1dbc2a125c8a
Author: Julie Pichon <email address hidden>
Date: Wed Aug 7 16:39:17 2013 +0100

    Ensure the user monkey patching is done for the API tests

    When running a subset of the tests, the get_user middleware monkey
    patching in openstack_auth.utils did not always happen, causing some
    of the tests to fail due to missing expected properties.

    Fixes bug #1209177

    Change-Id: Ic00b842e740954b0f36353381f511f7ba3eab70b

Changed in horizon:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in horizon:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in horizon:
milestone: havana-3 → 2013.2
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.