summaryrefslogtreecommitdiff
path: root/nova/tests/unit/conductor
diff options
context:
space:
mode:
authorMatt Riedemann <mriedem.os@gmail.com>2019-12-16 11:09:29 -0500
committerMatt Riedemann <mriedem.os@gmail.com>2019-12-23 10:10:57 -0500
commit26d695876a1c16668956aee888ce9637b4fc7dc7 (patch)
tree72b0709ff5c4a8704225e0eebcea92b977cab6ba /nova/tests/unit/conductor
parent24bf2aaa7441430a84b475efca9f4777dc243452 (diff)
downloadnova-26d695876a1c16668956aee888ce9637b4fc7dc7.tar.gz
Use graceful_exit=True in ComputeTaskManager.revert_snapshot_based_resize
This passes graceful_exit=True to the wrap_instance_event decorator in ComputeTaskManager.revert_snapshot_based_resize so that upon successful completion of the RevertResizeTask, when the instance is hard destroyed from the target cell DB (used to create the action/event), a traceback is not logged for the InstanceActionNotFound exception. The same event is also finished in the source cell DB upon successful completion of the RevertResizeTask. Note that there are other ways we could have done this, e.g. moving the contents of the _execute() method to another method and then putting that in an EventReporter context with the source cell context/instance, but this was simpler. Part of blueprint cross-cell-resize Change-Id: Ibb32f7c19f5f2ec4811b165b8df748d1b7b0f9e4
Diffstat (limited to 'nova/tests/unit/conductor')
-rw-r--r--nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py3
-rw-r--r--nova/tests/unit/conductor/test_conductor.py6
2 files changed, 8 insertions, 1 deletions
diff --git a/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py b/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py
index 545ce37a86..ad9519345c 100644
--- a/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py
+++ b/nova/tests/unit/conductor/tasks/test_cross_cell_migrate.py
@@ -1322,6 +1322,9 @@ class RevertResizeTaskTestCase(test.NoDBTestCase, ObjectComparatorMixin):
mock_action_event.event_finish_with_failure.assert_called_once_with(
source_cell_context, source_cell_instance.uuid, event_name,
exc_val=None, exc_tb=None, want_result=False)
+ mock_action_event.event_finish.assert_called_once_with(
+ source_cell_context, source_cell_instance.uuid,
+ 'conductor_revert_snapshot_based_resize', want_result=False)
# Destroy the instance in the target cell.
mock_inst_destroy.assert_called_once_with(hard_delete=True)
# Cleanup at source host.
diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py
index cdc8f1ce41..3443c34e2c 100644
--- a/nova/tests/unit/conductor/test_conductor.py
+++ b/nova/tests/unit/conductor/test_conductor.py
@@ -1783,9 +1783,10 @@ class _BaseTaskTestCase(object):
self.context, instance=instance, migration=migration)
mock_execute.assert_called_once_with()
+ @mock.patch('nova.compute.utils.EventReporter')
@mock.patch(
'nova.conductor.tasks.cross_cell_migrate.RevertResizeTask.execute')
- def test_revert_snapshot_based_resize(self, mock_execute):
+ def test_revert_snapshot_based_resize(self, mock_execute, mock_er):
instance = self._create_fake_instance_obj(ctxt=self.context)
migration = objects.Migration(
context=self.context, source_compute=instance.host,
@@ -1794,6 +1795,9 @@ class _BaseTaskTestCase(object):
self.conductor_manager.revert_snapshot_based_resize(
self.context, instance=instance, migration=migration)
mock_execute.assert_called_once_with()
+ mock_er.assert_called_once_with(
+ self.context, 'conductor_revert_snapshot_based_resize',
+ self.conductor_manager.host, instance.uuid, graceful_exit=True)
class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):