|
|
|
@ -34,7 +34,7 @@ from ironic.tests.unit.objects import utils as obj_utils
|
|
|
|
|
@mock.patch.object(objects.Node, 'get')
|
|
|
|
|
@mock.patch.object(objects.Node, 'release')
|
|
|
|
|
@mock.patch.object(objects.Node, 'reserve')
|
|
|
|
|
@mock.patch.object(driver_factory, 'get_driver')
|
|
|
|
|
@mock.patch.object(driver_factory, 'build_driver_for_task')
|
|
|
|
|
@mock.patch.object(objects.Port, 'list_by_node_id')
|
|
|
|
|
@mock.patch.object(objects.Portgroup, 'list_by_node_id')
|
|
|
|
|
class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
@ -48,7 +48,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.future_mock = mock.Mock(spec=['cancel', 'add_done_callback'])
|
|
|
|
|
|
|
|
|
|
def test_excl_lock(self, get_portgroups_mock, get_ports_mock,
|
|
|
|
|
get_driver_mock, reserve_mock, release_mock,
|
|
|
|
|
build_driver_mock, reserve_mock, release_mock,
|
|
|
|
|
node_get_mock):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
with task_manager.TaskManager(self.context, 'fake-node-id') as task:
|
|
|
|
@ -56,20 +56,20 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
|
self.assertEqual(get_ports_mock.return_value, task.ports)
|
|
|
|
|
self.assertEqual(get_portgroups_mock.return_value, task.portgroups)
|
|
|
|
|
self.assertEqual(get_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertEqual(build_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertFalse(task.shared)
|
|
|
|
|
build_driver_mock.assert_called_once_with(task, driver_name=None)
|
|
|
|
|
|
|
|
|
|
reserve_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with(self.node.driver)
|
|
|
|
|
release_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
self.node.id)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_with_driver(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
with task_manager.TaskManager(self.context, 'fake-node-id',
|
|
|
|
@ -78,20 +78,21 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
|
self.assertEqual(get_ports_mock.return_value, task.ports)
|
|
|
|
|
self.assertEqual(get_portgroups_mock.return_value, task.portgroups)
|
|
|
|
|
self.assertEqual(get_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertEqual(build_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertFalse(task.shared)
|
|
|
|
|
build_driver_mock.assert_called_once_with(
|
|
|
|
|
task, driver_name='fake-driver')
|
|
|
|
|
|
|
|
|
|
reserve_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with('fake-driver')
|
|
|
|
|
release_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
self.node.id)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_nested_acquire(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node2 = obj_utils.create_test_node(self.context,
|
|
|
|
|
uuid=uuidutils.generate_uuid(),
|
|
|
|
@ -100,13 +101,13 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
get_ports_mock.return_value = mock.sentinel.ports1
|
|
|
|
|
get_portgroups_mock.return_value = mock.sentinel.portgroups1
|
|
|
|
|
get_driver_mock.return_value = mock.sentinel.driver1
|
|
|
|
|
build_driver_mock.return_value = mock.sentinel.driver1
|
|
|
|
|
|
|
|
|
|
with task_manager.TaskManager(self.context, 'node-id1') as task:
|
|
|
|
|
reserve_mock.return_value = node2
|
|
|
|
|
get_ports_mock.return_value = mock.sentinel.ports2
|
|
|
|
|
get_portgroups_mock.return_value = mock.sentinel.portgroups2
|
|
|
|
|
get_driver_mock.return_value = mock.sentinel.driver2
|
|
|
|
|
build_driver_mock.return_value = mock.sentinel.driver2
|
|
|
|
|
with task_manager.TaskManager(self.context, 'node-id2') as task2:
|
|
|
|
|
self.assertEqual(self.context, task.context)
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
@ -121,15 +122,16 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(mock.sentinel.driver2, task2.driver)
|
|
|
|
|
self.assertFalse(task2.shared)
|
|
|
|
|
|
|
|
|
|
self.assertEqual([mock.call(task, driver_name=None),
|
|
|
|
|
mock.call(task2, driver_name=None)],
|
|
|
|
|
build_driver_mock.call_args_list)
|
|
|
|
|
|
|
|
|
|
self.assertEqual([mock.call(self.context, self.host, 'node-id1'),
|
|
|
|
|
mock.call(self.context, self.host, 'node-id2')],
|
|
|
|
|
reserve_mock.call_args_list)
|
|
|
|
|
self.assertEqual([mock.call(self.context, self.node.id),
|
|
|
|
|
mock.call(self.context, node2.id)],
|
|
|
|
|
get_ports_mock.call_args_list)
|
|
|
|
|
self.assertEqual([mock.call(self.node.driver),
|
|
|
|
|
mock.call(node2.driver)],
|
|
|
|
|
get_driver_mock.call_args_list)
|
|
|
|
|
# release should be in reverse order
|
|
|
|
|
self.assertEqual([mock.call(self.context, self.host, node2.id),
|
|
|
|
|
mock.call(self.context, self.host, self.node.id)],
|
|
|
|
@ -137,7 +139,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_exception_then_lock(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
retry_attempts = 3
|
|
|
|
|
self.config(node_locked_retry_attempts=retry_attempts,
|
|
|
|
@ -157,7 +159,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(2, reserve_mock.call_count)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_reserve_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
retry_attempts = 3
|
|
|
|
|
self.config(node_locked_retry_attempts=retry_attempts,
|
|
|
|
@ -175,12 +177,12 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(retry_attempts, reserve_mock.call_count)
|
|
|
|
|
self.assertFalse(get_ports_mock.called)
|
|
|
|
|
self.assertFalse(get_portgroups_mock.called)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
self.assertFalse(release_mock.called)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_get_ports_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
get_ports_mock.side_effect = exception.IronicException('foo')
|
|
|
|
@ -193,13 +195,13 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
reserve_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
release_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
self.node.id)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_get_portgroups_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
get_portgroups_mock.side_effect = exception.IronicException('foo')
|
|
|
|
@ -212,16 +214,16 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
reserve_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
'fake-node-id')
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
release_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
self.node.id)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_excl_lock_get_driver_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
def test_excl_lock_build_driver_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
get_driver_mock.side_effect = (
|
|
|
|
|
build_driver_mock.side_effect = (
|
|
|
|
|
exception.DriverNotFound(driver_name='foo'))
|
|
|
|
|
|
|
|
|
|
self.assertRaises(exception.DriverNotFound,
|
|
|
|
@ -233,13 +235,13 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with(self.node.driver)
|
|
|
|
|
build_driver_mock.assert_called_once_with(mock.ANY, driver_name=None)
|
|
|
|
|
release_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
self.node.id)
|
|
|
|
|
self.assertFalse(node_get_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_shared_lock(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
with task_manager.TaskManager(self.context, 'fake-node-id',
|
|
|
|
@ -248,18 +250,19 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
|
self.assertEqual(get_ports_mock.return_value, task.ports)
|
|
|
|
|
self.assertEqual(get_portgroups_mock.return_value, task.portgroups)
|
|
|
|
|
self.assertEqual(get_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertEqual(build_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertTrue(task.shared)
|
|
|
|
|
|
|
|
|
|
build_driver_mock.assert_called_once_with(task, driver_name=None)
|
|
|
|
|
|
|
|
|
|
self.assertFalse(reserve_mock.called)
|
|
|
|
|
self.assertFalse(release_mock.called)
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with(self.node.driver)
|
|
|
|
|
|
|
|
|
|
def test_shared_lock_with_driver(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
with task_manager.TaskManager(self.context,
|
|
|
|
@ -270,18 +273,20 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
|
self.assertEqual(get_ports_mock.return_value, task.ports)
|
|
|
|
|
self.assertEqual(get_portgroups_mock.return_value, task.portgroups)
|
|
|
|
|
self.assertEqual(get_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertEqual(build_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertTrue(task.shared)
|
|
|
|
|
|
|
|
|
|
build_driver_mock.assert_called_once_with(
|
|
|
|
|
task, driver_name='fake-driver')
|
|
|
|
|
|
|
|
|
|
self.assertFalse(reserve_mock.called)
|
|
|
|
|
self.assertFalse(release_mock.called)
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with('fake-driver')
|
|
|
|
|
|
|
|
|
|
def test_shared_lock_node_get_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.side_effect = exception.NodeNotFound(node='foo')
|
|
|
|
|
|
|
|
|
@ -296,10 +301,10 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
self.assertFalse(get_ports_mock.called)
|
|
|
|
|
self.assertFalse(get_portgroups_mock.called)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_shared_lock_get_ports_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
get_ports_mock.side_effect = exception.IronicException('foo')
|
|
|
|
@ -314,10 +319,10 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertFalse(release_mock.called)
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_shared_lock_get_portgroups_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
get_portgroups_mock.side_effect = exception.IronicException('foo')
|
|
|
|
@ -332,13 +337,13 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertFalse(release_mock.called)
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
self.assertFalse(get_driver_mock.called)
|
|
|
|
|
self.assertFalse(build_driver_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_shared_lock_get_driver_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
def test_shared_lock_build_driver_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
get_driver_mock.side_effect = (
|
|
|
|
|
build_driver_mock.side_effect = (
|
|
|
|
|
exception.DriverNotFound(driver_name='foo'))
|
|
|
|
|
|
|
|
|
|
self.assertRaises(exception.DriverNotFound,
|
|
|
|
@ -352,10 +357,10 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with(self.node.driver)
|
|
|
|
|
build_driver_mock.assert_called_once_with(mock.ANY, driver_name=None)
|
|
|
|
|
|
|
|
|
|
def test_upgrade_lock(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
node_get_mock.return_value = self.node
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
@ -365,7 +370,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertEqual(self.node, task.node)
|
|
|
|
|
self.assertEqual(get_ports_mock.return_value, task.ports)
|
|
|
|
|
self.assertEqual(get_portgroups_mock.return_value, task.portgroups)
|
|
|
|
|
self.assertEqual(get_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertEqual(build_driver_mock.return_value, task.driver)
|
|
|
|
|
self.assertTrue(task.shared)
|
|
|
|
|
self.assertFalse(reserve_mock.called)
|
|
|
|
|
|
|
|
|
@ -375,6 +380,9 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
task.upgrade_lock()
|
|
|
|
|
self.assertFalse(task.shared)
|
|
|
|
|
|
|
|
|
|
build_driver_mock.assert_called_once_with(mock.ANY,
|
|
|
|
|
driver_name=None)
|
|
|
|
|
|
|
|
|
|
# make sure reserve() was called only once
|
|
|
|
|
reserve_mock.assert_called_once_with(self.context, self.host,
|
|
|
|
|
'fake-node-id')
|
|
|
|
@ -383,10 +391,9 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
|
|
|
|
get_ports_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
|
|
|
|
get_driver_mock.assert_called_once_with(self.node.driver)
|
|
|
|
|
|
|
|
|
|
def test_spawn_after(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
spawn_mock = mock.Mock(return_value=self.future_mock)
|
|
|
|
|
task_release_mock = mock.Mock()
|
|
|
|
@ -406,7 +413,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
self.assertFalse(task_release_mock.called)
|
|
|
|
|
|
|
|
|
|
def test_spawn_after_exception_while_yielded(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
spawn_mock = mock.Mock()
|
|
|
|
|
task_release_mock = mock.Mock()
|
|
|
|
@ -423,7 +430,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
task_release_mock.assert_called_once_with()
|
|
|
|
|
|
|
|
|
|
def test_spawn_after_spawn_fails(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
spawn_mock = mock.Mock(side_effect=exception.IronicException('foo'))
|
|
|
|
|
task_release_mock = mock.Mock()
|
|
|
|
@ -440,7 +447,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
task_release_mock.assert_called_once_with()
|
|
|
|
|
|
|
|
|
|
def test_spawn_after_link_fails(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
self.future_mock.add_done_callback.side_effect = (
|
|
|
|
|
exception.IronicException('foo'))
|
|
|
|
@ -463,7 +470,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
task_release_mock.assert_called_once_with()
|
|
|
|
|
|
|
|
|
|
def test_spawn_after_on_error_hook(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
expected_exception = exception.IronicException('foo')
|
|
|
|
|
spawn_mock = mock.Mock(side_effect=expected_exception)
|
|
|
|
@ -485,7 +492,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
'fake-argument')
|
|
|
|
|
|
|
|
|
|
def test_spawn_after_on_error_hook_exception(
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, get_driver_mock,
|
|
|
|
|
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
|
|
|
|
reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
expected_exception = exception.IronicException('foo')
|
|
|
|
|
spawn_mock = mock.Mock(side_effect=expected_exception)
|
|
|
|
@ -512,7 +519,7 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
|
|
|
|
@mock.patch.object(states.machine, 'copy')
|
|
|
|
|
def test_init_prepares_fsm(
|
|
|
|
|
self, copy_mock, get_portgroups_mock, get_ports_mock,
|
|
|
|
|
get_driver_mock, reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
build_driver_mock, reserve_mock, release_mock, node_get_mock):
|
|
|
|
|
m = mock.Mock(spec=fsm.FSM)
|
|
|
|
|
reserve_mock.return_value = self.node
|
|
|
|
|
copy_mock.return_value = m
|
|
|
|
|