Fix argument error in overcloud_deploy._heat_deploy
We were missing the 'target state' argument to the utils.set_nodes_state call in the overcloud_deploy._heat_deploy method. This patch also updates the tests to use 'autospec=True' for all of the mocks. That would have caught this error. Change-Id: Ib8b7d4bec4861e98615a127d400da2ae79410102
This commit is contained in:
parent
57ad4f4534
commit
e63403e935
rdomanager_oscplugin
tests/v1
baremetal
overcloud_deploy
overcloud_image
overcloud_scale
undercloud
v1
@ -93,7 +93,7 @@ pxe_ssh,192.168.122.1,root,"KEY2",00:7c:ef:3d:eb:60""")
|
||||
os.unlink(self.json_file.name)
|
||||
os.unlink(self.instack_json.name)
|
||||
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes')
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes', autospec=True)
|
||||
def test_json_import(self, mock_register_nodes):
|
||||
|
||||
arglist = [self.json_file.name, '--json', '-s', 'http://localhost']
|
||||
@ -128,7 +128,7 @@ pxe_ssh,192.168.122.1,root,"KEY2",00:7c:ef:3d:eb:60""")
|
||||
client=self.app.client_manager.rdomanager_oscplugin.baremetal(),
|
||||
keystone_client=None)
|
||||
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes')
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes', autospec=True)
|
||||
def test_instack_json_import(self, mock_register_nodes):
|
||||
|
||||
arglist = [self.instack_json.name, '--json', '-s', 'http://localhost']
|
||||
@ -163,7 +163,7 @@ pxe_ssh,192.168.122.1,root,"KEY2",00:7c:ef:3d:eb:60""")
|
||||
client=self.app.client_manager.rdomanager_oscplugin.baremetal(),
|
||||
keystone_client=None)
|
||||
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes')
|
||||
@mock.patch('os_cloud_config.nodes.register_all_nodes', autospec=True)
|
||||
def test_csv_import(self, mock_register_nodes):
|
||||
|
||||
arglist = [self.csv_file.name, '--csv', '-s', 'http://localhost']
|
||||
@ -206,7 +206,7 @@ class TestStartBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
# Get the command object to test
|
||||
self.cmd = baremetal.StartBaremetalIntrospectionBulk(self.app, None)
|
||||
|
||||
@mock.patch('ironic_discoverd.client.introspect')
|
||||
@mock.patch('ironic_discoverd.client.introspect', autospec=True)
|
||||
def test_introspect_bulk_one(self, discoverd_mock):
|
||||
|
||||
client = self.app.client_manager.rdomanager_oscplugin.baremetal()
|
||||
@ -220,10 +220,12 @@ class TestStartBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
discoverd_mock.assert_called_once_with(
|
||||
'ABCDEFGH', base_url=None, auth_token='TOKEN')
|
||||
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_node_discovery')
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_provision_state')
|
||||
@mock.patch('ironic_discoverd.client.get_status')
|
||||
@mock.patch('ironic_discoverd.client.introspect')
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_node_discovery',
|
||||
autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_provision_state',
|
||||
autospec=True)
|
||||
@mock.patch('ironic_discoverd.client.get_status', autospec=True)
|
||||
@mock.patch('ironic_discoverd.client.introspect', autospec=True)
|
||||
def test_introspect_bulk(self, introspect_mock, get_status_mock,
|
||||
wait_for_state_mock, wait_for_discover_mock):
|
||||
|
||||
@ -261,10 +263,12 @@ class TestStartBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
wait_for_discover_mock.assert_called_once_with(
|
||||
discoverd_client, 'TOKEN', None, [])
|
||||
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_node_discovery')
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_provision_state')
|
||||
@mock.patch('ironic_discoverd.client.get_status')
|
||||
@mock.patch('ironic_discoverd.client.introspect')
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_node_discovery',
|
||||
autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_provision_state',
|
||||
autospec=True)
|
||||
@mock.patch('ironic_discoverd.client.get_status', autospec=True)
|
||||
@mock.patch('ironic_discoverd.client.introspect', autospec=True)
|
||||
def test_introspect_bulk_no_poll(self, introspect_mock, get_status_mock,
|
||||
wait_for_state_mock,
|
||||
wait_for_discover_mock):
|
||||
@ -311,7 +315,7 @@ class TestStatusBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
# Get the command object to test
|
||||
self.cmd = baremetal.StatusBaremetalIntrospectionBulk(self.app, None)
|
||||
|
||||
@mock.patch('ironic_discoverd.client.get_status')
|
||||
@mock.patch('ironic_discoverd.client.get_status', autospec=True)
|
||||
def test_status_bulk_one(self, discoverd_mock):
|
||||
|
||||
client = self.app.client_manager.rdomanager_oscplugin.baremetal()
|
||||
@ -333,7 +337,7 @@ class TestStatusBaremetalIntrospectionBulk(fakes.TestBaremetal):
|
||||
('Node UUID', 'Finished', 'Error'),
|
||||
[('ABCDEFGH', False, None)]))
|
||||
|
||||
@mock.patch('ironic_discoverd.client.get_status')
|
||||
@mock.patch('ironic_discoverd.client.get_status', autospec=True)
|
||||
def test_status_bulk(self, discoverd_mock):
|
||||
|
||||
client = self.app.client_manager.rdomanager_oscplugin.baremetal()
|
||||
@ -374,7 +378,7 @@ class TestConfigureBaremetalBoot(fakes.TestBaremetal):
|
||||
# Get the command object to test
|
||||
self.cmd = baremetal.ConfigureBaremetalBoot(self.app, None)
|
||||
|
||||
@mock.patch('openstackclient.common.utils.find_resource')
|
||||
@mock.patch('openstackclient.common.utils.find_resource', autospec=True)
|
||||
def test_configure_boot(self, find_resource_mock):
|
||||
|
||||
find_resource_mock.return_value = mock.Mock(id="IDIDID")
|
||||
@ -413,7 +417,7 @@ class TestConfigureBaremetalBoot(fakes.TestBaremetal):
|
||||
}])
|
||||
])
|
||||
|
||||
@mock.patch('openstackclient.common.utils.find_resource')
|
||||
@mock.patch('openstackclient.common.utils.find_resource', autospec=True)
|
||||
@mock.patch.object(baremetal.ConfigureBaremetalBoot, 'sleep_time',
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=0)
|
||||
@ -436,7 +440,7 @@ class TestConfigureBaremetalBoot(fakes.TestBaremetal):
|
||||
self.assertEqual(2, bm_client.node.get.call_count)
|
||||
self.assertEqual(1, bm_client.node.update.call_count)
|
||||
|
||||
@mock.patch('openstackclient.common.utils.find_resource')
|
||||
@mock.patch('openstackclient.common.utils.find_resource', autospec=True)
|
||||
@mock.patch.object(baremetal.ConfigureBaremetalBoot, 'sleep_time',
|
||||
new_callable=mock.PropertyMock,
|
||||
return_value=0)
|
||||
|
@ -28,17 +28,22 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
|
||||
self.cmd = overcloud_deploy.DeployOvercloud(self.app, None)
|
||||
|
||||
@mock.patch('time.sleep', return_value=None)
|
||||
@mock.patch('os_cloud_config.keystone.initialize')
|
||||
@mock.patch('rdomanager_oscplugin.utils.remove_known_hosts')
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_stack_ready')
|
||||
@mock.patch('rdomanager_oscplugin.utils.set_nodes_state')
|
||||
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.remove_known_hosts', autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.wait_for_stack_ready',
|
||||
autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.set_nodes_state', autospec=True)
|
||||
@mock.patch('heatclient.common.template_utils.'
|
||||
'process_multiple_environments_and_files')
|
||||
@mock.patch('heatclient.common.template_utils.get_template_contents')
|
||||
@mock.patch('os_cloud_config.keystone_pki.generate_certs_into_json')
|
||||
@mock.patch('rdomanager_oscplugin.utils.create_environment_file')
|
||||
@mock.patch('rdomanager_oscplugin.utils.get_hiera_key')
|
||||
@mock.patch('rdomanager_oscplugin.utils.check_hypervisor_stats')
|
||||
'process_multiple_environments_and_files', autospec=True)
|
||||
@mock.patch('heatclient.common.template_utils.get_template_contents',
|
||||
autospec=True)
|
||||
@mock.patch('os_cloud_config.keystone_pki.generate_certs_into_json',
|
||||
autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.create_environment_file',
|
||||
autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.get_hiera_key', autospec=True)
|
||||
@mock.patch('rdomanager_oscplugin.utils.check_hypervisor_stats',
|
||||
autospec=True)
|
||||
def test_tht_deploy(self, mock_check_hypervisor_stats, mock_get_key,
|
||||
mock_create_env, generate_certs_mock,
|
||||
mock_get_templte_contents, mock_process_multiple_env,
|
||||
|
@ -30,7 +30,7 @@ class TestOvercloudImageBuild(TestPluginV1):
|
||||
self.cmd._ramdisk_image_create = mock.Mock()
|
||||
|
||||
@mock.patch.object(overcloud_image.BuildOvercloudImage,
|
||||
'_build_image_fedora_user')
|
||||
'_build_image_fedora_user', autospec=True)
|
||||
def test_overcloud_image_build_all(self, mock_fedora_user):
|
||||
arglist = ['--all']
|
||||
verifylist = [('all', True)]
|
||||
@ -43,10 +43,10 @@ class TestOvercloudImageBuild(TestPluginV1):
|
||||
self.assertEqual(1, self.cmd._disk_image_create.call_count)
|
||||
self.assertEqual(1, mock_fedora_user.call_count)
|
||||
|
||||
@mock.patch('subprocess.call')
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('subprocess.call', autospec=True)
|
||||
@mock.patch('os.path.isfile', autospec=True)
|
||||
@mock.patch('os.chmod')
|
||||
@mock.patch('requests.get')
|
||||
@mock.patch('requests.get', autospec=True)
|
||||
def test_overcloud_image_build_fedora_user_no_cache(
|
||||
self,
|
||||
mock_requests_get,
|
||||
@ -81,7 +81,7 @@ class TestOvercloudImageBuild(TestPluginV1):
|
||||
mock_open_context.assert_has_calls(
|
||||
[mock.call('fedora-user.qcow2', 'wb')])
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('os.path.isfile', autospec=True)
|
||||
def test_overcloud_image_build_overcloud_full(
|
||||
self,
|
||||
mock_os_path_isfile):
|
||||
@ -115,7 +115,7 @@ class TestOvercloudImageBuild(TestPluginV1):
|
||||
"undercloud-package-install "
|
||||
"pip-and-virtualenv-override 2>&1 | tee dib-overcloud-full.log")
|
||||
|
||||
@mock.patch('os.path.isfile')
|
||||
@mock.patch('os.path.isfile', autospec=True)
|
||||
def test_overcloud_image_build_deploy_ramdisk(
|
||||
self,
|
||||
mock_os_path_isfile):
|
||||
@ -158,7 +158,7 @@ class TestOvercloudImageCreate(TestPluginV1):
|
||||
self.cmd._read_image_file_pointer = mock.Mock(return_value=b'IMGDATA')
|
||||
self.cmd._check_file_exists = mock.Mock(return_value=True)
|
||||
|
||||
@mock.patch('subprocess.call')
|
||||
@mock.patch('subprocess.call', autospec=True)
|
||||
def test_overcloud_create_images(self, mock_subprocess_call):
|
||||
parsed_args = self.check_parser(self.cmd, [], [])
|
||||
|
||||
|
@ -27,6 +27,8 @@ class TestOvercloudScale(fakes.TestOvercloudScale):
|
||||
# Get the command object to test
|
||||
self.cmd = overcloud_scale.ScaleOvercloud(self.app, None)
|
||||
|
||||
# TODO(someone): This test does not pass with autospec=True, it should
|
||||
# probably be fixed so that it can pass with that.
|
||||
@mock.patch('tripleo_common.scale.ScaleManager')
|
||||
def test_scale_out(self, scale_manager):
|
||||
argslist = ['-r', 'Compute-1', '-n', '2', 'overcloud', 'overcloud']
|
||||
|
@ -35,7 +35,7 @@ class TestUndercloudInstall(TestPluginV1):
|
||||
# Get the command object to test
|
||||
self.cmd = undercloud.InstallPlugin(self.app, None)
|
||||
|
||||
@mock.patch('subprocess.check_call')
|
||||
@mock.patch('subprocess.check_call', autospec=True)
|
||||
def test_undercloud_install(self, mock_subprocess):
|
||||
arglist = []
|
||||
verifylist = []
|
||||
|
@ -160,7 +160,7 @@ class DeployOvercloud(command.Command):
|
||||
self.log.debug("Verifying that Baremetal nodes to available or active")
|
||||
utils.set_nodes_state(
|
||||
baremetal_client, baremetal_client.node.list(),
|
||||
'provide', skipped_states=("available", "active"))
|
||||
'provide', 'available', skipped_states=("available", "active"))
|
||||
|
||||
stack_name = "overcloud"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user