summaryrefslogtreecommitdiff
path: root/nova
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2021-06-09 00:54:27 +0000
committerGerrit Code Review <review@openstack.org>2021-06-09 00:54:27 +0000
commit620a93181334692a54077ecb7abe062c8af1d2c4 (patch)
treeb31fa96a7d8ca0df3234f3a923a1d16086b9144b /nova
parent14c5f979a2c3978304de5b30e8786475df111cf5 (diff)
parentf1f599d098c2dcb307bfab074060855c703a8288 (diff)
downloadnova-620a93181334692a54077ecb7abe062c8af1d2c4.tar.gz
Merge "Create a fixture around fake_notifier"
Diffstat (limited to 'nova')
-rw-r--r--nova/tests/fixtures/__init__.py1
-rw-r--r--nova/tests/fixtures/notifications.py39
-rw-r--r--nova/tests/functional/compute/test_cache_image.py12
-rw-r--r--nova/tests/functional/compute/test_init_host.py3
-rw-r--r--nova/tests/functional/compute/test_live_migration.py3
-rw-r--r--nova/tests/functional/compute/test_resource_tracker.py3
-rw-r--r--nova/tests/functional/integrated_helpers.py27
-rw-r--r--nova/tests/functional/libvirt/test_evacuate.py7
-rw-r--r--nova/tests/functional/libvirt/test_numa_servers.py4
-rw-r--r--nova/tests/functional/libvirt/test_pci_sriov_servers.py5
-rw-r--r--nova/tests/functional/notification_sample_tests/notification_sample_base.py29
-rw-r--r--nova/tests/functional/notification_sample_tests/test_aggregate.py55
-rw-r--r--nova/tests/functional/notification_sample_tests/test_compute_task.py23
-rw-r--r--nova/tests/functional/notification_sample_tests/test_exception_notification.py7
-rw-r--r--nova/tests/functional/notification_sample_tests/test_flavor.py13
-rw-r--r--nova/tests/functional/notification_sample_tests/test_instance.py417
-rw-r--r--nova/tests/functional/notification_sample_tests/test_keypair.py19
-rw-r--r--nova/tests/functional/notification_sample_tests/test_libvirt.py5
-rw-r--r--nova/tests/functional/notification_sample_tests/test_metrics.py5
-rw-r--r--nova/tests/functional/notification_sample_tests/test_server_group.py17
-rw-r--r--nova/tests/functional/notification_sample_tests/test_service.py3
-rw-r--r--nova/tests/functional/notification_sample_tests/test_volume.py11
-rw-r--r--nova/tests/functional/regressions/test_bug_1713783.py4
-rw-r--r--nova/tests/functional/regressions/test_bug_1735407.py9
-rw-r--r--nova/tests/functional/regressions/test_bug_1764883.py3
-rw-r--r--nova/tests/functional/regressions/test_bug_1781286.py13
-rw-r--r--nova/tests/functional/regressions/test_bug_1806515.py3
-rw-r--r--nova/tests/functional/regressions/test_bug_1835822.py5
-rw-r--r--nova/tests/functional/regressions/test_bug_1843090.py3
-rw-r--r--nova/tests/functional/regressions/test_bug_1843708.py3
-rw-r--r--nova/tests/functional/regressions/test_bug_1862633.py7
-rw-r--r--nova/tests/functional/test_cold_migrate.py3
-rw-r--r--nova/tests/functional/test_cross_cell_migrate.py37
-rw-r--r--nova/tests/functional/test_server_external_events.py9
-rw-r--r--nova/tests/functional/test_servers.py40
-rw-r--r--nova/tests/unit/compute/test_compute.py3
-rw-r--r--nova/tests/unit/compute/test_compute_mgr.py35
-rw-r--r--nova/tests/unit/compute/test_compute_utils.py55
-rw-r--r--nova/tests/unit/compute/test_host_api.py3
-rw-r--r--nova/tests/unit/compute/test_resource_tracker.py4
-rw-r--r--nova/tests/unit/conductor/test_conductor.py3
-rw-r--r--nova/tests/unit/objects/test_objects.py4
-rw-r--r--nova/tests/unit/test_exception_wrapper.py15
-rw-r--r--nova/tests/unit/test_notifications.py58
44 files changed, 505 insertions, 522 deletions
diff --git a/nova/tests/fixtures/__init__.py b/nova/tests/fixtures/__init__.py
index ff6fe76f64..df254608fd 100644
--- a/nova/tests/fixtures/__init__.py
+++ b/nova/tests/fixtures/__init__.py
@@ -20,6 +20,7 @@ from .glance import GlanceFixture # noqa: F401
from .libvirt import LibvirtFixture # noqa: F401
from .libvirt_imagebackend import LibvirtImageBackendFixture # noqa: F401
from .neutron import NeutronFixture # noqa: F401
+from .notifications import NotificationFixture # noqa: F401
from .nova import * # noqa: F401, F403
from .os_brick import OSBrickFixture # noqa: F401
from .policy import OverridePolicyFixture # noqa: F401
diff --git a/nova/tests/fixtures/notifications.py b/nova/tests/fixtures/notifications.py
new file mode 100644
index 0000000000..309b9f83c8
--- /dev/null
+++ b/nova/tests/fixtures/notifications.py
@@ -0,0 +1,39 @@
+# 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 fixtures
+
+from nova.tests.unit import fake_notifier
+
+
+class NotificationFixture(fixtures.Fixture):
+ def __init__(self, test):
+ self.test = test
+
+ def setUp(self):
+ super().setUp()
+ self.addCleanup(fake_notifier.reset)
+ fake_notifier.stub_notifier(self.test)
+
+ def reset(self):
+ fake_notifier.reset()
+
+ def wait_for_versioned_notifications(
+ self, event_type, n_events=1, timeout=10.0,
+ ):
+ return fake_notifier.VERSIONED_SUBS[event_type].wait_n(
+ n_events, event_type, timeout,
+ )
+
+ @property
+ def versioned_notifications(self):
+ return fake_notifier.VERSIONED_NOTIFICATIONS
diff --git a/nova/tests/functional/compute/test_cache_image.py b/nova/tests/functional/compute/test_cache_image.py
index 86a3e9e26e..e24b9da879 100644
--- a/nova/tests/functional/compute/test_cache_image.py
+++ b/nova/tests/functional/compute/test_cache_image.py
@@ -15,7 +15,7 @@ from oslo_utils.fixture import uuidsentinel as uuids
from nova import context
from nova import objects
from nova import test
-from nova.tests.unit import fake_notifier
+from nova.tests import fixtures
class ImageCacheTest(test.TestCase):
@@ -26,8 +26,8 @@ class ImageCacheTest(test.TestCase):
self.flags(compute_driver='fake.FakeDriverWithCaching')
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(fixtures.NotificationFixture(self))
+
self.context = context.get_admin_context()
self.conductor = self.start_service('conductor')
@@ -70,10 +70,10 @@ class ImageCacheTest(test.TestCase):
mgr = getattr(self, host)
self.assertEqual(set(), mgr.driver.cached_images)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'aggregate.cache_images.start')
- progress = fake_notifier.wait_for_versioned_notifications(
+ progress = self.notifier.wait_for_versioned_notifications(
'aggregate.cache_images.progress', n_events=4)
self.assertEqual(4, len(progress), progress)
for notification in progress:
@@ -89,7 +89,7 @@ class ImageCacheTest(test.TestCase):
self.assertEqual(4, payload['total'])
self.assertIn('conductor', notification['publisher_id'])
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'aggregate.cache_images.end')
logtext = self.stdlog.logger.output
diff --git a/nova/tests/functional/compute/test_init_host.py b/nova/tests/functional/compute/test_init_host.py
index 2fb486f5ee..f506f6ed59 100644
--- a/nova/tests/functional/compute/test_init_host.py
+++ b/nova/tests/functional/compute/test_init_host.py
@@ -16,7 +16,6 @@ import time
from nova import context as nova_context
from nova import objects
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class ComputeManagerInitHostTestCase(
@@ -164,7 +163,7 @@ class TestComputeRestartInstanceStuckInBuild(
# the instance.create.start is the closest thing to the
# instance_claim call we can wait for in the test
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.create.start')
with mock.patch('nova.compute.manager.LOG.debug') as mock_log:
diff --git a/nova/tests/functional/compute/test_live_migration.py b/nova/tests/functional/compute/test_live_migration.py
index d94b084736..8e9b91dded 100644
--- a/nova/tests/functional/compute/test_live_migration.py
+++ b/nova/tests/functional/compute/test_live_migration.py
@@ -19,7 +19,6 @@ from nova import exception
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class FakeCinderError(object):
@@ -48,8 +47,6 @@ class LiveMigrationCinderFailure(integrated_helpers._IntegratedTestBase):
def setUp(self):
super(LiveMigrationCinderFailure, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
# Start a second compute node (the first one was started for us by
# _IntegratedTestBase. set_nodes() is needed to avoid duplicate
# nodenames. See comments in test_bug_1702454.py.
diff --git a/nova/tests/functional/compute/test_resource_tracker.py b/nova/tests/functional/compute/test_resource_tracker.py
index e57e5abf92..81b7dfb68c 100644
--- a/nova/tests/functional/compute/test_resource_tracker.py
+++ b/nova/tests/functional/compute/test_resource_tracker.py
@@ -32,7 +32,6 @@ from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
from nova.virt import driver as virt_driver
@@ -703,8 +702,6 @@ class TestProviderConfig(integrated_helpers.ProviderUsageBaseTestCase):
self.api = self.useFixture(nova_fixtures.OSAPIFixture(
api_version='v2.1')).admin_api
self.api.microversion = 'latest'
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
self.start_service('conductor')
# start nova-compute that will not have the additional trait.
self._start_compute("fake-host-1")
diff --git a/nova/tests/functional/integrated_helpers.py b/nova/tests/functional/integrated_helpers.py
index f0b931185e..ec73a05f21 100644
--- a/nova/tests/functional/integrated_helpers.py
+++ b/nova/tests/functional/integrated_helpers.py
@@ -40,7 +40,6 @@ from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional.api import client as api_client
from nova.tests.functional import fixtures as func_fixtures
-from nova.tests.unit import fake_notifier
from nova import utils
@@ -408,7 +407,7 @@ class InstanceHelperMixin:
self.api.post_server_action(
server['id'], {'reboot': {'type': 'HARD' if hard else 'SOFT'}},
)
- fake_notifier.wait_for_versioned_notifications('instance.reboot.end')
+ self.notifier.wait_for_versioned_notifications('instance.reboot.end')
return self._wait_for_state_change(server, expected_state)
def _attach_interface(self, server, port_uuid):
@@ -419,14 +418,14 @@ class InstanceHelperMixin:
}
}
attachment = self.api.attach_interface(server['id'], body)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.interface_attach.end')
return attachment
def _detach_interface(self, server, port_uuid):
"""detach a neutron port form a server."""
self.api.detach_interface(server['id'], port_uuid)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.interface_detach.end')
def _rebuild_server(self, server, image_uuid, expected_state='ACTIVE'):
@@ -434,7 +433,7 @@ class InstanceHelperMixin:
self.api.post_server_action(
server['id'], {'rebuild': {'imageRef': image_uuid}},
)
- fake_notifier.wait_for_versioned_notifications('instance.rebuild.end')
+ self.notifier.wait_for_versioned_notifications('instance.rebuild.end')
return self._wait_for_state_change(server, expected_state)
def _migrate_server(self, server, host=None):
@@ -446,7 +445,7 @@ class InstanceHelperMixin:
def _resize_server(self, server, flavor_id):
self.api.post_server_action(
server['id'], {'resize': {'flavorRef': flavor_id}})
- fake_notifier.wait_for_versioned_notifications('instance.resize.end')
+ self.notifier.wait_for_versioned_notifications('instance.resize.end')
return self._wait_for_state_change(server, 'VERIFY_RESIZE')
def _confirm_resize(self, server, *, cross_cell=False):
@@ -469,7 +468,7 @@ class InstanceHelperMixin:
# dest host revert_resize method but the allocations are cleaned up
# in the source host finish_revert_resize method so we need to wait
# for the finish_revert_resize method to complete.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
return server
@@ -488,13 +487,13 @@ class InstanceHelperMixin:
def _suspend_server(self, server, expected_state='SUSPENDED'):
"""Suspend a server."""
self.api.post_server_action(server['id'], {'suspend': {}})
- fake_notifier.wait_for_versioned_notifications('instance.suspend.end')
+ self.notifier.wait_for_versioned_notifications('instance.suspend.end')
return self._wait_for_state_change(server, expected_state)
def _resume_server(self, server, expected_state='ACTIVE'):
"""Resume a server."""
self.api.post_server_action(server['id'], {'resume': {}})
- fake_notifier.wait_for_versioned_notifications('instance.resume.end')
+ self.notifier.wait_for_versioned_notifications('instance.resume.end')
return self._wait_for_state_change(server, expected_state)
def _shelve_server(self, server, expected_state='SHELVED_OFFLOADED'):
@@ -914,7 +913,7 @@ class PlacementInstanceHelperMixin(InstanceHelperMixin, PlacementHelperMixin):
# instance.delete.end notification as that is emitted after the
# resources are freed.
- fake_notifier.wait_for_versioned_notifications('instance.delete.end')
+ self.notifier.wait_for_versioned_notifications('instance.delete.end')
for rp_uuid in [
self._get_provider_uuid_by_host(hostname)
@@ -1115,8 +1114,8 @@ class _IntegratedTestBase(test.TestCase, PlacementInstanceHelperMixin):
self.glance = self.useFixture(nova_fixtures.GlanceFixture(self))
self.policy = self.useFixture(nova_fixtures.RealPolicyFixture())
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
self._setup_services()
@@ -1186,8 +1185,8 @@ class ProviderUsageBaseTestCase(test.TestCase, PlacementInstanceHelperMixin):
self.placement = self.useFixture(func_fixtures.PlacementFixture()).api
self.useFixture(nova_fixtures.AllServicesCurrent())
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
self.api_fixture = self.useFixture(nova_fixtures.OSAPIFixture(
api_version='v2.1'))
diff --git a/nova/tests/functional/libvirt/test_evacuate.py b/nova/tests/functional/libvirt/test_evacuate.py
index 9e8d61b351..856f326135 100644
--- a/nova/tests/functional/libvirt/test_evacuate.py
+++ b/nova/tests/functional/libvirt/test_evacuate.py
@@ -31,7 +31,6 @@ from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit import fake_network
-from nova.tests.unit import fake_notifier
from nova.virt.libvirt import config as libvirt_config
CONF = conf.CONF
@@ -431,8 +430,8 @@ class _LibvirtEvacuateTest(integrated_helpers.InstanceHelperMixin):
# force_down and evacuate without onSharedStorage
self.api.microversion = '2.14'
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
self.useFixture(nova_fixtures.LibvirtFixture())
@@ -523,7 +522,7 @@ class _LibvirtEvacuateTest(integrated_helpers.InstanceHelperMixin):
expected_task_state=None, expected_migration_status='failed')
# Wait for the rebuild to start, then complete
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.rebuild.start')
# Meta-test
diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py
index c2e58bc5b6..4f8f78a6bb 100644
--- a/nova/tests/functional/libvirt/test_numa_servers.py
+++ b/nova/tests/functional/libvirt/test_numa_servers.py
@@ -27,7 +27,6 @@ from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.api import client
from nova.tests.functional.libvirt import base
-from nova.tests.unit import fake_notifier
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@@ -1252,9 +1251,6 @@ class NUMAServersRebuildTests(NUMAServersTestBase):
self.image_ref_0 = images[0]['id']
self.image_ref_1 = images[1]['id']
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
-
def _create_active_server(self, server_args=None):
basic_server = {
'flavorRef': 1,
diff --git a/nova/tests/functional/libvirt/test_pci_sriov_servers.py b/nova/tests/functional/libvirt/test_pci_sriov_servers.py
index 63e7a16000..0802a1f643 100644
--- a/nova/tests/functional/libvirt/test_pci_sriov_servers.py
+++ b/nova/tests/functional/libvirt/test_pci_sriov_servers.py
@@ -35,7 +35,6 @@ from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.api import client
from nova.tests.functional.libvirt import base
-from nova.tests.unit import fake_notifier
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@@ -711,14 +710,14 @@ class SRIOVAttachDetachTest(_PCIServersTestBase):
def _detach_port(self, instance_uuid, port_id):
self.api.detach_interface(instance_uuid, port_id)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.interface_detach.end')
def _attach_port(self, instance_uuid, port_id):
self.api.attach_interface(
instance_uuid,
{'interfaceAttachment': {'port_id': port_id}})
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.interface_attach.end')
def _test_detach_attach(self, first_port_id, second_port_id):
diff --git a/nova/tests/functional/notification_sample_tests/notification_sample_base.py b/nova/tests/functional/notification_sample_tests/notification_sample_base.py
index b6f25f459c..72291e55cd 100644
--- a/nova/tests/functional/notification_sample_tests/notification_sample_base.py
+++ b/nova/tests/functional/notification_sample_tests/notification_sample_base.py
@@ -27,7 +27,6 @@ from nova.tests.functional import integrated_helpers
from nova.tests import json_ref
from nova.tests.unit.api.openstack.compute import test_services
from nova.tests.unit import fake_crypto
-from nova.tests.unit import fake_notifier
CONF = cfg.CONF
@@ -75,8 +74,8 @@ class NotificationSampleTestBase(test.TestCase,
self.api.microversion = max_version
self.admin_api.microversion = max_version
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
self.useFixture(utils_fixture.TimeFixture(test_services.fake_utcnow()))
self.useFixture(nova_fixtures.GlanceFixture(self))
@@ -92,7 +91,7 @@ class NotificationSampleTestBase(test.TestCase,
self.start_service('scheduler')
self.compute = self.start_service('compute')
# Reset the service create notifications
- fake_notifier.reset()
+ self.notifier.reset()
def _get_notification_sample(self, sample):
sample_dir = os.path.dirname(os.path.abspath(__file__))
@@ -136,9 +135,9 @@ class NotificationSampleTestBase(test.TestCase,
notification emitted during the test.
"""
if not actual:
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
+ notification = self.notifier.versioned_notifications[0]
else:
notification = actual
sample_file = self._get_notification_sample(sample_file_name)
@@ -163,12 +162,12 @@ class NotificationSampleTestBase(test.TestCase,
scheduler_expected_notifications = [
'scheduler-select_destinations-start',
'scheduler-select_destinations-end']
- self.assertLessEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertLessEqual(2, len(self.notifier.versioned_notifications))
for notification in scheduler_expected_notifications:
self._verify_notification(
notification,
replacements=replacements,
- actual=fake_notifier.VERSIONED_NOTIFICATIONS.pop(0))
+ actual=self.notifier.versioned_notifications.pop(0))
def _boot_a_server(self, expected_status='ACTIVE', extra_params=None,
scheduler_hints=None, additional_extra_specs=None):
@@ -191,7 +190,7 @@ class NotificationSampleTestBase(test.TestCase,
self.admin_api.post_extra_spec(flavor_id, extra_specs)
# Ignore the create flavor notification
- fake_notifier.reset()
+ self.notifier.reset()
keypair_req = {
"keypair": {
@@ -204,11 +203,11 @@ class NotificationSampleTestBase(test.TestCase,
'keypair-import-start',
'keypair-import-end'
]
- self.assertLessEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertLessEqual(2, len(self.notifier.versioned_notifications))
for notification in keypair_expected_notifications:
self._verify_notification(
notification,
- actual=fake_notifier.VERSIONED_NOTIFICATIONS.pop(0))
+ actual=self.notifier.versioned_notifications.pop(0))
server = self._build_server(
name='some-server',
@@ -252,19 +251,19 @@ class NotificationSampleTestBase(test.TestCase,
def _get_notifications(self, event_type):
return [notification for notification
- in fake_notifier.VERSIONED_NOTIFICATIONS
+ in self.notifier.versioned_notifications
if notification['event_type'] == event_type]
def _wait_for_notification(self, event_type, timeout=10.0):
# NOTE(mdbooth): wait_for_versioned_notifications raises an exception
# if it times out since change I017d1a31. Consider removing this
# method.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
event_type, timeout=timeout)
def _wait_for_notifications(self, event_type, expected_count,
timeout=10.0):
- notifications = fake_notifier.wait_for_versioned_notifications(
+ notifications = self.notifier.wait_for_versioned_notifications(
event_type, n_events=expected_count, timeout=timeout)
msg = ''.join('\n%s' % notif for notif in notifications)
diff --git a/nova/tests/functional/notification_sample_tests/test_aggregate.py b/nova/tests/functional/notification_sample_tests/test_aggregate.py
index 4b90f082be..73fcb85cca 100644
--- a/nova/tests/functional/notification_sample_tests/test_aggregate.py
+++ b/nova/tests/functional/notification_sample_tests/test_aggregate.py
@@ -11,7 +11,6 @@
# under the License.
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestAggregateNotificationSample(
@@ -28,34 +27,34 @@ class TestAggregateNotificationSample(
"availability_zone": "nova"}}
aggregate = self.admin_api.post_aggregate(aggregate_req)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-create-start',
replacements={
'uuid': aggregate['uuid']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'aggregate-create-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self.admin_api.delete_aggregate(aggregate['id'])
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(4, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-delete-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'aggregate-delete-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
def test_aggregate_add_remove_host(self):
aggregate_req = {
@@ -64,7 +63,7 @@ class TestAggregateNotificationSample(
"availability_zone": "nova"}}
aggregate = self.admin_api.post_aggregate(aggregate_req)
- fake_notifier.reset()
+ self.notifier.reset()
add_host_req = {
"add_host": {
@@ -73,19 +72,19 @@ class TestAggregateNotificationSample(
}
self.admin_api.post_aggregate_action(aggregate['id'], add_host_req)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-add_host-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'aggregate-add_host-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
remove_host_req = {
"remove_host": {
@@ -94,19 +93,19 @@ class TestAggregateNotificationSample(
}
self.admin_api.post_aggregate_action(aggregate['id'], remove_host_req)
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(4, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-remove_host-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'aggregate-remove_host-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self.admin_api.delete_aggregate(aggregate['id'])
@@ -124,22 +123,22 @@ class TestAggregateNotificationSample(
}
}
}
- fake_notifier.reset()
+ self.notifier.reset()
self.admin_api.post_aggregate_action(aggregate['id'], set_metadata_req)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-update_metadata-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'aggregate-update_metadata-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def test_aggregate_updateprops(self):
aggregate_req = {
@@ -157,19 +156,19 @@ class TestAggregateNotificationSample(
# 1. aggregate-create-end
# 2. aggregate-update_prop-start
# 3. aggregate-update_prop-end
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(4, len(self.notifier.versioned_notifications))
self._verify_notification(
'aggregate-update_prop-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'aggregate-update_prop-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
def test_aggregate_cache_images(self):
aggregate_req = {
@@ -184,7 +183,7 @@ class TestAggregateNotificationSample(
}
self.admin_api.post_aggregate_action(aggregate['id'], add_host_req)
- fake_notifier.reset()
+ self.notifier.reset()
cache_images_req = {
'cache': [
@@ -195,26 +194,26 @@ class TestAggregateNotificationSample(
cache_images_req)
# Since the operation is asynchronous we have to wait for the end
# notification.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'aggregate.cache_images.end')
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'aggregate-cache_images-start',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'aggregate-cache_images-progress',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self._verify_notification(
'aggregate-cache_images-end',
replacements={
'uuid': aggregate['uuid'],
'id': aggregate['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
diff --git a/nova/tests/functional/notification_sample_tests/test_compute_task.py b/nova/tests/functional/notification_sample_tests/test_compute_task.py
index 20caa3b78d..3de1c7d4e1 100644
--- a/nova/tests/functional/notification_sample_tests/test_compute_task.py
+++ b/nova/tests/functional/notification_sample_tests/test_compute_task.py
@@ -13,7 +13,6 @@
from nova.tests import fixtures
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestComputeTaskNotificationSample(
@@ -38,8 +37,8 @@ class TestComputeTaskNotificationSample(
self._wait_for_notification('compute_task.build_instances.error')
# 0. scheduler.select_destinations.start
# 1. compute_task.rebuild_server.error
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'compute_task-build_instances-error',
replacements={
@@ -52,7 +51,7 @@ class TestComputeTaskNotificationSample(
'reason.module_name': self.ANY,
'reason.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def test_rebuild_fault(self):
server = self._boot_a_server(
@@ -65,7 +64,7 @@ class TestComputeTaskNotificationSample(
service_id = self.api.get_service_id('nova-compute')
self.admin_api.put_service_force_down(service_id, True)
- fake_notifier.reset()
+ self.notifier.reset()
# NOTE(takashin): The rebuild action and the evacuate action shares
# same code path. So the 'evacuate' action is used for this test.
@@ -76,8 +75,8 @@ class TestComputeTaskNotificationSample(
# 0. instance.evacuate
# 1. scheduler.select_destinations.start
# 2. compute_task.rebuild_server.error
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'compute_task-rebuild_server-error',
replacements={
@@ -90,7 +89,7 @@ class TestComputeTaskNotificationSample(
'reason.module_name': self.ANY,
'reason.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
def test_migrate_fault(self):
server = self._boot_a_server(
@@ -103,14 +102,14 @@ class TestComputeTaskNotificationSample(
service_id = self.api.get_service_id('nova-compute')
self.admin_api.put_service(service_id, {'status': 'disabled'})
- fake_notifier.reset()
+ self.notifier.reset()
# Note that the operation will return a 202 response but fail with
# NoValidHost asynchronously.
self.admin_api.post_server_action(server['id'], {'migrate': None})
self._wait_for_notification('compute_task.migrate_server.error')
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(1, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'compute_task-migrate_server-error',
replacements={
@@ -124,4 +123,4 @@ class TestComputeTaskNotificationSample(
'reason.module_name': self.ANY,
'reason.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
diff --git a/nova/tests/functional/notification_sample_tests/test_exception_notification.py b/nova/tests/functional/notification_sample_tests/test_exception_notification.py
index a21acb0c95..e3ff85a0fb 100644
--- a/nova/tests/functional/notification_sample_tests/test_exception_notification.py
+++ b/nova/tests/functional/notification_sample_tests/test_exception_notification.py
@@ -12,7 +12,6 @@
from nova.tests.functional.api import client as api_client
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestExceptionNotificationSample(
@@ -33,12 +32,12 @@ class TestExceptionNotificationSample(
self.assertRaises(api_client.OpenStackApiException,
self.admin_api.api_post, 'os-aggregates', post)
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- traceback = fake_notifier.VERSIONED_NOTIFICATIONS[3][
+ self.assertEqual(4, len(self.notifier.versioned_notifications))
+ traceback = self.notifier.versioned_notifications[3][
'payload']['nova_object.data']['traceback']
self.assertIn('AggregateNameExists', traceback)
self._verify_notification(
'compute-exception',
replacements={
'traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
diff --git a/nova/tests/functional/notification_sample_tests/test_flavor.py b/nova/tests/functional/notification_sample_tests/test_flavor.py
index f206a01b97..478cbc2c64 100644
--- a/nova/tests/functional/notification_sample_tests/test_flavor.py
+++ b/nova/tests/functional/notification_sample_tests/test_flavor.py
@@ -12,7 +12,6 @@
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestFlavorNotificationSample(
@@ -48,7 +47,7 @@ class TestFlavorNotificationSample(
self.admin_api.api_delete(
'flavors/a22d5517-147c-4147-a0d1-e698df5cd4e3')
self._verify_notification(
- 'flavor-delete', actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ 'flavor-delete', actual=self.notifier.versioned_notifications[1])
def test_flavor_update(self):
body = {
@@ -84,7 +83,7 @@ class TestFlavorNotificationSample(
body)
self._verify_notification(
- 'flavor-update', actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ 'flavor-update', actual=self.notifier.versioned_notifications[2])
class TestFlavorNotificationSamplev2_55(
@@ -110,11 +109,11 @@ class TestFlavorNotificationSamplev2_55(
flavor = self.admin_api.api_post('flavors', body).body['flavor']
# Check the notification; should be the same as the sample where there
# is no description set.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'flavor-create',
replacements={'is_public': False},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
# Update and set the flavor description.
self.admin_api.api_put(
@@ -122,10 +121,10 @@ class TestFlavorNotificationSamplev2_55(
{'flavor': {'description': 'test description'}}).body['flavor']
# Assert the notifications, one for create and one for update.
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'flavor-update',
replacements={'description': 'test description',
'extra_specs': {},
'projects': []},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
diff --git a/nova/tests/functional/notification_sample_tests/test_instance.py b/nova/tests/functional/notification_sample_tests/test_instance.py
index a263e51293..81020710dc 100644
--- a/nova/tests/functional/notification_sample_tests/test_instance.py
+++ b/nova/tests/functional/notification_sample_tests/test_instance.py
@@ -19,7 +19,6 @@ from nova.tests import fixtures
from nova.tests.functional.api import client
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestInstanceNotificationSampleWithMultipleCompute(
@@ -55,7 +54,7 @@ class TestInstanceNotificationSampleWithMultipleCompute(
]
for action in actions:
- fake_notifier.reset()
+ self.notifier.reset()
action(server)
# Ensure that instance is in active state after an action
self._wait_for_state_change(server, 'ACTIVE')
@@ -82,33 +81,33 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# 3. instance.live_migration_rollback.end
# 4. instance.live_migration_rollback_dest.start
# 5. instance.live_migration_rollback_dest.end
- self.assertEqual(6, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(6, len(self.notifier.versioned_notifications),
[x['event_type'] for x in
- fake_notifier.VERSIONED_NOTIFICATIONS])
+ self.notifier.versioned_notifications])
self._verify_notification(
'instance-live_migration_rollback-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-live_migration_rollback-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self._verify_notification(
'instance-live_migration_rollback_dest-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-live_migration_rollback_dest-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
def _test_live_migration_success(self, server):
post = {
@@ -123,21 +122,21 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# 1. scheduler.select_destinations.end
# 2. instance.live_migration_pre.start
# 3. instance.live_migration_pre.end
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(4, len(self.notifier.versioned_notifications),
[x['event_type'] for x in
- fake_notifier.VERSIONED_NOTIFICATIONS])
+ self.notifier.versioned_notifications])
self._verify_notification(
'instance-live_migration_pre-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-live_migration_pre-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
migrations = self.admin_api.get_active_migrations(server['id'])
self.assertEqual(1, len(migrations))
@@ -150,33 +149,33 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# 5. instance.live_migration_post_dest.start
# 6. instance.live_migration_post_dest.end
# 7. instance.live_migration_post.end
- self.assertEqual(8, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(8, len(self.notifier.versioned_notifications),
[x['event_type'] for x in
- fake_notifier.VERSIONED_NOTIFICATIONS])
+ self.notifier.versioned_notifications])
self._verify_notification(
'instance-live_migration_post-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-live_migration_post_dest-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
self._verify_notification(
'instance-live_migration_post_dest-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[6])
+ actual=self.notifier.versioned_notifications[6])
self._verify_notification(
'instance-live_migration_post-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[7])
+ actual=self.notifier.versioned_notifications[7])
def _test_live_migration_abort(self, server):
post = {
@@ -208,45 +207,45 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# 5. instance.live_migration_abort.end
# 6. instance.live_migration_rollback.start
# 7. instance.live_migration_rollback.end
- self.assertEqual(8, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(8, len(self.notifier.versioned_notifications),
[x['event_type'] for x in
- fake_notifier.VERSIONED_NOTIFICATIONS])
+ self.notifier.versioned_notifications])
self._verify_notification(
'instance-live_migration_pre-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-live_migration_pre-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self._verify_notification(
'instance-live_migration_abort-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-live_migration_abort-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
self._verify_notification(
'instance-live_migration_rollback-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[6])
+ actual=self.notifier.versioned_notifications[6])
self._verify_notification(
'instance-live_migration_rollback-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[7])
+ actual=self.notifier.versioned_notifications[7])
def _test_evacuate_server(self, server):
services = self.admin_api.get_services(host='host2',
@@ -266,7 +265,7 @@ class TestInstanceNotificationSampleWithMultipleCompute(
notifications = self._get_notifications('instance.evacuate')
self.assertEqual(1, len(notifications),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-evacuate',
replacements={
@@ -312,20 +311,20 @@ class TestInstanceNotificationSampleWithMultipleCompute(
# 3. instance.live_migration_pre.end
# 4. instance.live_migration_force_complete.start
# 5. instance.live_migration_force_complete.end
- self.assertGreaterEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 6,
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertGreaterEqual(len(self.notifier.versioned_notifications), 6,
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-live_migration_force_complete-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-live_migration_force_complete-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
class TestInstanceNotificationSample(
@@ -387,7 +386,7 @@ class TestInstanceNotificationSample(
]
for action in actions:
- fake_notifier.reset()
+ self.notifier.reset()
action(server)
# Ensure that instance is in active state after an action
self._wait_for_state_change(server, 'ACTIVE')
@@ -411,8 +410,8 @@ class TestInstanceNotificationSample(
# instance.delete.end notification. So to avoid race condition the test
# needs to wait for the notification as well here.
self._wait_for_notification('instance.delete.end')
- self.assertEqual(9, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(9, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
# This list needs to be in order.
expected_notifications = [
@@ -432,7 +431,7 @@ class TestInstanceNotificationSample(
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[idx])
+ actual=self.notifier.versioned_notifications[idx])
@mock.patch('nova.compute.manager.ComputeManager._build_resources')
def test_create_server_error(self, mock_build):
@@ -452,10 +451,10 @@ class TestInstanceNotificationSample(
# 1. scheduler.select_destinations.end
# 2. instance-create-start
# 3. instance-create-error
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(4, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[3]['payload'][
+ tb = self.notifier.versioned_notifications[3]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn('raise exception.FlavorDiskTooSmall()', tb)
@@ -464,33 +463,33 @@ class TestInstanceNotificationSample(
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-create-error',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'fault.traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
- fake_notifier.reset()
+ self.notifier.reset()
self._delete_server(server)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-delete-start_not_scheduled',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-delete-end_not_scheduled',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def test_instance_exists_usage_audit(self):
# TODO(xavvior): Should create a functional test for the
@@ -505,7 +504,7 @@ class TestInstanceNotificationSample(
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
- fake_notifier.reset()
+ self.notifier.reset()
post = {
'rebuild': {
@@ -535,24 +534,24 @@ class TestInstanceNotificationSample(
service_id = self.api.get_service_id('nova-compute')
self.admin_api.put_service_force_down(service_id, True)
- fake_notifier.reset()
+ self.notifier.reset()
self._delete_server(server)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-delete-start_compute_down',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-delete-end_compute_down',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self.admin_api.put_service_force_down(service_id, False)
@@ -667,13 +666,13 @@ class TestInstanceNotificationSample(
replacements = self._verify_instance_update_steps(
create_steps, instance_updates)
- fake_notifier.reset()
+ self.notifier.reset()
self._delete_server(server)
instance_updates = self._get_notifications('instance.update')
self.assertEqual(2, len(instance_updates),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.versioned_notifications)
delete_steps = [
# active -> deleting
@@ -734,55 +733,55 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], {'os-start': {}})
self._wait_for_state_change(server, expected_status='ACTIVE')
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(4, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-power_off-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-power_off-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self._verify_notification(
'instance-power_on-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-power_on-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
def _test_shelve_and_shelve_offload_server(self, server):
self.flags(shelved_offload_time=-1)
self.api.post_server_action(server['id'], {'shelve': {}})
self._wait_for_state_change(server, expected_status='SHELVED')
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-shelve-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self._verify_notification(
'instance-shelve-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
- fake_notifier.reset()
+ self.notifier.reset()
self.api.post_server_action(server['id'], {'shelveOffload': {}})
# we need to wait for the instance.host to become None as well before
# we can unshelve to make sure that the unshelve.start notification
@@ -792,20 +791,20 @@ class TestInstanceNotificationSample(
{'status': 'SHELVED_OFFLOADED',
'OS-EXT-SRV-ATTR:host': None})
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-shelve_offload-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-shelve_offload-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self.api.post_server_action(server['id'], {'unshelve': None})
self._wait_for_state_change(server, 'ACTIVE')
@@ -828,20 +827,20 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_notification('instance.unshelve.end')
- self.assertEqual(9, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(9, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-unshelve-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[7])
+ actual=self.notifier.versioned_notifications[7])
self._verify_notification(
'instance-unshelve-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[8])
+ actual=self.notifier.versioned_notifications[8])
def _test_suspend_resume_server(self, server):
post = {'suspend': {}}
@@ -857,33 +856,33 @@ class TestInstanceNotificationSample(
# 1. instance-suspend-end
# 2. instance-resume-start
# 3. instance-resume-end
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(4, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-suspend-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-suspend-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self._verify_notification(
'instance-resume-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-resume-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self.flags(reclaim_instance_interval=0)
@@ -899,32 +898,32 @@ class TestInstanceNotificationSample(
# 1. instance-pause-end
# 2. instance-unpause-start
# 3. instance-unpause-end
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(4, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-pause-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-pause-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self._verify_notification(
'instance-unpause-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-unpause-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
def _build_destination_payload(self):
cell1 = self.cell_mappings.get('cell1')
@@ -965,7 +964,7 @@ class TestInstanceNotificationSample(
self.admin_api.post_extra_spec(other_flavor_id, extra_specs)
# Ignore the create flavor notification
- fake_notifier.reset()
+ self.notifier.reset()
post = {
'resize': {
@@ -984,10 +983,10 @@ class TestInstanceNotificationSample(
'flavor.extra_specs': extra_specs['extra_specs'],
'requested_destination': self._build_destination_payload()})
- self.assertEqual(7, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(7, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
# ignore instance.exists
- fake_notifier.VERSIONED_NOTIFICATIONS.pop(0)
+ self.notifier.versioned_notifications.pop(0)
# This list needs to be in order.
expected_notifications = [
@@ -1004,30 +1003,30 @@ class TestInstanceNotificationSample(
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[idx])
+ actual=self.notifier.versioned_notifications[idx])
- fake_notifier.reset()
+ self.notifier.reset()
# the following is the revert server request
post = {'revertResize': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(server, 'ACTIVE')
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
# ignore instance.exists
- fake_notifier.VERSIONED_NOTIFICATIONS.pop(0)
+ self.notifier.versioned_notifications.pop(0)
self._verify_notification(
'instance-resize_revert-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-resize_revert-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
@mock.patch('nova.compute.manager.ComputeManager._prep_resize')
def test_resize_server_error_but_reschedule_was_success(
@@ -1058,7 +1057,7 @@ class TestInstanceNotificationSample(
'flavorRef': other_flavor_id
}
}
- fake_notifier.reset()
+ self.notifier.reset()
mock_prep_resize.side_effect = _build_resources
# NOTE(gibi): the first resize_instance call (from the API) should be
# unaffected so that we can reach _prep_resize at all. But the
@@ -1081,13 +1080,13 @@ class TestInstanceNotificationSample(
# 1: instance-resize_prep-start
# 2: instance-resize-error
# 3: instance-resize_prep-end
- self.assertLessEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertLessEqual(2, len(self.notifier.versioned_notifications),
'Unexpected number of notifications: %s' %
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.versioned_notifications)
# Note(gibi): There is also an instance.exists notification emitted
# during the rescheduling
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[2]['payload'][
+ tb = self.notifier.versioned_notifications[2]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("raise exception.FlavorDiskTooSmall()", tb)
@@ -1097,7 +1096,7 @@ class TestInstanceNotificationSample(
'uuid': server['id'],
'fault.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
@mock.patch('nova.compute.manager.ComputeManager._prep_resize')
def test_resize_server_error_and_reschedule_was_failed(
@@ -1132,7 +1131,7 @@ class TestInstanceNotificationSample(
'flavorRef': other_flavor_id
}
}
- fake_notifier.reset()
+ self.notifier.reset()
mock_prep_resize.side_effect = _build_resources
# NOTE(gibi): the first resize_instance call (from the API) should be
# unaffected so that we can reach _prep_resize at all. But the
@@ -1164,11 +1163,11 @@ class TestInstanceNotificationSample(
'flavor.flavorid': other_flavor_id,
'flavor.extra_specs': {},
'requested_destination': self._build_destination_payload()})
- self.assertEqual(5, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(5, len(self.notifier.versioned_notifications),
'Unexpected number of notifications: %s' %
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.versioned_notifications)
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[2]['payload'][
+ tb = self.notifier.versioned_notifications[2]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("raise exception.FlavorDiskTooSmall()", tb)
@@ -1178,29 +1177,29 @@ class TestInstanceNotificationSample(
'uuid': server['id'],
'fault.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
def _test_snapshot_server(self, server):
post = {'createImage': {'name': 'test-snap'}}
response = self.api.post_server_action(server['id'], post)
self._wait_for_notification('instance.snapshot.end')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-snapshot-start',
replacements={
'snapshot_image_id': response['image_id'],
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-snapshot-end',
replacements={
'snapshot_image_id': response['image_id'],
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def test_rebuild_server(self):
# NOTE(gabor_antal): Rebuild changes the image used by the instance,
@@ -1212,7 +1211,7 @@ class TestInstanceNotificationSample(
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
- fake_notifier.reset()
+ self.notifier.reset()
image_ref = 'a2459075-d96c-40d5-893e-577ff92e721c'
post = {
@@ -1252,22 +1251,22 @@ class TestInstanceNotificationSample(
# 4. instance.detach.end
# 5. instance.rebuild.end
# The compute/manager will detach every volume during rebuild
- self.assertEqual(6, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(6, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-rebuild_scheduled',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'trusted_image_certificates': None},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-rebuild-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'trusted_image_certificates': None},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-volume_detach-start',
replacements={
@@ -1276,7 +1275,7 @@ class TestInstanceNotificationSample(
'architecture': None,
'image_uuid': 'a2459075-d96c-40d5-893e-577ff92e721c',
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self._verify_notification(
'instance-volume_detach-end',
replacements={
@@ -1285,14 +1284,14 @@ class TestInstanceNotificationSample(
'architecture': None,
'image_uuid': 'a2459075-d96c-40d5-893e-577ff92e721c',
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-rebuild-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'trusted_image_certificates': None},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
def test_rebuild_server_with_trusted_cert(self):
# NOTE(gabor_antal): Rebuild changes the image used by the instance,
@@ -1306,7 +1305,7 @@ class TestInstanceNotificationSample(
'trusted_image_certificates': create_trusted_certs})
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
- fake_notifier.reset()
+ self.notifier.reset()
image_ref = 'a2459075-d96c-40d5-893e-577ff92e721c'
rebuild_trusted_certs = ['rebuild-cert-id-1', 'rebuild-cert-id-2']
@@ -1348,20 +1347,20 @@ class TestInstanceNotificationSample(
# 4. instance.detach.end
# 5. instance.rebuild.end
# The compute/manager will detach every volume during rebuild
- self.assertEqual(6, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(6, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-rebuild_scheduled',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-rebuild-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'instance-volume_detach-start',
replacements={
@@ -1370,7 +1369,7 @@ class TestInstanceNotificationSample(
'architecture': None,
'image_uuid': 'a2459075-d96c-40d5-893e-577ff92e721c',
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
self._verify_notification(
'instance-volume_detach-end',
replacements={
@@ -1379,13 +1378,13 @@ class TestInstanceNotificationSample(
'architecture': None,
'image_uuid': 'a2459075-d96c-40d5-893e-577ff92e721c',
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[4])
+ actual=self.notifier.versioned_notifications[4])
self._verify_notification(
'instance-rebuild-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
@mock.patch('nova.compute.manager.ComputeManager.'
'_do_rebuild_instance_with_claim')
@@ -1398,7 +1397,7 @@ class TestInstanceNotificationSample(
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
- fake_notifier.reset()
+ self.notifier.reset()
post = {
'rebuild': {
@@ -1411,7 +1410,7 @@ class TestInstanceNotificationSample(
self._wait_for_state_change(server, expected_status='ERROR')
notification = self._get_notifications('instance.rebuild.error')
self.assertEqual(1, len(notification),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.versioned_notifications)
tb = notification[0]['payload']['nova_object.data']['fault'][
'nova_object.data']['traceback']
@@ -1431,24 +1430,24 @@ class TestInstanceNotificationSample(
self.api.delete_server(server['id'])
self._wait_for_state_change(server, 'SOFT_DELETED')
# we don't want to test soft_delete here
- fake_notifier.reset()
+ self.notifier.reset()
self.api.post_server_action(server['id'], {'restore': {}})
self._wait_for_state_change(server, 'ACTIVE')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-restore-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-restore-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_reboot_server(self, server):
post = {'reboot': {'type': 'HARD'}}
@@ -1456,20 +1455,20 @@ class TestInstanceNotificationSample(
self._wait_for_notification('instance.reboot.start')
self._wait_for_notification('instance.reboot.end')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-reboot-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-reboot-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
@mock.patch('nova.virt.fake.SmallFakeDriver.reboot')
def _test_reboot_server_error(self, server, mock_reboot):
@@ -1480,10 +1479,10 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], post)
self._wait_for_notification('instance.reboot.start')
self._wait_for_notification('instance.reboot.error')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[1]['payload'][
+ tb = self.notifier.versioned_notifications[1]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("raise exception.UnsupportedVirtType", tb)
@@ -1492,14 +1491,14 @@ class TestInstanceNotificationSample(
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-reboot-error',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'fault.traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _detach_volume_from_server(self, server, volume_id):
self.api.delete_server_volume(server['id'], volume_id)
@@ -1524,21 +1523,21 @@ class TestInstanceNotificationSample(
# we have to wait for the volume_swap.end notification directly.
self._wait_for_notification('instance.volume_swap.end')
- self.assertEqual(7, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(7, len(self.notifier.versioned_notifications),
'Unexpected number of versioned notifications. '
- 'Got: %s' % fake_notifier.VERSIONED_NOTIFICATIONS)
+ 'Got: %s' % self.notifier.versioned_notifications)
self._verify_notification(
'instance-volume_swap-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
self._verify_notification(
'instance-volume_swap-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[6])
+ actual=self.notifier.versioned_notifications[6])
def _do_setup_server_and_error_flag(self):
server = self._boot_a_server(
@@ -1565,9 +1564,9 @@ class TestInstanceNotificationSample(
# 5. instance-volume_swap-start
# 6. instance-volume_swap-error
# 7. compute.exception
- self.assertLessEqual(7, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertLessEqual(7, len(self.notifier.versioned_notifications),
'Unexpected number of versioned notifications. '
- 'Got: %s' % fake_notifier.VERSIONED_NOTIFICATIONS)
+ 'Got: %s' % self.notifier.versioned_notifications)
block_devices = [{
"nova_object.data": {
"boot_index": None,
@@ -1588,12 +1587,12 @@ class TestInstanceNotificationSample(
'block_devices': block_devices,
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[5])
+ actual=self.notifier.versioned_notifications[5])
- tb1 = fake_notifier.VERSIONED_NOTIFICATIONS[6]['payload'][
+ tb1 = self.notifier.versioned_notifications[6]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("_swap_volume", tb1)
- tb2 = fake_notifier.VERSIONED_NOTIFICATIONS[7]['payload'][
+ tb2 = self.notifier.versioned_notifications[7]['payload'][
'nova_object.data']['traceback']
self.assertIn("_swap_volume", tb2)
@@ -1604,7 +1603,7 @@ class TestInstanceNotificationSample(
'block_devices': block_devices,
'uuid': server['id'],
'fault.traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[6])
+ actual=self.notifier.versioned_notifications[6])
def test_resize_confirm_server(self):
server = self._boot_a_server(
@@ -1616,26 +1615,26 @@ class TestInstanceNotificationSample(
post = {'resize': {'flavorRef': '2'}}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(server, 'VERIFY_RESIZE')
- fake_notifier.reset()
+ self.notifier.reset()
post = {'confirmResize': None}
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(server, 'ACTIVE')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-resize_confirm-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-resize_confirm-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_trigger_crash_dump(self, server):
post = {'trigger_crash_dump': None}
@@ -1643,60 +1642,60 @@ class TestInstanceNotificationSample(
self._wait_for_notification('instance.trigger_crash_dump.end')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-trigger_crash_dump-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-trigger_crash_dump-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_volume_detach_attach_server(self, server):
self._detach_volume_from_server(server, self.cinder.SWAP_OLD_VOL)
# 0. volume_detach-start
# 1. volume_detach-end
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-volume_detach-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-volume_detach-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
- fake_notifier.reset()
+ self.notifier.reset()
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
# 0. volume_attach-start
# 1. volume_attach-end
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-volume_attach-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-volume_attach-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_rescue_unrescue_server(self, server):
# Both "rescue" and "unrescue" notification asserts are made here
@@ -1712,21 +1711,21 @@ class TestInstanceNotificationSample(
# 0. instance.rescue.start
# 1. instance.exists
# 2. instance.rescue.end
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-rescue-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-rescue-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
- fake_notifier.reset()
+ actual=self.notifier.versioned_notifications[2])
+ self.notifier.reset()
# unrescue notification asserts
post = {
@@ -1735,40 +1734,40 @@ class TestInstanceNotificationSample(
self.api.post_server_action(server['id'], post)
self._wait_for_state_change(server, 'ACTIVE')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-unrescue-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-unrescue-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_soft_delete_server(self, server):
self.flags(reclaim_instance_interval=30)
self.api.delete_server(server['id'])
self._wait_for_state_change(server, 'SOFT_DELETED')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-soft_delete-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-soft_delete-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self.flags(reclaim_instance_interval=0)
# Leave instance in normal, active state
self.api.post_server_action(server['id'], {'restore': {}})
@@ -1809,7 +1808,7 @@ class TestInstanceNotificationSample(
# 2. compute.exception
# We only rely on the first 2 notifications, in this case we don't
# care about the exception notification.
- self.assertLessEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertLessEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'instance-volume_attach-start',
replacements={
@@ -1817,9 +1816,9 @@ class TestInstanceNotificationSample(
'block_devices': block_devices,
'volume_id': self.cinder.SWAP_NEW_VOL,
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[1]['payload'][
+ tb = self.notifier.versioned_notifications[1]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("CinderConnectionFailed:", tb)
@@ -1831,7 +1830,7 @@ class TestInstanceNotificationSample(
'volume_id': self.cinder.SWAP_NEW_VOL,
'uuid': server['id'],
'fault.traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
@mock.patch('nova.volume.cinder.API.attachment_update')
def _test_attach_volume_error(self, server, mock_attach):
@@ -1845,43 +1844,43 @@ class TestInstanceNotificationSample(
}
self.api.attach_interface(server['id'], post)
self._wait_for_notification('instance.interface_attach.end')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-interface_attach-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-interface_attach-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
- fake_notifier.reset()
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.notifier.reset()
+ self.assertEqual(0, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self.api.detach_interface(
server['id'],
fixtures.NeutronFixture.port_2['id'])
self._wait_for_notification('instance.interface_detach.end')
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-interface_detach-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-interface_detach-end',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
@mock.patch('nova.virt.fake.SmallFakeDriver.attach_interface')
def _test_interface_attach_error(self, server, mock_driver):
@@ -1900,15 +1899,15 @@ class TestInstanceNotificationSample(
# 0. instance.interface_attach.start
# 1. instance.interface_attach.error
# 2. compute.exception
- self.assertLessEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertLessEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'instance-interface_attach-start',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
- tb = fake_notifier.VERSIONED_NOTIFICATIONS[1]['payload'][
+ tb = self.notifier.versioned_notifications[1]['payload'][
'nova_object.data']['fault']['nova_object.data']['traceback']
self.assertIn("raise exception.InterfaceAttachFailed", tb)
@@ -1918,7 +1917,7 @@ class TestInstanceNotificationSample(
'reservation_id': server['reservation_id'],
'uuid': server['id'],
'fault.traceback': self.ANY},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_lock_unlock_instance(self, server):
self.api.post_server_action(server['id'], {'lock': {}})
@@ -1929,20 +1928,20 @@ class TestInstanceNotificationSample(
# 0. instance-lock
# 1. instance-unlock
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-lock',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-unlock',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def _test_lock_unlock_instance_with_reason(self, server):
self.api.post_server_action(
@@ -1954,17 +1953,17 @@ class TestInstanceNotificationSample(
# 0. instance-lock
# 1. instance-unlock
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
- fake_notifier.VERSIONED_NOTIFICATIONS)
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
+ self.notifier.versioned_notifications)
self._verify_notification(
'instance-lock-with-reason',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'instance-unlock',
replacements={
'reservation_id': server['reservation_id'],
'uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
diff --git a/nova/tests/functional/notification_sample_tests/test_keypair.py b/nova/tests/functional/notification_sample_tests/test_keypair.py
index 917889919b..b2481f1b2a 100644
--- a/nova/tests/functional/notification_sample_tests/test_keypair.py
+++ b/nova/tests/functional/notification_sample_tests/test_keypair.py
@@ -11,7 +11,6 @@
# under the License.
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestKeypairNotificationSample(
@@ -26,35 +25,35 @@ class TestKeypairNotificationSample(
}}
keypair = self.api.post_keypair(keypair_req)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'keypair-create-start',
replacements={},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'keypair-create-end',
replacements={
"fingerprint": keypair['fingerprint'],
"public_key": keypair['public_key']
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
self.api.delete_keypair(keypair['name'])
- self.assertEqual(4, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(4, len(self.notifier.versioned_notifications))
self._verify_notification(
'keypair-delete-start',
replacements={
"fingerprint": keypair['fingerprint'],
"public_key": keypair['public_key']
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[2])
+ actual=self.notifier.versioned_notifications[2])
self._verify_notification(
'keypair-delete-end',
replacements={
"fingerprint": keypair['fingerprint'],
"public_key": keypair['public_key']
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[3])
+ actual=self.notifier.versioned_notifications[3])
def test_keypair_import(self):
pub_key = ('ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDx8nkQv/zgGg'
@@ -71,10 +70,10 @@ class TestKeypairNotificationSample(
self.api.post_keypair(keypair_req)
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(2, len(self.notifier.versioned_notifications))
self._verify_notification(
'keypair-import-start',
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
self._verify_notification(
'keypair-import-end',
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
diff --git a/nova/tests/functional/notification_sample_tests/test_libvirt.py b/nova/tests/functional/notification_sample_tests/test_libvirt.py
index fe9ec33f9b..8106edd44a 100644
--- a/nova/tests/functional/notification_sample_tests/test_libvirt.py
+++ b/nova/tests/functional/notification_sample_tests/test_libvirt.py
@@ -21,7 +21,6 @@ from nova.tests import fixtures as nova_fixtures
from nova.tests.fixtures import libvirt as fakelibvirt
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
from nova.virt.libvirt import host
@@ -45,7 +44,7 @@ class TestLibvirtErrorNotificationSample(
self.assertRaises(exception.HypervisorUnavailable,
self.restart_compute_service, self.compute)
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'libvirt-connect-error',
replacements={
@@ -54,4 +53,4 @@ class TestLibvirtErrorNotificationSample(
'reason.module_name': self.ANY,
'reason.traceback': self.ANY
},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
diff --git a/nova/tests/functional/notification_sample_tests/test_metrics.py b/nova/tests/functional/notification_sample_tests/test_metrics.py
index 7824feb76e..04487f7d2d 100644
--- a/nova/tests/functional/notification_sample_tests/test_metrics.py
+++ b/nova/tests/functional/notification_sample_tests/test_metrics.py
@@ -16,7 +16,6 @@ import nova.conf
from nova import context
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
CONF = nova.conf.CONF
@@ -35,8 +34,8 @@ class TestMetricsNotificationSample(
self.compute.manager.update_available_resource(
context.get_admin_context())
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'metrics-update',
replacements={'host_ip': CONF.my_ip},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
diff --git a/nova/tests/functional/notification_sample_tests/test_server_group.py b/nova/tests/functional/notification_sample_tests/test_server_group.py
index d1ede9d5ed..b9a57b1ee3 100644
--- a/nova/tests/functional/notification_sample_tests/test_server_group.py
+++ b/nova/tests/functional/notification_sample_tests/test_server_group.py
@@ -12,7 +12,6 @@
from nova.tests import fixtures
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestServerGroupNotificationSample(
@@ -31,20 +30,20 @@ class TestServerGroupNotificationSample(
}
group = self.api.post_server_groups(group_req)
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'server_group-create',
replacements={'uuid': group['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
- fake_notifier.reset()
+ self.notifier.reset()
self.api.delete_server_group(group['id'])
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'server_group-delete',
replacements={'uuid': group['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
def test_server_group_add_member(self):
group_req = {
@@ -53,7 +52,7 @@ class TestServerGroupNotificationSample(
"rules": {"max_server_per_host": 3}
}
group = self.api.post_server_groups(group_req)
- fake_notifier.reset()
+ self.notifier.reset()
server = self._boot_a_server(
extra_params={'networks': [{'port': self.neutron.port_1['id']}]},
@@ -66,9 +65,9 @@ class TestServerGroupNotificationSample(
# 4: instance.create.end
# 5: instance.update
# (Due to adding server tags in the '_boot_a_server' method.)
- self.assertEqual(6, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(6, len(self.notifier.versioned_notifications))
self._verify_notification(
'server_group-add_member',
replacements={'uuid': group['id'],
'members': [server['id']]},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
diff --git a/nova/tests/functional/notification_sample_tests/test_service.py b/nova/tests/functional/notification_sample_tests/test_service.py
index 3005a69fdb..057c6e8696 100644
--- a/nova/tests/functional/notification_sample_tests/test_service.py
+++ b/nova/tests/functional/notification_sample_tests/test_service.py
@@ -20,7 +20,6 @@ from nova.tests import fixtures
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
from nova.tests.unit.api.openstack.compute import test_services
-from nova.tests.unit import fake_notifier
class TestServiceNotificationBase(
@@ -167,4 +166,4 @@ class TestServiceNotificationSample(TestServiceNotificationBase):
self._verify_notification(
'service-delete',
replacements={'uuid': compute2_service_id},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
diff --git a/nova/tests/functional/notification_sample_tests/test_volume.py b/nova/tests/functional/notification_sample_tests/test_volume.py
index a2bf27a29a..5a86042a32 100644
--- a/nova/tests/functional/notification_sample_tests/test_volume.py
+++ b/nova/tests/functional/notification_sample_tests/test_volume.py
@@ -16,7 +16,6 @@ from nova import context
from nova.tests import fixtures
from nova.tests.functional.notification_sample_tests \
import notification_sample_base
-from nova.tests.unit import fake_notifier
class TestVolumeUsageNotificationSample(
@@ -34,7 +33,7 @@ class TestVolumeUsageNotificationSample(
server = self._boot_a_server(
extra_params={'networks': [{'port': self.neutron.port_1['id']}]})
self._attach_volume_to_server(server, self.cinder.SWAP_OLD_VOL)
- fake_notifier.reset()
+ self.notifier.reset()
return server
@@ -47,19 +46,19 @@ class TestVolumeUsageNotificationSample(
# 0. volume_detach-start
# 1. volume.usage
# 2. volume_detach-end
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(3, len(self.notifier.versioned_notifications))
self._verify_notification(
'volume-usage',
replacements={'instance_uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[1])
+ actual=self.notifier.versioned_notifications[1])
def test_instance_poll_volume_usage(self):
server = self._setup_server_with_volume_attached()
self.compute.manager._poll_volume_usage(context.get_admin_context())
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self._verify_notification(
'volume-usage',
replacements={'instance_uuid': server['id']},
- actual=fake_notifier.VERSIONED_NOTIFICATIONS[0])
+ actual=self.notifier.versioned_notifications[0])
diff --git a/nova/tests/functional/regressions/test_bug_1713783.py b/nova/tests/functional/regressions/test_bug_1713783.py
index 69a1671db5..245a468b87 100644
--- a/nova/tests/functional/regressions/test_bug_1713783.py
+++ b/nova/tests/functional/regressions/test_bug_1713783.py
@@ -91,8 +91,8 @@ class FailedEvacuateStateTests(test.TestCase,
host=self.hostname, binary='nova-compute')[0]['id']
self.api.put_service(compute_id, {'forced_down': 'true'})
- fake_notifier.stub_notifier(self)
- fake_notifier.reset()
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
# Initiate evacuation
self._evacuate_server(
diff --git a/nova/tests/functional/regressions/test_bug_1735407.py b/nova/tests/functional/regressions/test_bug_1735407.py
index e53dba9321..85f65e273a 100644
--- a/nova/tests/functional/regressions/test_bug_1735407.py
+++ b/nova/tests/functional/regressions/test_bug_1735407.py
@@ -16,7 +16,6 @@ from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit import fake_network
-from nova.tests.unit import fake_notifier
class TestParallelEvacuationWithServerGroup(
@@ -47,8 +46,8 @@ class TestParallelEvacuationWithServerGroup(
# 2.14 is needed for evacuate without onSharedStorage flag
self.api.microversion = '2.14'
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
# the image fake backend needed for image discovery
self.useFixture(nova_fixtures.GlanceFixture(self))
@@ -77,7 +76,7 @@ class TestParallelEvacuationWithServerGroup(
# validation
if instance.host == 'host1':
# wait for the other instance rebuild to start
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.rebuild.start', n_events=1)
original_rebuild(self_, context, instance, *args, **kwargs)
@@ -127,7 +126,7 @@ class TestParallelEvacuationWithServerGroup(
# NOTE(mdbooth): We only get 1 rebuild.start notification here because
# we validate server group policy (and therefore fail) before emitting
# rebuild.start.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.rebuild.start', n_events=1)
server1 = self._wait_for_server_parameter(
server1, {'OS-EXT-STS:task_state': None})
diff --git a/nova/tests/functional/regressions/test_bug_1764883.py b/nova/tests/functional/regressions/test_bug_1764883.py
index 6d07b7c53e..aa86770584 100644
--- a/nova/tests/functional/regressions/test_bug_1764883.py
+++ b/nova/tests/functional/regressions/test_bug_1764883.py
@@ -16,7 +16,6 @@ from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
from nova.tests.unit import fake_network
-from nova.tests.unit import fake_notifier
class TestEvacuationWithSourceReturningDuringRebuild(
@@ -63,8 +62,6 @@ class TestEvacuationWithSourceReturningDuringRebuild(
self.image_id = self.api.get_images()[0]['id']
self.flavor_id = self.api.get_flavors()[0]['id']
- self.addCleanup(fake_notifier.reset)
-
# Stub out rebuild with a slower method allowing the src compute to be
# restarted once the migration hits pre-migrating after claiming
# resources on the dest.
diff --git a/nova/tests/functional/regressions/test_bug_1781286.py b/nova/tests/functional/regressions/test_bug_1781286.py
index eeed95576e..a5d71755cd 100644
--- a/nova/tests/functional/regressions/test_bug_1781286.py
+++ b/nova/tests/functional/regressions/test_bug_1781286.py
@@ -20,7 +20,6 @@ from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class RescheduleBuildAvailabilityZoneUpCall(
@@ -51,8 +50,8 @@ class RescheduleBuildAvailabilityZoneUpCall(
self.start_service('compute', host='host1')
self.start_service('compute', host='host2')
# Listen for notifications.
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
def test_server_create_reschedule_blocked_az_up_call(self):
self.flags(default_availability_zone='us-central')
@@ -80,7 +79,7 @@ class RescheduleBuildAvailabilityZoneUpCall(
# Because we poisoned AggregateList.get_by_host after hitting the
# compute service we have to wait for the notification that the build
# is complete and then stop the mock so we can use the API again.
- fake_notifier.wait_for_versioned_notifications('instance.create.end')
+ self.notifier.wait_for_versioned_notifications('instance.create.end')
# Note that we use stopall here because we actually called
# build_and_run_instance twice so we have more than one instance of
# the mock that needs to be stopped.
@@ -116,8 +115,8 @@ class RescheduleMigrateAvailabilityZoneUpCall(
self.start_service('compute', host='host2')
self.start_service('compute', host='host3')
# Listen for notifications.
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
def test_migrate_reschedule_blocked_az_up_call(self):
self.flags(default_availability_zone='us-central')
@@ -153,7 +152,7 @@ class RescheduleMigrateAvailabilityZoneUpCall(
# Because we poisoned AggregateList.get_by_host after hitting the
# compute service we have to wait for the notification that the resize
# is complete and then stop the mock so we can use the API again.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_finish.end')
# Note that we use stopall here because we actually called _prep_resize
# twice so we have more than one instance of the mock that needs to be
diff --git a/nova/tests/functional/regressions/test_bug_1806515.py b/nova/tests/functional/regressions/test_bug_1806515.py
index 6d2675af27..cd57eb9ad2 100644
--- a/nova/tests/functional/regressions/test_bug_1806515.py
+++ b/nova/tests/functional/regressions/test_bug_1806515.py
@@ -13,7 +13,6 @@
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class ShowErrorServerWithTags(test.TestCase,
@@ -41,8 +40,6 @@ class ShowErrorServerWithTags(test.TestCase,
self.api.microversion = 'latest'
- self.addCleanup(fake_notifier.reset)
-
def _create_error_server(self):
server = self.api.post_server({
'server': {
diff --git a/nova/tests/functional/regressions/test_bug_1835822.py b/nova/tests/functional/regressions/test_bug_1835822.py
index 751f060647..5736e9ea3d 100644
--- a/nova/tests/functional/regressions/test_bug_1835822.py
+++ b/nova/tests/functional/regressions/test_bug_1835822.py
@@ -14,7 +14,6 @@ from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class RegressionTest1835822(
@@ -39,8 +38,8 @@ class RegressionTest1835822(
self.image_ref_0 = images[0]['id']
self.image_ref_1 = images[1]['id']
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
def _create_active_server(self, server_args=None):
basic_server = {
diff --git a/nova/tests/functional/regressions/test_bug_1843090.py b/nova/tests/functional/regressions/test_bug_1843090.py
index e9a389c5da..8ccb83192c 100644
--- a/nova/tests/functional/regressions/test_bug_1843090.py
+++ b/nova/tests/functional/regressions/test_bug_1843090.py
@@ -15,7 +15,6 @@ import nova.compute
from nova import exception
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class PinnedComputeRpcTests(integrated_helpers.ProviderUsageBaseTestCase):
@@ -28,8 +27,6 @@ class PinnedComputeRpcTests(integrated_helpers.ProviderUsageBaseTestCase):
self.useFixture(nova_fixtures.HostNameWeigherFixture())
super(PinnedComputeRpcTests, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
self.compute1 = self._start_compute(host='host1')
self.compute2 = self._start_compute(host='host2')
diff --git a/nova/tests/functional/regressions/test_bug_1843708.py b/nova/tests/functional/regressions/test_bug_1843708.py
index d04dbb1cda..2ae725a5eb 100644
--- a/nova/tests/functional/regressions/test_bug_1843708.py
+++ b/nova/tests/functional/regressions/test_bug_1843708.py
@@ -15,7 +15,6 @@
from nova import context
from nova import objects
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class RebuildWithKeypairTestCase(integrated_helpers._IntegratedTestBase):
@@ -59,7 +58,7 @@ class RebuildWithKeypairTestCase(integrated_helpers._IntegratedTestBase):
},
}
self.api.api_post('servers/%s/action' % server['id'], body)
- fake_notifier.wait_for_versioned_notifications('instance.rebuild.end')
+ self.notifier.wait_for_versioned_notifications('instance.rebuild.end')
self._wait_for_state_change(server, 'ACTIVE')
# Check keypairs changed
diff --git a/nova/tests/functional/regressions/test_bug_1862633.py b/nova/tests/functional/regressions/test_bug_1862633.py
index 90de776285..5cfcc75ab2 100644
--- a/nova/tests/functional/regressions/test_bug_1862633.py
+++ b/nova/tests/functional/regressions/test_bug_1862633.py
@@ -16,7 +16,6 @@ from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import fixtures as func_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class UnshelveNeutronErrorTest(
@@ -34,8 +33,8 @@ class UnshelveNeutronErrorTest(
self.api = self.useFixture(nova_fixtures.OSAPIFixture(
api_version='v2.1')).admin_api
self.api.microversion = 'latest'
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
self.start_service('conductor')
self.start_service('scheduler')
@@ -73,7 +72,7 @@ class UnshelveNeutronErrorTest(
reason='test')
req = {'unshelve': None}
self.api.post_server_action(server['id'], req)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.unshelve.start')
self._wait_for_server_parameter(
server,
diff --git a/nova/tests/functional/test_cold_migrate.py b/nova/tests/functional/test_cold_migrate.py
index 5b6aa5bacc..e07820ba2a 100644
--- a/nova/tests/functional/test_cold_migrate.py
+++ b/nova/tests/functional/test_cold_migrate.py
@@ -17,7 +17,6 @@ from nova import context as nova_context
from nova import objects
from nova import test
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class ColdMigrationDisallowSameHost(
@@ -34,7 +33,7 @@ class ColdMigrationDisallowSameHost(
self._start_compute('host1')
def _wait_for_migrate_no_valid_host(self, error='NoValidHost'):
- event = fake_notifier.wait_for_versioned_notifications(
+ event = self.notifier.wait_for_versioned_notifications(
'compute_task.migrate_server.error')[0]
self.assertEqual(error,
event['payload']['nova_object.data']['reason'][
diff --git a/nova/tests/functional/test_cross_cell_migrate.py b/nova/tests/functional/test_cross_cell_migrate.py
index 0b9b94dbc3..eccce774d9 100644
--- a/nova/tests/functional/test_cross_cell_migrate.py
+++ b/nova/tests/functional/test_cross_cell_migrate.py
@@ -31,7 +31,6 @@ from nova.scheduler import weights
from nova import test
from nova.tests import fixtures as nova_fixtures
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
from nova import utils
CONF = conf.CONF
@@ -421,7 +420,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
body = {'volumeAttachment': {'volumeId': volume_id}}
self.api.api_post(
'/servers/%s/os-volume_attachments' % server_id, body)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.volume_attach.end')
def _detach_volume_from_server(self, server_id, volume_id):
@@ -430,7 +429,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
"""
self.api.api_delete(
'/servers/%s/os-volume_attachments/%s' % (server_id, volume_id))
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.volume_detach.end')
def assert_volume_is_attached(self, server_id, volume_id):
@@ -453,13 +452,13 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
# We should have gotten only two notifications:
# 1. instance.resize_confirm.start
# 2. instance.resize_confirm.end
- self.assertEqual(2, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(2, len(self.notifier.versioned_notifications),
'Unexpected number of versioned notifications for '
'cross-cell resize confirm: %s' %
- fake_notifier.VERSIONED_NOTIFICATIONS)
- start = fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type']
+ self.notifier.versioned_notifications)
+ start = self.notifier.versioned_notifications[0]['event_type']
self.assertEqual('instance.resize_confirm.start', start)
- end = fake_notifier.VERSIONED_NOTIFICATIONS[1]['event_type']
+ end = self.notifier.versioned_notifications[1]['event_type']
self.assertEqual('instance.resize_confirm.end', end)
def delete_server_and_assert_cleanup(self, server,
@@ -538,7 +537,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self._attach_volume_to_server(server['id'], uuids.fake_volume_id)
# Reset the fake notifier so we only check confirmation notifications.
- fake_notifier.reset()
+ self.notifier.reset()
# Confirm the resize and check all the things. The instance and its
# related records should be gone from the source cell database; the
@@ -634,15 +633,15 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
# 1. instance.resize_revert.start (from target compute host)
# 2. instance.exists (from target compute host)
# 3. instance.resize_revert.end (from source compute host)
- self.assertEqual(3, len(fake_notifier.VERSIONED_NOTIFICATIONS),
+ self.assertEqual(3, len(self.notifier.versioned_notifications),
'Unexpected number of versioned notifications for '
'cross-cell resize revert: %s' %
- fake_notifier.VERSIONED_NOTIFICATIONS)
- start = fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type']
+ self.notifier.versioned_notifications)
+ start = self.notifier.versioned_notifications[0]['event_type']
self.assertEqual('instance.resize_revert.start', start)
- exists = fake_notifier.VERSIONED_NOTIFICATIONS[1]['event_type']
+ exists = self.notifier.versioned_notifications[1]['event_type']
self.assertEqual('instance.exists', exists)
- end = fake_notifier.VERSIONED_NOTIFICATIONS[2]['event_type']
+ end = self.notifier.versioned_notifications[2]['event_type']
self.assertEqual('instance.resize_revert.end', end)
def assert_resize_revert_actions(self, server, source_host, dest_host):
@@ -703,7 +702,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self._attach_volume_to_server(server['id'], uuids.fake_volume_id)
# Reset the fake notifier so we only check revert notifications.
- fake_notifier.reset()
+ self.notifier.reset()
# Revert the resize. The server should be re-spawned in the source
# cell and removed from the target cell. The allocations
@@ -718,7 +717,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
# instance.resize_revert.end notification because the migration.status
# is changed to "reverted" *after* the instance status is changed to
# ACTIVE.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
migrations = self.api.api_get(
'/os-migrations?instance_uuid=%s' % server['id']
@@ -799,7 +798,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self.api.post_server_action(server['id'], {'revertResize': None})
server = self._wait_for_state_change(server, 'ACTIVE')
self._wait_for_migration_status(server, ['reverted'])
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
self.assert_volume_is_detached(server['id'], uuids.fake_volume_id)
# Delete the server and make sure we did not leak anything.
@@ -980,7 +979,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
# _poll_unconfirmed_resizes periodic task and run it on the target
# compute service.
# Reset the fake notifier so we only check confirmation notifications.
- fake_notifier.reset()
+ self.notifier.reset()
self.flags(resize_confirm_window=1)
# Stub timeutils so the DB API query finds the unconfirmed migration.
future = timeutils.utcnow() + datetime.timedelta(hours=1)
@@ -1071,7 +1070,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
self.assertEqual(4, server['OS-EXT-STS:power_state'],
"Unexpected power state after revertResize.")
self._wait_for_migration_status(server, ['reverted'])
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_revert.end')
# Now try cold-migrating to cell2 to make sure there is no
@@ -1146,7 +1145,7 @@ class TestMultiCellMigrate(integrated_helpers.ProviderUsageBaseTestCase):
# to wait for something which happens after that, which is the
# ComputeTaskManager._cold_migrate method sending the
# compute_task.migrate_server.error event.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'compute_task.migrate_server.error')
mig_uuid = self.get_migration_uuid_for_instance(server['id'])
mig_allocs = self._get_allocations_by_server_uuid(mig_uuid)
diff --git a/nova/tests/functional/test_server_external_events.py b/nova/tests/functional/test_server_external_events.py
index 482bc8ffac..c8b3827ece 100644
--- a/nova/tests/functional/test_server_external_events.py
+++ b/nova/tests/functional/test_server_external_events.py
@@ -14,7 +14,6 @@ from nova.compute import instance_actions
from nova.compute import power_state
from nova.compute import vm_states
from nova.tests.functional import integrated_helpers
-from nova.tests.unit import fake_notifier
class ServerExternalEventsTestV276(
@@ -64,9 +63,9 @@ class ServerExternalEventsTestV276(
self.assertIn('compute_power_update', events_by_name)
self.assertEqual('Success', detail['events'][0]['result'])
# Test if notifications were emitted.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.power_off.start')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.power_off.end')
# Checking POWER_ON
@@ -90,7 +89,7 @@ class ServerExternalEventsTestV276(
self.assertIn('compute_power_update', events_by_name)
self.assertEqual('Success', detail['events'][0]['result'])
# Test if notifications were emitted.
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.power_on.start')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.power_on.end')
diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py
index 710597add3..2cba010af7 100644
--- a/nova/tests/functional/test_servers.py
+++ b/nova/tests/functional/test_servers.py
@@ -49,7 +49,6 @@ from nova.tests.functional.api import client
from nova.tests.functional import integrated_helpers
from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_block_device
-from nova.tests.unit import fake_notifier
from nova.tests.unit import fake_requests
from nova.tests.unit.objects import test_instance_info_cache
from nova import utils as nova_utils
@@ -1629,8 +1628,6 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase):
def setUp(self):
super(ServerMovingTests, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
self.compute1 = self._start_compute(host='host1')
self.compute2 = self._start_compute(host='host2')
@@ -2036,7 +2033,7 @@ class ServerMovingTests(integrated_helpers.ProviderUsageBaseTestCase):
server, expected_state='ERROR', expected_host=source_hostname,
expected_migration_status='error')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'compute_task.rebuild_server.error')
self._run_periodics()
@@ -3999,11 +3996,9 @@ class VolumeBackedServerTest(integrated_helpers.ProviderUsageBaseTestCase):
# Now shelve and unshelve the server to make sure root_gb DISK_GB
# isn't reported for allocations after we unshelve the server.
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
self.api.post_server_action(server['id'], {'shelve': None})
self._wait_for_state_change(server, 'SHELVED_OFFLOADED')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.shelve_offload.end')
# The server should not have any allocations since it's not currently
# hosted on any compute service.
@@ -4783,7 +4778,7 @@ class ConsumerGenerationConflictTest(
(migrations[0]['uuid'], server['id']),
self.stdlog.logger.output)
self._delete_server(server)
- fake_notifier.wait_for_versioned_notifications('instance.delete.end')
+ self.notifier.wait_for_versioned_notifications('instance.delete.end')
allocations = self._get_allocations_by_server_uuid(
migrations[0]['uuid'])
@@ -4831,7 +4826,7 @@ class ConsumerGenerationConflictTest(
(migrations[0]['uuid'], server['id']),
self.stdlog.logger.output)
self._delete_server(server)
- fake_notifier.wait_for_versioned_notifications('instance.delete.end')
+ self.notifier.wait_for_versioned_notifications('instance.delete.end')
allocations = self._get_allocations_by_server_uuid(
migrations[0]['uuid'])
@@ -4882,7 +4877,7 @@ class ConsumerGenerationConflictTest(
(migrations[0]['uuid'], server['id']),
self.stdlog.logger.output)
self._delete_server(server)
- fake_notifier.wait_for_versioned_notifications('instance.delete.end')
+ self.notifier.wait_for_versioned_notifications('instance.delete.end')
allocations = self._get_allocations_by_server_uuid(
migrations[0]['uuid'])
@@ -4947,9 +4942,6 @@ class ConsumerGenerationConflictTest(
server = self._boot_and_check_allocations(
self.flavor, source_hostname)
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
-
orig_put = adapter.Adapter.put
rsp = fake_requests.FakeResponse(
@@ -4991,7 +4983,7 @@ class ConsumerGenerationConflictTest(
{'OS-EXT-SRV-ATTR:host': dest_hostname,
'status': 'ERROR'})
self._wait_for_migration_status(server, ['error'])
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.live_migration_post.end')
# 1 claim on destination, 1 normal delete on dest that fails,
@@ -5018,7 +5010,7 @@ class ConsumerGenerationConflictTest(
self.stdlog.logger.output)
self._delete_server(server)
- fake_notifier.wait_for_versioned_notifications('instance.delete.end')
+ self.notifier.wait_for_versioned_notifications('instance.delete.end')
self.assertFlavorMatchesAllocation(self.flavor, migration_uuid,
source_rp_uuid)
@@ -6462,7 +6454,7 @@ class PortResourceRequestBasedSchedulingTest(
self.api.detach_interface(
server['id'], self.neutron.port_with_resource_request['id'])
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.interface_detach.end')
updated_port = self.neutron.show_port(
@@ -7018,9 +7010,9 @@ class ServerMoveWithPortResourceRequestTest(
self._wait_for_action_fail_completion(
server, instance_actions.MIGRATE, 'compute_prep_resize')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.resize_prep.end')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'compute.exception')
migration_uuid = self.get_migration_uuid_for_instance(server['id'])
@@ -7275,9 +7267,9 @@ class ServerMoveWithPortResourceRequestTest(
self._wait_for_action_fail_completion(
server, instance_actions.EVACUATE, 'compute_rebuild_instance')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.rebuild.error')
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'compute.exception')
# and the instance allocates from the source host
@@ -7562,9 +7554,9 @@ class ServerMoveWithPortResourceRequestTest(
# Unshelve fails on host2 due to
# update_pci_request_spec_with_allocated_interface_name fails so the
# instance goes back to shelve offloaded state
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.unshelve.start')
- error_notification = fake_notifier.wait_for_versioned_notifications(
+ error_notification = self.notifier.wait_for_versioned_notifications(
'compute.exception')[0]
self.assertEqual(
'UnexpectedResourceProviderNameForPCIRequest',
@@ -7610,7 +7602,7 @@ class ServerMoveWithPortResourceRequestTest(
reason='test')
req = {'unshelve': None}
self.api.post_server_action(server['id'], req)
- fake_notifier.wait_for_versioned_notifications(
+ self.notifier.wait_for_versioned_notifications(
'instance.unshelve.start')
self._wait_for_server_parameter(
server,
@@ -8188,7 +8180,7 @@ class AcceleratorServerOpsTest(AcceleratorServerBase):
{'rebuild': {
'imageRef': rebuild_image_ref,
'OS-DCF:diskConfig': 'AUTO'}})
- fake_notifier.wait_for_versioned_notifications('instance.rebuild.end')
+ self.notifier.wait_for_versioned_notifications('instance.rebuild.end')
self._wait_for_state_change(self.server, 'ACTIVE')
self._check_allocations_usage(self.server)
diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py
index 779a4b7b77..e2924d6b31 100644
--- a/nova/tests/unit/compute/test_compute.py
+++ b/nova/tests/unit/compute/test_compute.py
@@ -149,8 +149,7 @@ class BaseTestCase(test.TestCase):
def setUp(self):
super(BaseTestCase, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.useFixture(fixtures.NotificationFixture(self))
self.compute = compute_manager.ComputeManager()
# NOTE(gibi): this is a hack to make the fake virt driver use the nodes
diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py
index ba8c56f021..d27094b2b2 100644
--- a/nova/tests/unit/compute/test_compute_mgr.py
+++ b/nova/tests/unit/compute/test_compute_mgr.py
@@ -8328,8 +8328,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
def setUp(self):
super(ComputeManagerMigrationTestCase, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(fixtures.NotificationFixture(self))
self.flags(compute_driver='fake.SameHostColdMigrateDriver')
self.compute = manager.ComputeManager()
self.context = context.RequestContext(fakes.FAKE_USER_ID,
@@ -10997,10 +10996,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
# There would really be three notifications but because we mocked out
# _send_prep_resize_notifications there is just the one error
# notification from the wrap_exception decorator.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
@mock.patch('nova.scheduler.client.report.SchedulerReportClient.'
'get_allocs_for_consumer')
@@ -11046,10 +11045,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
# There would really be three notifications but because we mocked out
# _send_prep_resize_notifications there is just the one error
# notification from the wrap_exception decorator.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
def test_snapshot_for_resize(self):
"""Happy path test for _snapshot_for_resize."""
@@ -11237,10 +11236,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
add_fault.assert_called_once_with(
self.context, self.instance, wrapped_exc, mock.ANY)
# Assert wrap_exception is called.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
# Assert errors_out_migration is called.
self.assertEqual('error', self.migration.status)
self.migration.save.assert_called_once_with()
@@ -11272,10 +11271,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
add_fault.assert_called_once_with(
self.context, self.instance, ex, mock.ANY)
# Assert wrap_exception is called.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
# Assert errors_out_migration is called.
self.assertEqual('error', self.migration.status)
self.migration.save.assert_called_once_with()
@@ -11613,10 +11612,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
self.assertEqual('error', self.migration.status)
self.migration.save.assert_called_once_with()
# Assert wrap_exception is called.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
@mock.patch('nova.objects.Instance.save')
@mock.patch('nova.compute.manager.ComputeManager.'
@@ -11651,10 +11650,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
self.assertEqual('error', self.migration.status)
self.migration.save.assert_called_once_with()
# Assert wrap_exception is called.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
@mock.patch('nova.objects.Instance.get_bdms')
@mock.patch('nova.compute.manager.ComputeManager.'
@@ -11810,10 +11809,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
self.assertEqual('error', self.migration.status)
self.migration.save.assert_called_once_with()
# Assert wrap_exception is called.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
# clear_events_for_instance should not have been called.
mock_clear_events.assert_not_called()
@@ -11945,10 +11944,10 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase,
mock_add_fault.assert_called_once_with(
self.context, self.instance, error, test.MatchType(tuple))
# wrap_exception should have sent an error notification.
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'compute.%s' % fields.NotificationAction.EXCEPTION,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
# Now run it again but _finish_revert_snapshot_based_resize_at_source
# will pass and _update_scheduler_instance_info will fail but not be
diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py
index 4a32c87d95..ba03f06730 100644
--- a/nova/tests/unit/compute/test_compute_utils.py
+++ b/nova/tests/unit/compute/test_compute_utils.py
@@ -43,6 +43,7 @@ from nova.objects import fields
from nova import rpc
from nova.scheduler.client import report
from nova import test
+from nova.tests import fixtures
from nova.tests.unit import fake_block_device
from nova.tests.unit import fake_crypto
from nova.tests.unit import fake_instance
@@ -360,8 +361,7 @@ class UsageInfoTestCase(test.TestCase):
super(UsageInfoTestCase, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(fixtures.NotificationFixture(self))
self.flags(compute_driver='fake.FakeDriver')
self.compute = manager.ComputeManager()
@@ -417,8 +417,8 @@ class UsageInfoTestCase(test.TestCase):
compute_utils.notify_usage_exists(
rpc.get_notifier('compute'), self.context, instance, 'fake-host')
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- msg = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ msg = self.notifier.versioned_notifications[0]
self.assertEqual(msg['priority'], 'INFO')
self.assertEqual(msg['event_type'], 'instance.exists')
payload = msg['payload']['nova_object.data']
@@ -493,8 +493,8 @@ class UsageInfoTestCase(test.TestCase):
phase='start',
bdms=bdms)
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual(notification['priority'], 'INFO')
self.assertEqual(notification['event_type'], 'instance.delete.start')
@@ -539,8 +539,8 @@ class UsageInfoTestCase(test.TestCase):
host='fake-compute',
phase='start')
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('INFO', notification['priority'])
self.assertEqual('instance.create.start', notification['event_type'])
@@ -582,8 +582,8 @@ class UsageInfoTestCase(test.TestCase):
host='fake-compute',
phase='start')
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('INFO', notification['priority'])
self.assertEqual('instance.create.start', notification['event_type'])
@@ -621,8 +621,8 @@ class UsageInfoTestCase(test.TestCase):
host='fake-compute',
phase='start')
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('INFO', notification['priority'])
self.assertEqual('instance.create.start', notification['event_type'])
@@ -656,8 +656,8 @@ class UsageInfoTestCase(test.TestCase):
fields.NotificationPhase.START,
uuids.old_volume_id, uuids.new_volume_id)
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('INFO', notification['priority'])
self.assertEqual('instance.%s.%s' %
@@ -697,8 +697,8 @@ class UsageInfoTestCase(test.TestCase):
fields.NotificationPhase.ERROR,
uuids.old_volume_id, uuids.new_volume_id, ex)
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('ERROR', notification['priority'])
self.assertEqual('instance.%s.%s' %
@@ -748,8 +748,8 @@ class UsageInfoTestCase(test.TestCase):
uuids.rescue_image_ref,
phase='start')
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual(notification['priority'], 'INFO')
self.assertEqual(notification['event_type'], 'instance.rescue.start')
@@ -781,8 +781,8 @@ class UsageInfoTestCase(test.TestCase):
compute_utils.notify_about_resize_prep_instance(
self.context, instance, 'fake-compute', 'start', new_flavor)
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual(notification['priority'], 'INFO')
self.assertEqual(notification['event_type'],
@@ -854,8 +854,8 @@ class UsageInfoTestCase(test.TestCase):
compute_utils.notify_about_volume_usage(self.context, vol_usage,
'fake-compute')
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('INFO', notification['priority'])
self.assertEqual('volume.usage', notification['event_type'])
@@ -1235,8 +1235,7 @@ class ComputeUtilsTestCase(test.NoDBTestCase):
class ServerGroupTestCase(test.TestCase):
def setUp(self):
super(ServerGroupTestCase, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(fixtures.NotificationFixture(self))
self.user_id = 'fake'
self.project_id = 'fake'
self.context = context.RequestContext(self.user_id, self.project_id)
@@ -1253,8 +1252,8 @@ class ServerGroupTestCase(test.TestCase):
def test_notify_about_server_group_action(self):
compute_utils.notify_about_server_group_action(self.context,
self.group, 'create')
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
expected = {'priority': 'INFO',
'event_type': u'server_group.create',
'publisher_id': u'nova-api:fake-mini',
@@ -1285,8 +1284,8 @@ class ServerGroupTestCase(test.TestCase):
self.context, uuids.server_group)
mock_get_by_uuid.assert_called_once_with(self.context,
uuids.server_group)
- self.assertEqual(len(fake_notifier.VERSIONED_NOTIFICATIONS), 1)
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(len(self.notifier.versioned_notifications), 1)
+ notification = self.notifier.versioned_notifications[0]
expected = {'priority': 'INFO',
'event_type': u'server_group.add_member',
'publisher_id': u'nova-api:fake-mini',
diff --git a/nova/tests/unit/compute/test_host_api.py b/nova/tests/unit/compute/test_host_api.py
index adc3589ff5..17c0a2c5ee 100644
--- a/nova/tests/unit/compute/test_host_api.py
+++ b/nova/tests/unit/compute/test_host_api.py
@@ -38,8 +38,7 @@ class ComputeHostAPITestCase(test.TestCase):
self.host_api = compute.HostAPI()
self.aggregate_api = compute.AggregateAPI()
self.ctxt = context.get_admin_context()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.useFixture(nova_fixtures.NotificationFixture(self))
self.req = fakes.HTTPRequest.blank('')
self.controller = services.ServiceController()
self.useFixture(nova_fixtures.SingleCellSimple())
diff --git a/nova/tests/unit/compute/test_resource_tracker.py b/nova/tests/unit/compute/test_resource_tracker.py
index d47e92ffb1..e1aff3dfa2 100644
--- a/nova/tests/unit/compute/test_resource_tracker.py
+++ b/nova/tests/unit/compute/test_resource_tracker.py
@@ -39,6 +39,7 @@ from nova.objects import pci_device
from nova.pci import manager as pci_manager
from nova.scheduler.client import report
from nova import test
+from nova.tests import fixtures
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_notifier
from nova.tests.unit.objects import test_pci_device as fake_pci_device
@@ -3796,8 +3797,7 @@ class ComputeMonitorTestCase(BaseTestCase):
@mock.patch('nova.compute.utils.notify_about_metrics_update')
def test_get_host_metrics(self, mock_notify):
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.useFixture(fixtures.NotificationFixture(self))
class FakeCPUMonitor(monitor_base.MonitorBase):
diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py
index bff9af3422..ae7005b0c4 100644
--- a/nova/tests/unit/conductor/test_conductor.py
+++ b/nova/tests/unit/conductor/test_conductor.py
@@ -138,8 +138,7 @@ class _BaseTestCase(object):
self.project_id = fakes.FAKE_PROJECT_ID
self.context = FakeContext(self.user_id, self.project_id)
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.useFixture(fixtures.NotificationFixture(self))
self.stub_out('nova.rpc.RequestContextSerializer.deserialize_context',
lambda *args, **kwargs: self.context)
diff --git a/nova/tests/unit/objects/test_objects.py b/nova/tests/unit/objects/test_objects.py
index 13d3270894..499a6d1d82 100644
--- a/nova/tests/unit/objects/test_objects.py
+++ b/nova/tests/unit/objects/test_objects.py
@@ -35,7 +35,6 @@ from nova.objects import fields
from nova.objects import virt_device_metadata
from nova import test
from nova.tests import fixtures as nova_fixtures
-from nova.tests.unit import fake_notifier
from nova import utils
@@ -212,8 +211,7 @@ class _BaseTestCase(test.TestCase):
self.user_id = 'fake-user'
self.project_id = 'fake-project'
self.context = context.RequestContext(self.user_id, self.project_id)
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.useFixture(nova_fixtures.NotificationFixture(self))
# NOTE(danms): register these here instead of at import time
# so that they're not always present
diff --git a/nova/tests/unit/test_exception_wrapper.py b/nova/tests/unit/test_exception_wrapper.py
index 7da86d7f74..85f73cd657 100644
--- a/nova/tests/unit/test_exception_wrapper.py
+++ b/nova/tests/unit/test_exception_wrapper.py
@@ -19,6 +19,7 @@ import mock
from nova import context as nova_context
from nova import exception_wrapper
from nova import test
+from nova.tests import fixtures as nova_fixtures
from nova.tests.unit import fake_notifier
@@ -52,8 +53,8 @@ def good_function(self, context):
class WrapExceptionTestCase(test.NoDBTestCase):
def setUp(self):
super(WrapExceptionTestCase, self).setUp()
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(
+ nova_fixtures.NotificationFixture(self))
def test_cleanse_dict(self):
kwargs = {'foo': 1, 'blah_pass': 2, 'zoo_password': 3, '_pass': 4}
@@ -67,7 +68,7 @@ class WrapExceptionTestCase(test.NoDBTestCase):
service='compute', binary='nova-compute')
self.assertEqual(99, wrapped(good_function)(1, 2))
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.versioned_notifications))
def test_wrap_exception_unknown_module(self):
ctxt = nova_context.get_admin_context()
@@ -75,8 +76,8 @@ class WrapExceptionTestCase(test.NoDBTestCase):
service='compute', binary='nova-compute')
self.assertRaises(
TypeError, wrapped(bad_function_unknown_module), None, ctxt)
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
payload = notification['payload']['nova_object.data']
self.assertEqual('unknown', payload['module_name'])
@@ -96,8 +97,8 @@ class WrapExceptionTestCase(test.NoDBTestCase):
self.assertIn(key, notification.payload.keys())
self.assertNotIn('context', notification.payload['args'].keys())
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
- notification = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
+ notification = self.notifier.versioned_notifications[0]
self.assertEqual('compute.exception', notification['event_type'])
self.assertEqual('nova-compute:fake-mini',
notification['publisher_id'])
diff --git a/nova/tests/unit/test_notifications.py b/nova/tests/unit/test_notifications.py
index da3159f153..0798b4b104 100644
--- a/nova/tests/unit/test_notifications.py
+++ b/nova/tests/unit/test_notifications.py
@@ -32,6 +32,7 @@ from nova.notifications import base as notifications
from nova import objects
from nova.objects import base as obj_base
from nova import test
+from nova.tests import fixtures
from nova.tests.unit import fake_network
from nova.tests.unit import fake_notifier
@@ -46,8 +47,7 @@ class NotificationsTestCase(test.TestCase):
self.fixture = self.useFixture(o_fixture.ClearRequestContext())
self.net_info = fake_network.fake_get_instance_nw_info(self)
- fake_notifier.stub_notifier(self)
- self.addCleanup(fake_notifier.reset)
+ self.notifier = self.useFixture(fixtures.NotificationFixture(self))
self.flags(host='testhost')
self.flags(notify_on_state_change="vm_and_task_state",
@@ -106,7 +106,7 @@ class NotificationsTestCase(test.TestCase):
notifications.send_update(self.context, old, self.instance)
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.versioned_notifications))
def test_task_notif(self):
@@ -127,7 +127,7 @@ class NotificationsTestCase(test.TestCase):
verify_states=True)
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.versioned_notifications))
# ok now enable task state notifications and re-try
self.flags(notify_on_state_change="vm_and_task_state",
@@ -135,11 +135,11 @@ class NotificationsTestCase(test.TestCase):
notifications.send_update(self.context, old, self.instance)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'instance.update',
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
def test_send_no_notif(self):
@@ -154,7 +154,7 @@ class NotificationsTestCase(test.TestCase):
service="compute", host=None, verify_states=True)
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.versioned_notifications))
def test_send_on_vm_change(self):
old = obj_base.obj_to_primitive(self.instance)
@@ -168,13 +168,13 @@ class NotificationsTestCase(test.TestCase):
notif = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('compute.testhost', notif.publisher_id)
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'nova-compute:testhost',
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['publisher_id'])
+ self.notifier.versioned_notifications[0]['publisher_id'])
self.assertEqual(
'instance.update',
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
def test_send_on_task_change(self):
@@ -185,10 +185,10 @@ class NotificationsTestCase(test.TestCase):
notifications.send_update(self.context, old, self.instance)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'instance.update',
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
def test_no_update_with_states(self):
@@ -196,7 +196,7 @@ class NotificationsTestCase(test.TestCase):
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
task_states.SPAWNING, verify_states=True)
self.assertEqual(0, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(0, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(0, len(self.notifier.versioned_notifications))
def test_vm_update_with_states(self):
fake_net_info = fake_network.fake_get_instance_nw_info(self)
@@ -211,10 +211,10 @@ class NotificationsTestCase(test.TestCase):
def _verify_notification(self, expected_state=vm_states.ACTIVE,
expected_new_task_state=task_states.SPAWNING):
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(
'instance.update',
- fake_notifier.VERSIONED_NOTIFICATIONS[0]['event_type'])
+ self.notifier.versioned_notifications[0]['event_type'])
access_ip_v4 = str(self.instance.access_ip_v4)
access_ip_v6 = str(self.instance.access_ip_v6)
display_name = self.instance.display_name
@@ -235,7 +235,7 @@ class NotificationsTestCase(test.TestCase):
self.assertEqual("2017-02-02T16:45:00.000000",
payload["audit_period_ending"])
- payload = fake_notifier.VERSIONED_NOTIFICATIONS[0][
+ payload = self.notifier.versioned_notifications[0][
'payload']['nova_object.data']
state_update = payload['state_update']['nova_object.data']
self.assertEqual(vm_states.BUILDING, state_update['old_state'])
@@ -284,14 +284,14 @@ class NotificationsTestCase(test.TestCase):
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
None)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
# service name should default to 'compute'
notif = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('compute.testhost', notif.publisher_id)
# in the versioned notification it defaults to nova-compute
- notif = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ notif = self.notifier.versioned_notifications[0]
self.assertEqual('nova-compute:testhost', notif['publisher_id'])
def test_update_with_service_name(self):
@@ -299,13 +299,13 @@ class NotificationsTestCase(test.TestCase):
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
None, service="nova-compute")
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
# service name should default to 'compute'
notif = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('nova-compute.testhost', notif.publisher_id)
- notif = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ notif = self.notifier.versioned_notifications[0]
self.assertEqual('nova-compute:testhost', notif['publisher_id'])
def test_update_with_host_name(self):
@@ -313,13 +313,13 @@ class NotificationsTestCase(test.TestCase):
vm_states.BUILDING, vm_states.BUILDING, task_states.SPAWNING,
None, host="someotherhost")
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
# service name should default to 'compute'
notif = fake_notifier.NOTIFICATIONS[0]
self.assertEqual('compute.someotherhost', notif.publisher_id)
- notif = fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ notif = self.notifier.versioned_notifications[0]
self.assertEqual('nova-compute:someotherhost', notif['publisher_id'])
def test_payload_has_fixed_ip_labels(self):
@@ -411,14 +411,14 @@ class NotificationsTestCase(test.TestCase):
new_name_inst = self._wrapped_create(params=param)
notifications.send_update(self.context, self.instance, new_name_inst)
self.assertEqual(1, len(fake_notifier.NOTIFICATIONS))
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
old_display_name = self.instance.display_name
new_display_name = new_name_inst.display_name
for payload in [
fake_notifier.NOTIFICATIONS[0].payload,
- fake_notifier.VERSIONED_NOTIFICATIONS[0][
+ self.notifier.versioned_notifications[0][
'payload']['nova_object.data']]:
self.assertEqual(payload["old_display_name"], old_display_name)
@@ -428,24 +428,24 @@ class NotificationsTestCase(test.TestCase):
objects.TagList.create(self.context,
self.instance.uuid, [u'tag1', u'tag2'])
notifications.send_update(self.context, self.instance, self.instance)
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual([u'tag1', u'tag2'],
- fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.notifier.versioned_notifications[0]
['payload']['nova_object.data']['tags'])
def test_send_versioned_action_initiator_update(self):
notifications.send_update(self.context, self.instance, self.instance)
action_initiator_user = self.context.user_id
action_initiator_project = self.context.project_id
- self.assertEqual(1, len(fake_notifier.VERSIONED_NOTIFICATIONS))
+ self.assertEqual(1, len(self.notifier.versioned_notifications))
self.assertEqual(action_initiator_user,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.notifier.versioned_notifications[0]
['payload']['nova_object.data']
['action_initiator_user'])
self.assertEqual(action_initiator_project,
- fake_notifier.VERSIONED_NOTIFICATIONS[0]
+ self.notifier.versioned_notifications[0]
['payload']['nova_object.data']
['action_initiator_project'])