Merge "Add volume_connectors and volume_targets to task"
This commit is contained in:
commit
d69a3b6c58
@ -50,6 +50,10 @@ attributes that you may access:
|
||||
The Node object
|
||||
task.ports
|
||||
Ports belonging to the Node
|
||||
task.volume_connectors
|
||||
Storage connectors belonging to the Node
|
||||
task.volume_targets
|
||||
Storage targets assigned to the Node
|
||||
task.driver
|
||||
The Driver for the Node, or the Driver based on the
|
||||
'driver_name' kwarg of TaskManager().
|
||||
@ -226,6 +230,10 @@ class TaskManager(object):
|
||||
self.ports = objects.Port.list_by_node_id(context, self.node.id)
|
||||
self.portgroups = objects.Portgroup.list_by_node_id(context,
|
||||
self.node.id)
|
||||
self.volume_connectors = objects.VolumeConnector.list_by_node_id(
|
||||
context, self.node.id)
|
||||
self.volume_targets = objects.VolumeTarget.list_by_node_id(
|
||||
context, self.node.id)
|
||||
self.driver = driver_factory.build_driver_for_task(
|
||||
self, driver_name=driver_name)
|
||||
|
||||
@ -344,6 +352,8 @@ class TaskManager(object):
|
||||
self.driver = None
|
||||
self.ports = None
|
||||
self.portgroups = None
|
||||
self.volume_connectors = None
|
||||
self.volume_targets = None
|
||||
self.fsm = None
|
||||
|
||||
def _write_exception(self, future):
|
||||
|
@ -40,6 +40,8 @@ from ironic.tests.unit.objects import utils as obj_utils
|
||||
@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')
|
||||
@mock.patch.object(objects.VolumeConnector, 'list_by_node_id')
|
||||
@mock.patch.object(objects.VolumeTarget, 'list_by_node_id')
|
||||
class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
def setUp(self):
|
||||
super(TaskManagerTestCase, self).setUp()
|
||||
@ -50,7 +52,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
self.node = obj_utils.create_test_node(self.context)
|
||||
self.future_mock = mock.Mock(spec=['cancel', 'add_done_callback'])
|
||||
|
||||
def test_excl_lock(self, get_portgroups_mock, get_ports_mock,
|
||||
def test_excl_lock(self, get_voltgt_mock, get_volconn_mock,
|
||||
get_portgroups_mock, get_ports_mock,
|
||||
build_driver_mock, reserve_mock, release_mock,
|
||||
node_get_mock):
|
||||
reserve_mock.return_value = self.node
|
||||
@ -59,6 +62,9 @@ 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_volconn_mock.return_value,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(get_voltgt_mock.return_value, task.volume_targets)
|
||||
self.assertEqual(build_driver_mock.return_value, task.driver)
|
||||
self.assertFalse(task.shared)
|
||||
build_driver_mock.assert_called_once_with(task, driver_name=None)
|
||||
@ -68,11 +74,14 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
release_mock.assert_called_once_with(self.context, self.host,
|
||||
self.node.id)
|
||||
|
||||
def test_excl_lock_with_driver(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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',
|
||||
@ -81,6 +90,9 @@ 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_volconn_mock.return_value,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(get_voltgt_mock.return_value, task.volume_targets)
|
||||
self.assertEqual(build_driver_mock.return_value, task.driver)
|
||||
self.assertFalse(task.shared)
|
||||
build_driver_mock.assert_called_once_with(
|
||||
@ -91,11 +103,14 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
release_mock.assert_called_once_with(self.context, self.host,
|
||||
self.node.id)
|
||||
|
||||
def test_excl_nested_acquire(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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(),
|
||||
@ -104,24 +119,34 @@ 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_volconn_mock.return_value = mock.sentinel.volconn1
|
||||
get_voltgt_mock.return_value = mock.sentinel.voltgt1
|
||||
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_volconn_mock.return_value = mock.sentinel.volconn2
|
||||
get_voltgt_mock.return_value = mock.sentinel.voltgt2
|
||||
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)
|
||||
self.assertEqual(mock.sentinel.ports1, task.ports)
|
||||
self.assertEqual(mock.sentinel.portgroups1, task.portgroups)
|
||||
self.assertEqual(mock.sentinel.volconn1,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(mock.sentinel.voltgt1, task.volume_targets)
|
||||
self.assertEqual(mock.sentinel.driver1, task.driver)
|
||||
self.assertFalse(task.shared)
|
||||
self.assertEqual(self.context, task2.context)
|
||||
self.assertEqual(node2, task2.node)
|
||||
self.assertEqual(mock.sentinel.ports2, task2.ports)
|
||||
self.assertEqual(mock.sentinel.portgroups2, task2.portgroups)
|
||||
self.assertEqual(mock.sentinel.volconn2,
|
||||
task2.volume_connectors)
|
||||
self.assertEqual(mock.sentinel.voltgt2, task2.volume_targets)
|
||||
self.assertEqual(mock.sentinel.driver2, task2.driver)
|
||||
self.assertFalse(task2.shared)
|
||||
|
||||
@ -144,7 +169,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
release_mock.call_args_list)
|
||||
|
||||
def test_excl_lock_exception_then_lock(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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,
|
||||
@ -164,7 +190,8 @@ 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, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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,
|
||||
@ -182,11 +209,14 @@ 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_volconn_mock.called)
|
||||
self.assertFalse(get_voltgt_mock.called)
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
self.assertFalse(release_mock.called)
|
||||
|
||||
def test_excl_lock_get_ports_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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')
|
||||
@ -205,7 +235,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
self.node.id)
|
||||
|
||||
def test_excl_lock_get_portgroups_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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')
|
||||
@ -223,8 +254,49 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
release_mock.assert_called_once_with(self.context, self.host,
|
||||
self.node.id)
|
||||
|
||||
def test_excl_lock_get_volconn_exception(
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
reserve_mock.return_value = self.node
|
||||
get_volconn_mock.side_effect = exception.IronicException('foo')
|
||||
|
||||
self.assertRaises(exception.IronicException,
|
||||
task_manager.TaskManager,
|
||||
self.context,
|
||||
'fake-node-id')
|
||||
|
||||
reserve_mock.assert_called_once_with(self.context, self.host,
|
||||
'fake-node-id')
|
||||
get_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
self.assertFalse(get_voltgt_mock.called)
|
||||
release_mock.assert_called_once_with(self.context, self.host,
|
||||
self.node.id)
|
||||
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
||||
|
||||
def test_excl_lock_get_voltgt_exception(
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
reserve_mock.return_value = self.node
|
||||
get_voltgt_mock.side_effect = exception.IronicException('foo')
|
||||
|
||||
self.assertRaises(exception.IronicException,
|
||||
task_manager.TaskManager,
|
||||
self.context,
|
||||
'fake-node-id')
|
||||
|
||||
reserve_mock.assert_called_once_with(self.context, self.host,
|
||||
'fake-node-id')
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
release_mock.assert_called_once_with(self.context, self.host,
|
||||
self.node.id)
|
||||
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
||||
|
||||
def test_excl_lock_build_driver_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
reserve_mock.return_value = self.node
|
||||
build_driver_mock.side_effect = (
|
||||
@ -245,7 +317,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
self.node.id)
|
||||
|
||||
def test_shared_lock(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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',
|
||||
@ -254,6 +327,9 @@ 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_volconn_mock.return_value,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(get_voltgt_mock.return_value, task.volume_targets)
|
||||
self.assertEqual(build_driver_mock.return_value, task.driver)
|
||||
self.assertTrue(task.shared)
|
||||
|
||||
@ -264,9 +340,12 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
|
||||
def test_shared_lock_with_driver(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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,
|
||||
@ -277,6 +356,9 @@ 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_volconn_mock.return_value,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(get_voltgt_mock.return_value, task.volume_targets)
|
||||
self.assertEqual(build_driver_mock.return_value, task.driver)
|
||||
self.assertTrue(task.shared)
|
||||
|
||||
@ -288,9 +370,12 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
|
||||
def test_shared_lock_node_get_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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')
|
||||
|
||||
@ -305,10 +390,13 @@ 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_volconn_mock.called)
|
||||
self.assertFalse(get_voltgt_mock.called)
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
|
||||
def test_shared_lock_get_ports_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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')
|
||||
@ -326,7 +414,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
|
||||
def test_shared_lock_get_portgroups_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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')
|
||||
@ -343,8 +432,47 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
get_portgroups_mock.assert_called_once_with(self.context, self.node.id)
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
|
||||
def test_shared_lock_get_volconn_exception(
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
node_get_mock.return_value = self.node
|
||||
get_volconn_mock.side_effect = exception.IronicException('foo')
|
||||
|
||||
self.assertRaises(exception.IronicException,
|
||||
task_manager.TaskManager,
|
||||
self.context,
|
||||
'fake-node-id',
|
||||
shared=True)
|
||||
|
||||
self.assertFalse(reserve_mock.called)
|
||||
self.assertFalse(release_mock.called)
|
||||
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
||||
get_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
self.assertFalse(get_voltgt_mock.called)
|
||||
|
||||
def test_shared_lock_get_voltgt_exception(
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
node_get_mock.return_value = self.node
|
||||
get_voltgt_mock.side_effect = exception.IronicException('foo')
|
||||
|
||||
self.assertRaises(exception.IronicException,
|
||||
task_manager.TaskManager,
|
||||
self.context,
|
||||
'fake-node-id',
|
||||
shared=True)
|
||||
|
||||
self.assertFalse(reserve_mock.called)
|
||||
self.assertFalse(release_mock.called)
|
||||
node_get_mock.assert_called_once_with(self.context, 'fake-node-id')
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
self.assertFalse(build_driver_mock.called)
|
||||
|
||||
def test_shared_lock_build_driver_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock, node_get_mock):
|
||||
node_get_mock.return_value = self.node
|
||||
build_driver_mock.side_effect = (
|
||||
@ -361,10 +489,13 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
build_driver_mock.assert_called_once_with(mock.ANY, driver_name=None)
|
||||
|
||||
def test_upgrade_lock(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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
|
||||
@ -374,6 +505,9 @@ 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_volconn_mock.return_value,
|
||||
task.volume_connectors)
|
||||
self.assertEqual(get_voltgt_mock.return_value, task.volume_targets)
|
||||
self.assertEqual(build_driver_mock.return_value, task.driver)
|
||||
self.assertTrue(task.shared)
|
||||
self.assertFalse(reserve_mock.called)
|
||||
@ -397,8 +531,11 @@ 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_volconn_mock.assert_called_once_with(self.context, self.node.id)
|
||||
get_voltgt_mock.assert_called_once_with(self.context, self.node.id)
|
||||
|
||||
def test_upgrade_lock_refreshes_fsm(self, get_portgroups_mock,
|
||||
def test_upgrade_lock_refreshes_fsm(self, get_voltgt_mock,
|
||||
get_volconn_mock, get_portgroups_mock,
|
||||
get_ports_mock, build_driver_mock,
|
||||
reserve_mock, release_mock,
|
||||
node_get_mock):
|
||||
@ -423,8 +560,9 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
@mock.patch.object(task_manager.TaskManager,
|
||||
'_notify_provision_state_change', autospec=True)
|
||||
def test_spawn_after(
|
||||
self, notify_mock, get_portgroups_mock, get_ports_mock,
|
||||
build_driver_mock, reserve_mock, release_mock, node_get_mock):
|
||||
self, notify_mock, get_voltgt_mock, get_volconn_mock,
|
||||
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()
|
||||
reserve_mock.return_value = self.node
|
||||
@ -444,7 +582,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
notify_mock.assert_called_once_with(task)
|
||||
|
||||
def test_spawn_after_exception_while_yielded(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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()
|
||||
@ -463,8 +602,9 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
@mock.patch.object(task_manager.TaskManager,
|
||||
'_notify_provision_state_change', autospec=True)
|
||||
def test_spawn_after_spawn_fails(
|
||||
self, notify_mock, get_portgroups_mock, get_ports_mock,
|
||||
build_driver_mock, reserve_mock, release_mock, node_get_mock):
|
||||
self, notify_mock, get_voltgt_mock, get_volconn_mock,
|
||||
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()
|
||||
reserve_mock.return_value = self.node
|
||||
@ -481,7 +621,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
self.assertFalse(notify_mock.called)
|
||||
|
||||
def test_spawn_after_link_fails(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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'))
|
||||
@ -504,7 +645,8 @@ 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, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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)
|
||||
@ -526,7 +668,8 @@ class TaskManagerTestCase(tests_db_base.DbTestCase):
|
||||
'fake-argument')
|
||||
|
||||
def test_spawn_after_on_error_hook_exception(
|
||||
self, get_portgroups_mock, get_ports_mock, build_driver_mock,
|
||||
self, get_voltgt_mock, get_volconn_mock, 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)
|
||||
@ -552,7 +695,8 @@ 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,
|
||||
self, copy_mock, get_volconn_mock, get_voltgt_mock,
|
||||
get_portgroups_mock, get_ports_mock,
|
||||
build_driver_mock, reserve_mock, release_mock, node_get_mock):
|
||||
m = mock.Mock(spec=fsm.FSM)
|
||||
reserve_mock.return_value = self.node
|
||||
@ -580,6 +724,8 @@ class TaskManagerStateModelTestCases(tests_base.TestCase):
|
||||
t.driver = mock.Mock()
|
||||
t.ports = mock.Mock()
|
||||
t.portgroups = mock.Mock()
|
||||
t.volume_connectors = mock.Mock()
|
||||
t.volume_targets = mock.Mock()
|
||||
t.shared = True
|
||||
t._purpose = 'purpose'
|
||||
t._debug_timer = mock.Mock()
|
||||
@ -589,6 +735,8 @@ class TaskManagerStateModelTestCases(tests_base.TestCase):
|
||||
self.assertIsNone(t.driver)
|
||||
self.assertIsNone(t.ports)
|
||||
self.assertIsNone(t.portgroups)
|
||||
self.assertIsNone(t.volume_connectors)
|
||||
self.assertIsNone(t.volume_targets)
|
||||
self.assertIsNone(t.fsm)
|
||||
|
||||
def test_process_event_fsm_raises(self):
|
||||
|
Loading…
Reference in New Issue
Block a user