More tests for overcloud deploy

Change-Id: I62317c6c5b2e85a3b3852bd1cdb757ba6931b041
This commit is contained in:
Lennart Regebro 2015-12-04 16:10:41 +01:00
parent c2ad6940c2
commit 95ca05cd41
5 changed files with 128 additions and 7 deletions

View File

@ -8,7 +8,7 @@ cliff>=1.15.0 # Apache-2.0
ipaddress>=1.0.7;python_version<'3.3'
passlib>=1.6
python-ironic-inspector-client>=1.3.0
os-cloud-config
# os-cloud-config>=0.3.1
python-heatclient>=0.6.0
python-ironicclient>=0.8.0
python-openstackclient>=2.0.0
@ -16,3 +16,6 @@ six>=1.9.0
# tripleo-common lib is not yet on PyPi
-e git://github.com/openstack/tripleo-common.git#egg=tripleo_common
# This currently needs a development version of os_cloud_config
-e git://github.com/openstack/os-cloud-config.git#egg=os_cloud_config

View File

@ -36,7 +36,7 @@ def create_tht_stack(**kwargs):
'stack_name': 'overcloud',
'outputs': [{
'output_key': 'KeystoneURL',
'output_value': 'Overcloud endpoint',
'output_value': 'http://0.0.0.0:8000',
}]
}
stack.update(kwargs)
@ -69,3 +69,4 @@ class TestDeployOvercloud(utils.TestCommand):
self.app.client_manager.network = mock.Mock()
self.app.client_manager.compute = mock.Mock()
self.app.client_manager.identity = mock.Mock()
self.app.client_manager.image = mock.Mock()

View File

@ -217,12 +217,14 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
'_validate_args')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_create_parameters_env')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.generate_overcloud_passwords')
@mock.patch('tripleoclient.utils.create_overcloudrc')
@mock.patch('os_cloud_config.utils.clients.get_nova_bm_client',
autospec=True)
@mock.patch('os_cloud_config.utils.clients.get_keystone_client',
autospec=True)
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@ -251,10 +253,10 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
wait_for_stack_ready_mock,
mock_remove_known_hosts, mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_get_keystone_client, mock_get_nova_bm_client,
mock_create_overcloudrc,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_deploy_postconfig,
mock_create_parameters_env, mock_validate_args,
mock_breakpoints_cleanup):
@ -383,6 +385,14 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_validate_args.assert_called_once_with(parsed_args)
mock_remove_known_hosts.assert_called_once_with('0.0.0.0')
mock_get_keystone_client.assert_called_once_with('admin', 'password',
'admin',
'http://0.0.0.0:8000')
mock_get_nova_bm_client.assert_called_once_with('admin', 'password',
'admin',
'http://0.0.0.0:8000')
@mock.patch("heatclient.common.event_utils.get_events")
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
@ -434,7 +444,6 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
clients = self.app.client_manager
orchestration_client = clients.tripleoclient.orchestration
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
mock_events.return_value = []
mock_check_hypervisor_stats.return_value = {
@ -629,6 +638,98 @@ class TestDeployOvercloud(fakes.TestDeployOvercloud):
mock_create_tempest_deployer_input.assert_called_with()
@mock.patch("heatclient.common.event_utils.get_events")
@mock.patch('tripleo_common.update.add_breakpoints_cleanup_into_env')
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_deploy_postconfig')
@mock.patch('tripleoclient.utils.create_tempest_deployer_input',
autospec=True)
@mock.patch('tripleoclient.utils.generate_overcloud_passwords')
@mock.patch('tripleoclient.utils.create_overcloudrc')
@mock.patch('os_cloud_config.keystone.setup_endpoints', autospec=True)
@mock.patch('time.sleep', return_value=None)
@mock.patch('os_cloud_config.keystone.initialize', autospec=True)
@mock.patch('tripleoclient.utils.remove_known_hosts', autospec=True)
@mock.patch('tripleoclient.utils.wait_for_stack_ready',
autospec=True)
@mock.patch('heatclient.common.template_utils.'
'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('tripleoclient.utils.create_environment_file',
autospec=True)
@mock.patch('tripleoclient.utils.get_config_value', autospec=True)
@mock.patch('tripleoclient.utils.check_hypervisor_stats',
autospec=True)
def test_deploy_rhel_reg(self, mock_check_hypervisor_stats,
mock_get_key,
mock_create_env, generate_certs_mock,
mock_get_templte_contents,
mock_process_multiple_env,
wait_for_stack_ready_mock,
mock_remove_known_hosts,
mock_keystone_initialize,
mock_sleep, mock_setup_endpoints,
mock_create_overcloudrc,
mock_generate_overcloud_passwords,
mock_create_tempest_deployer_input,
mock_deploy_postconfig,
mock_breakpoints_cleanup,
mock_events):
arglist = ['--templates', '--rhel-reg',
'--reg-sat-url', 'https://example.com',
'--reg-method', 'satellite', '--reg-org', '123456789',
'--reg-activation-key', 'super-awesome-key']
verifylist = [
('templates', '/usr/share/openstack-tripleo-heat-templates/'),
('rhel_reg', True),
('reg_sat_url', 'https://example.com'),
('reg_method', 'satellite'),
('reg_org', '123456789'),
('reg_activation_key', 'super-awesome-key')
]
mock_generate_overcloud_passwords.return_value = self._get_passwords()
mock_process_multiple_env.return_value = [{}, "env"]
mock_get_templte_contents.return_value = [{}, "template"]
wait_for_stack_ready_mock.return_value = True
clients = self.app.client_manager
orchestration_client = clients.tripleoclient.orchestration
orchestration_client.stacks.get.return_value = fakes.create_tht_stack()
mock_events.return_value = []
mock_check_hypervisor_stats.return_value = {
'count': 4,
'memory_mb': 4096,
'vcpus': 8,
}
mock_get_key.return_value = "PASSWORD"
clients.network.api.find_attr.return_value = {
"id": "network id"
}
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
baremetal = clients.tripleoclient.baremetal
baremetal.node.list.return_value = range(10)
result = self.cmd.take_action(parsed_args)
self.assertTrue(result)
args, kwargs = mock_process_multiple_env.call_args
self.assertIn(
'/usr/share/openstack-tripleo-heat-templates/extraconfig/post_dep'
'loy/rhel-registration/rhel-registration-resource-registry.yaml',
args[0])
self.assertIn(
'/usr/share/openstack-tripleo-heat-templates/extraconfig/post_dep'
'loy/rhel-registration/environment-rhel-registration.yaml',
args[0])
def test_validate_args_correct(self):
arglist = ['--templates',
'--neutron-network-type', 'nettype',

View File

@ -55,6 +55,22 @@ class TestDeployValidators(fakes.TestDeployOvercloud):
mock_maint_nodes.assert_called_once_with(detail=True,
maintenance=False)
def test_image_ids(self):
image_client = self.app.client_manager.image
image_client.images = {}
image_ids = self.cmd._image_ids()
image_client.images = {
'bm-deploy-kernel':
mock.Mock(id='fb7a98fb-acb9-43ec-9b93-525d1286f9d8'),
'bm-deploy-ramdisk':
mock.Mock(id='8558de2e-1b72-4654-8ba9-cceb89e9194e'),
}
image_ids = self.cmd._image_ids()
self.assertEqual(image_ids, ('fb7a98fb-acb9-43ec-9b93-525d1286f9d8',
'8558de2e-1b72-4654-8ba9-cceb89e9194e'))
@mock.patch('tripleoclient.v1.overcloud_deploy.DeployOvercloud.'
'_image_ids',
return_value=('fb7a98fb-acb9-43ec-9b93-525d1286f9d8',

View File

@ -442,7 +442,7 @@ class DeployOvercloud(command.Command):
if not tls_enabled:
# NOTE(bcrochet): Bad hack. Remove the ssl_port info from the
# os_cloud_config.SERVICES dictionary
for service_name, data in keystone.SERVICES.iteritems():
for service_name, data in keystone.SERVICES.items():
data.pop('ssl_port', None)
services = {}