gate: context tests failed because missing parameter "is_admin_project" (oslo.context 2.6.0)

Bug #1603979 reported by Tang Chen on 2016-07-18
22
This bug affects 3 people
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Critical
Tang Chen

Bug Description

Description
===========
The following 3 tests failed:
1. nova.tests.unit.test_context.ContextTestCase.test_convert_from_dict_then_to_dict
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 230, in test_convert_from_dict_then_to_dict
        self.assertEqual(values, values2)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: !=:
    reference = {
     ......
     'is_admin': True,
     ......}
    actual = {
     ......
     'is_admin': True,
     'is_admin_project': True,
     ......}

2. nova.tests.unit.test_context.ContextTestCase.test_convert_from_rc_to_dict
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 203, in test_convert_from_rc_to_dict
        self.assertEqual(expected_values, values2)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: !=:
    reference = {
     ......
     'is_admin': True,
     ......}
    actual = {
     ......
     'is_admin': True,
     'is_admin_project': True,
     ......}

3. nova.tests.unit.test_context.ContextTestCase.test_to_dict_from_dict_no_log
Captured traceback:
~~~~~~~~~~~~~~~~~~~
    Traceback (most recent call last):
      File "nova/tests/unit/test_context.py", line 144, in test_to_dict_from_dict_no_log
        self.assertEqual(0, len(warns), warns)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 411, in assertEqual
        self.assertThat(observed, matcher, message)
      File "/opt/stack/nova/.tox/py27/lib/python2.7/site-packages/testtools/testcase.py", line 498, in assertThat
        raise mismatch_error
    testtools.matchers._impl.MismatchError: 0 != 1: ["Arguments dropped when creating context: {'is_admin_project': True}"]

Steps to reproduce
==================
Just run the context tests:
    tox -e py27 test_context

This is because we missed to pass "is_admin_project" parameter to __init__() of oslo.context.ResourceContext when initializing a nova ResourceContext object.

In nova/context.py

@enginefacade.transaction_context_provider
class RequestContext(context.RequestContext):
    """Security context and request information.

    Represents the user taking a given action within the system.

    """

    def __init__(self, user_id=None, project_id=None,
                 is_admin=None, read_deleted="no",
                 roles=None, remote_address=None, timestamp=None,
                 request_id=None, auth_token=None, overwrite=True,
                 quota_class=None, user_name=None, project_name=None,
                 service_catalog=None, instance_lock_checked=False,
                 user_auth_plugin=None, **kwargs):
    ......
        super(RequestContext, self).__init__(
            ......
            is_admin=is_admin,
            ......)

But in oslo_context/context.py,

class RequestContext(object):

    ......

    def __init__(......
                 is_admin=False,
                 ......
                 is_admin_project=True):

Tang Chen (tangchen) on 2016-07-18
Changed in nova:
assignee: nobody → Tang Chen (tangchen)
description: updated

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

Changed in nova:
status: New → In Progress
Changed in nova:
importance: Undecided → Critical
summary: - context tests failed because missing parameter "is_admin_project"
+ gate: context tests failed because missing parameter "is_admin_project"

Global requirements uses "oslo.context>=2.4.0" and the "upper-constraints.txt" got updated to use 2.6.0 yesterday [1].

References:
[1] https://github.com/openstack/requirements/commit/238389c4ee1bd3cc9be4931dd2639aea2dae70f1

Matt Riedemann (mriedem) on 2016-07-18
summary: gate: context tests failed because missing parameter "is_admin_project"
+ (oslo.context 2.6.0)
tags: added: oslo
Matt Riedemann (mriedem) wrote :

Tony Breeds has a fix here too: https://review.openstack.org/#/c/342604/

Change abandoned by Tang Chen (<email address hidden>) on branch: master
Review: https://review.openstack.org/343618
Reason: Fixed by another patch.

Vasyl Saienko (vsaienko) wrote :

@Markus: shouldn't be https://review.openstack.org/#/c/333181/ merged to fix the issue?

ChangBo Guo(gcb) (glongwave) wrote :

Nova didn't accept the g-r update now, Maybe the CI test skip oslo.context 2.6.0.

We have another fix in https://review.openstack.org/#/c/343694/

Changed in nova:
status: Fix Released → In Progress

Hm, there's also https://review.openstack.org/#/c/345633/
I have no strong feelings for any solution, to be honest.

Change abandoned by Ronald Bradford (<email address hidden>) on branch: master
Review: https://review.openstack.org/343694
Reason: Superseded by https://review.openstack.org/#/c/345633/

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Duplicates of this bug

Other bug subscribers