37
37
self.driver_info = {}
38
38
self.driver_internal_info = {
39
'agent_url': "http://127.0.0.1:9999"
39
'agent_url': "http://127.0.0.1:9999",
40
'clean_version': {'generic': '1'}
41
42
self.instance_info = {}
47
'driver_info': self.driver_info,
48
'driver_internal_info': self.driver_internal_info,
49
'instance_info': self.instance_info
44
53
class TestAgentClient(base.TestCase):
90
99
mock_get.return_value = res
91
100
self.assertEqual([], self.client.get_commands_status(self.node))
93
def test_deploy_is_done(self):
94
with mock.patch.object(self.client, 'get_commands_status') as mock_s:
95
mock_s.return_value = [{
96
'command_name': 'prepare_image',
97
'command_status': 'SUCCESS'
99
self.assertTrue(self.client.deploy_is_done(self.node))
101
def test_deploy_is_done_empty_response(self):
102
with mock.patch.object(self.client, 'get_commands_status') as mock_s:
103
mock_s.return_value = []
104
self.assertFalse(self.client.deploy_is_done(self.node))
106
def test_deploy_is_done_race(self):
107
with mock.patch.object(self.client, 'get_commands_status') as mock_s:
108
mock_s.return_value = [{
109
'command_name': 'some_other_command',
110
'command_status': 'SUCCESS'
112
self.assertFalse(self.client.deploy_is_done(self.node))
114
def test_deploy_is_done_still_running(self):
115
with mock.patch.object(self.client, 'get_commands_status') as mock_s:
116
mock_s.return_value = [{
117
'command_name': 'prepare_image',
118
'command_status': 'RUNNING'
120
self.assertFalse(self.client.deploy_is_done(self.node))
122
102
@mock.patch('uuid.uuid4', mock.MagicMock(return_value='uuid'))
123
103
def test_prepare_image(self):
124
104
self.client._command = mock.Mock()
151
131
method='standby.prepare_image',
135
@mock.patch('uuid.uuid4', mock.MagicMock(return_value='uuid'))
136
def test_start_iscsi_target(self):
137
self.client._command = mock.Mock()
139
params = {'iqn': iqn}
141
self.client.start_iscsi_target(self.node, iqn)
142
self.client._command.assert_called_once_with(node=self.node,
143
method='iscsi.start_iscsi_target',
147
@mock.patch('uuid.uuid4', mock.MagicMock(return_value='uuid'))
148
def test_install_bootloader(self):
149
self.client._command = mock.Mock()
150
root_uuid = 'fake-root-uuid'
151
efi_system_part_uuid = 'fake-efi-system-part-uuid'
152
params = {'root_uuid': root_uuid,
153
'efi_system_part_uuid': efi_system_part_uuid}
155
self.client.install_bootloader(
156
self.node, root_uuid, efi_system_part_uuid=efi_system_part_uuid)
157
self.client._command.assert_called_once_with(
158
node=self.node, method='image.install_bootloader', params=params,
161
def test_get_clean_steps(self):
162
self.client._command = mock.Mock()
165
'node': self.node.as_dict(),
169
self.client.get_clean_steps(self.node,
171
self.client._command.assert_called_once_with(node=self.node,
172
method='clean.get_clean_steps',
173
params=expected_params,
176
def test_execute_clean_step(self):
177
self.client._command = mock.Mock()
179
step = {'priority': 10, 'step': 'erase_devices', 'interface': 'deploy'}
182
'node': self.node.as_dict(),
184
'clean_version': self.node.driver_internal_info.get(
185
'hardware_manager_version')
187
self.client.execute_clean_step(step,
190
self.client._command.assert_called_once_with(node=self.node,
191
method='clean.execute_clean_step',
192
params=expected_params,