
There are usage patterns which would benefit from having the capability to send a list of resources in bulk instead of using individual fanout messages. From now on, the rpc callback subscriber receives a list of resources (single or multiple), and the pushers must always push a list. Backwards compatibility for QoSPolicy consumers in mitaka is provided by calling push with "resource" parameter for single item lists during one release cycle. That will be dropped when Ocata opens. Partially-implements: blueprint vlan-aware-vms Change-Id: I1117925360a29ecbd1902fa527b2f24f94ce81ec
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
# 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
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
import mock
|
|
|
|
from neutron.api.rpc.callbacks.consumer import registry
|
|
from neutron.tests import base
|
|
|
|
|
|
class ConsumerRegistryTestCase(base.BaseTestCase):
|
|
|
|
def setUp(self):
|
|
super(ConsumerRegistryTestCase, self).setUp()
|
|
|
|
def test__get_manager_is_singleton(self):
|
|
self.assertIs(registry._get_manager(), registry._get_manager())
|
|
|
|
@mock.patch.object(registry, '_get_manager')
|
|
def test_subscribe(self, manager_mock):
|
|
callback = lambda: None
|
|
registry.subscribe(callback, 'TYPE')
|
|
manager_mock().register.assert_called_with(callback, 'TYPE')
|
|
|
|
@mock.patch.object(registry, '_get_manager')
|
|
def test_unsubscribe(self, manager_mock):
|
|
callback = lambda: None
|
|
registry.unsubscribe(callback, 'TYPE')
|
|
manager_mock().unregister.assert_called_with(callback, 'TYPE')
|
|
|
|
@mock.patch.object(registry, '_get_manager')
|
|
def test_clear(self, manager_mock):
|
|
registry.clear()
|
|
manager_mock().clear.assert_called_with()
|
|
|
|
@mock.patch.object(registry, '_get_manager')
|
|
def test_push(self, manager_mock):
|
|
resource_type_ = object()
|
|
resource_ = object()
|
|
event_type_ = object()
|
|
|
|
callback1 = mock.Mock()
|
|
callback2 = mock.Mock()
|
|
callbacks = {callback1, callback2}
|
|
manager_mock().get_callbacks.return_value = callbacks
|
|
registry.push(resource_type_, [resource_], event_type_)
|
|
for callback in callbacks:
|
|
callback.assert_called_with([resource_], event_type_)
|