Catch DriverLoadFailure + Correct concurrency of gabbi >1.22.0 + remove most oslo.context usage + remove dependency on sphinxcontrib-docbookrestapi
new oslo.messaging 5.2.0 release will raise oslo_messaging.transport.DriverLoadFailure if no existent transport driver, hence breaks our code and unit test as well. This patch fixes it by adding DriverLoadFailure to catch list. Closes-Bug: #1588151 (cherry picked from commit9c5df8400b
) + When running gabbi under testr, concurrency grouping is controlled by a regex in .testr.conf. A module name change in gabbi 1.22.0 inadvertently broke the grouping. This change should work for old and new versions. (cherry picked from commit86e94d9ab2
) + The RequestContextSerializer of oslo.messaging has been deprecated, and actually we don't need it. Let's drop it and remove the oslo.context usage in most use cases. This fix the stable/liberty tests since oslo.context added a new field recently that broke the tests. (cherry picked from commit3c08a6e586
) + This Sphinx extension is no longer used nor maintained and can be safely removed. (cherry picked from commit3b6a3bfab3
) Change-Id: I318d4b93beac9d1816fe4b5f9eb9de98e4debc04
This commit is contained in:
parent
62b18d6670
commit
8b663afb39
|
@ -6,4 +6,4 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
|
|||
test_id_option=--load-list $IDFILE
|
||||
test_list_option=--list
|
||||
# NOTE(chdent): Only used/matches on gabbi-related tests.
|
||||
group_regex=(gabbi\.driver\.test_gabbi_[^_]+)_
|
||||
group_regex=(gabbi\.(suitemaker|driver)\.test_gabbi_([^_]+))_
|
||||
|
|
|
@ -25,7 +25,6 @@ import uuid
|
|||
|
||||
import croniter
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log
|
||||
from oslo_utils import netutils
|
||||
from oslo_utils import timeutils
|
||||
|
@ -491,7 +490,7 @@ def _send_notification(event, payload):
|
|||
notifier = messaging.get_notifier(transport, publisher_id="aodh.api")
|
||||
# FIXME(sileht): perhaps we need to copy some infos from the
|
||||
# pecan request headers like nova does
|
||||
notifier.info(context.RequestContext(), notification, payload)
|
||||
notifier.info({}, notification, payload)
|
||||
|
||||
|
||||
class AlarmController(rest.RestController):
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#
|
||||
# Copyright 2013 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Authors: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
|
||||
# Copyright 2013-2015 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -22,7 +20,6 @@ import json
|
|||
|
||||
import croniter
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log
|
||||
from oslo_service import service as os_service
|
||||
from oslo_utils import timeutils
|
||||
|
@ -105,7 +102,7 @@ class Evaluator(object):
|
|||
self._alarm_change_notifier = messaging.get_notifier(
|
||||
transport, publisher_id="aodh.evaluator")
|
||||
notification = "alarm.state_transition"
|
||||
self._alarm_change_notifier.info(context.RequestContext(),
|
||||
self._alarm_change_notifier.info({},
|
||||
notification, payload)
|
||||
|
||||
def _refresh(self, alarm, state, reason, reason_data):
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Copyright 2013 eNovance <licensing@enovance.com>
|
||||
# Copyright 2013-2015 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -18,6 +18,7 @@ from oslo_messaging import serializer as oslo_serializer
|
|||
|
||||
DEFAULT_URL = "__default__"
|
||||
TRANSPORTS = {}
|
||||
_SERIALIZER = oslo_serializer.JsonPayloadSerializer()
|
||||
|
||||
|
||||
def setup():
|
||||
|
@ -32,8 +33,9 @@ def get_transport(conf, url=None, optional=False, cache=True):
|
|||
if not transport or not cache:
|
||||
try:
|
||||
transport = oslo_messaging.get_transport(conf, url)
|
||||
except oslo_messaging.InvalidTransportURL as e:
|
||||
if not optional or e.url:
|
||||
except (oslo_messaging.InvalidTransportURL,
|
||||
oslo_messaging.DriverLoadFailure):
|
||||
if not optional or url:
|
||||
# NOTE(sileht): oslo_messaging is configured but unloadable
|
||||
# so reraise the exception
|
||||
raise
|
||||
|
@ -47,20 +49,16 @@ def get_transport(conf, url=None, optional=False, cache=True):
|
|||
def get_rpc_server(conf, transport, topic, endpoint):
|
||||
"""Return a configured oslo_messaging rpc server."""
|
||||
target = oslo_messaging.Target(server=conf.host, topic=topic)
|
||||
serializer = oslo_serializer.RequestContextSerializer(
|
||||
oslo_serializer.JsonPayloadSerializer())
|
||||
return oslo_messaging.get_rpc_server(transport, target,
|
||||
[endpoint], executor='eventlet',
|
||||
serializer=serializer)
|
||||
serializer=_SERIALIZER)
|
||||
|
||||
|
||||
def get_rpc_client(transport, retry=None, **kwargs):
|
||||
"""Return a configured oslo_messaging RPCClient."""
|
||||
target = oslo_messaging.Target(**kwargs)
|
||||
serializer = oslo_serializer.RequestContextSerializer(
|
||||
oslo_serializer.JsonPayloadSerializer())
|
||||
return oslo_messaging.RPCClient(transport, target,
|
||||
serializer=serializer,
|
||||
serializer=_SERIALIZER,
|
||||
retry=retry)
|
||||
|
||||
|
||||
|
@ -74,7 +72,5 @@ def get_notification_listener(transport, targets, endpoints,
|
|||
|
||||
def get_notifier(transport, publisher_id):
|
||||
"""Return a configured oslo_messaging notifier."""
|
||||
serializer = oslo_serializer.RequestContextSerializer(
|
||||
oslo_serializer.JsonPayloadSerializer())
|
||||
notifier = oslo_messaging.Notifier(transport, serializer=serializer)
|
||||
notifier = oslo_messaging.Notifier(transport, serializer=_SERIALIZER)
|
||||
return notifier.prepare(publisher_id=publisher_id)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#
|
||||
# Copyright 2013 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Authors: Mehdi Abaakouk <mehdi.abaakouk@enovance.com>
|
||||
# Copyright 2013-2015 eNovance <licensing@enovance.com>
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -16,7 +14,6 @@
|
|||
# under the License.
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_context import context
|
||||
from oslo_log import log
|
||||
import six
|
||||
|
||||
|
@ -51,7 +48,7 @@ class RPCAlarmNotifier(object):
|
|||
'previous': previous,
|
||||
'state': alarm.state})
|
||||
return
|
||||
self.client.cast(context.get_admin_context(),
|
||||
self.client.cast({},
|
||||
'notify_alarm', data={
|
||||
'actions': actions,
|
||||
'alarm_id': alarm.alarm_id,
|
||||
|
|
|
@ -240,8 +240,7 @@ class TestEvaluate(base.TestEvaluatorBase):
|
|||
def test_alarm_change_record(self, get_notifier, utcnow, mock_uuid):
|
||||
# the context.RequestContext() method need to generate uuid,
|
||||
# so we need to provide 'fake_uuid_0' and 'fake_uuid_1' for that.
|
||||
mock_uuid.side_effect = ['fake_event_id_0', 'fake_uuid_0',
|
||||
'fake_event_id_1', 'fake_uuid_1']
|
||||
mock_uuid.side_effect = ['fake_event_id_0', 'fake_event_id_1']
|
||||
change_notifier = mock.MagicMock()
|
||||
get_notifier.return_value = change_notifier
|
||||
utcnow.return_value = datetime.datetime(2015, 7, 26, 3, 33, 21, 876795)
|
||||
|
|
|
@ -1675,18 +1675,7 @@ class TestAlarms(TestAlarmsBase):
|
|||
'user_id']).issubset(payload.keys()))
|
||||
|
||||
endpoint.info.assert_called_once_with(
|
||||
{'resource_uuid': None,
|
||||
'domain': None,
|
||||
'project_domain': None,
|
||||
'auth_token': None,
|
||||
'is_admin': False,
|
||||
'user': None,
|
||||
'tenant': None,
|
||||
'read_only': False,
|
||||
'show_deleted': False,
|
||||
'user_identity': '- - - - -',
|
||||
'request_id': mock.ANY,
|
||||
'user_domain': None},
|
||||
{},
|
||||
'aodh.api', 'alarm.creation',
|
||||
PayloadMatcher(), mock.ANY)
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright 2013-2014 eNovance
|
||||
# Copyright 2013-2015 eNovance
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
|
@ -15,7 +15,6 @@
|
|||
|
||||
import mock
|
||||
from oslo_config import fixture as fixture_config
|
||||
from oslo_context import context
|
||||
from oslo_serialization import jsonutils
|
||||
from oslotest import mockpatch
|
||||
import requests
|
||||
|
@ -68,7 +67,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
'reason': 'Everything is on fire',
|
||||
'reason_data': {'fire': 'everywhere'}
|
||||
}
|
||||
self.service.notify_alarm(context.get_admin_context(), data)
|
||||
self.service.notify_alarm({}, data)
|
||||
notifications = self.service.notifiers['test'].obj.notifications
|
||||
self.assertEqual(1, len(notifications))
|
||||
self.assertEqual((urlparse.urlsplit(data['actions'][0]),
|
||||
|
@ -82,10 +81,10 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
notifications[0])
|
||||
|
||||
def test_notify_alarm_no_action(self):
|
||||
self.service.notify_alarm(context.get_admin_context(), {})
|
||||
self.service.notify_alarm({}, {})
|
||||
|
||||
def test_notify_alarm_log_action(self):
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
{
|
||||
'actions': ['log://'],
|
||||
'alarm_id': 'foobar',
|
||||
|
@ -113,7 +112,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY)
|
||||
|
@ -129,7 +128,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY,
|
||||
|
@ -148,7 +147,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY,
|
||||
|
@ -164,7 +163,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY,
|
||||
|
@ -178,7 +177,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY,
|
||||
|
@ -194,7 +193,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
poster.assert_called_with(action, data=mock.ANY,
|
||||
headers=mock.ANY,
|
||||
|
@ -213,7 +212,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
LOG = mock.MagicMock()
|
||||
with mock.patch('aodh.notifier.LOG', LOG):
|
||||
self.service.notify_alarm(
|
||||
context.get_admin_context(),
|
||||
{},
|
||||
{
|
||||
'actions': ['no-such-action-i-am-sure'],
|
||||
'alarm_id': 'foobar',
|
||||
|
@ -225,7 +224,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
LOG = mock.MagicMock()
|
||||
with mock.patch('aodh.notifier.LOG', LOG):
|
||||
self.service.notify_alarm(
|
||||
context.get_admin_context(),
|
||||
{},
|
||||
{
|
||||
'actions': ['no-such-action-i-am-sure://'],
|
||||
'alarm_id': 'foobar',
|
||||
|
@ -247,7 +246,7 @@ class TestAlarmNotifier(tests_base.BaseTestCase):
|
|||
|
||||
with mock.patch('eventlet.spawn_n', self._fake_spawn_n):
|
||||
with mock.patch.object(requests.Session, 'post') as poster:
|
||||
self.service.notify_alarm(context.get_admin_context(),
|
||||
self.service.notify_alarm({},
|
||||
self._notification(action))
|
||||
headers = {'X-Auth-Token': 'token_1234'}
|
||||
headers.update(self.HTTP_HEADERS)
|
||||
|
|
|
@ -46,7 +46,6 @@ extensions = [
|
|||
'sphinx.ext.viewcode',
|
||||
'sphinxcontrib.pecanwsme.rest',
|
||||
'oslosphinx',
|
||||
'sphinxcontrib.docbookrestapi.setup',
|
||||
'stevedore.sphinxext',
|
||||
]
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ psycopg2
|
|||
pymongo>=3.0.2
|
||||
python-subunit>=0.0.18
|
||||
sphinx!=1.2.0,!=1.3b1,<1.3,>=1.1.2
|
||||
sphinxcontrib-docbookrestapi
|
||||
sphinxcontrib-httpdomain
|
||||
sphinxcontrib-pecanwsme>=0.8
|
||||
testrepository>=0.0.18
|
||||
|
|
Loading…
Reference in New Issue