def test_update_outputs(self): mesos_def = tdef.UbuntuMesosTemplateDefinition() expected_api_address = 'updated_address' expected_node_addresses = ['ex_slave', 'address'] expected_master_addresses = ['ex_master', 'address'] outputs = [ {"output_value": expected_api_address, "description": "No description given", "output_key": "api_address"}, {"output_value": ['any', 'output'], "description": "No description given", "output_key": "mesos_master_private"}, {"output_value": expected_master_addresses, "description": "No description given", "output_key": "mesos_master"}, {"output_value": ['any', 'output'], "description": "No description given", "output_key": "mesos_slaves_private"}, {"output_value": expected_node_addresses, "description": "No description given", "output_key": "mesos_slaves"}, ] mock_stack = mock.MagicMock() mock_stack.to_dict.return_value = {'outputs': outputs} mock_bay = mock.MagicMock() mock_baymodel = mock.MagicMock() mesos_def.update_outputs(mock_stack, mock_baymodel, mock_bay) self.assertEqual(expected_api_address, mock_bay.api_address) self.assertEqual(expected_node_addresses, mock_bay.node_addresses) self.assertEqual(expected_master_addresses, mock_bay.master_addresses)
def test_mesos_get_heat_param(self): mesos_def = tdef.UbuntuMesosTemplateDefinition() heat_param = mesos_def.get_heat_param(bay_attr='node_count') self.assertEqual('number_of_slaves', heat_param) heat_param = mesos_def.get_heat_param(bay_attr='master_count') self.assertEqual('number_of_masters', heat_param)
def test_mesos_get_params(self, mock_get_output, mock_get_params, mock_osc_class): mock_context = mock.MagicMock() mock_context.auth_url = 'http://192.168.10.10:5000/v3' mock_context.user_name = 'mesos_user' mock_context.tenant = 'admin' mock_context.domain_name = 'domainname' mock_baymodel = mock.MagicMock() mock_baymodel.tls_disabled = False rexray_preempt = mock_baymodel.labels.get('rexray_preempt') mesos_slave_isolation = mock_baymodel.labels.get( 'mesos_slave_isolation') mesos_slave_work_dir = mock_baymodel.labels.get('mesos_slave_work_dir') mesos_slave_image_providers = mock_baymodel.labels.get( 'image_providers') mesos_slave_executor_env_variables = mock_baymodel.labels.get( 'mesos_slave_executor_env_variables') mock_bay = mock.MagicMock() mock_bay.uuid = '5d12f6fd-a196-4bf0-ae4c-1f639a523a52' del mock_bay.stack_id mock_osc = mock.MagicMock() mock_osc.cinder_region_name.return_value = 'RegionOne' mock_osc_class.return_value = mock_osc mesos_def = tdef.UbuntuMesosTemplateDefinition() mesos_def.get_params(mock_context, mock_baymodel, mock_bay) expected_kwargs = { 'extra_params': { 'region_name': mock_osc.cinder_region_name.return_value, 'auth_url': 'http://192.168.10.10:5000/v3', 'username': '******', 'tenant_name': 'admin', 'domain_name': 'domainname', 'rexray_preempt': rexray_preempt, 'mesos_slave_isolation': mesos_slave_isolation, 'mesos_slave_work_dir': mesos_slave_work_dir, 'mesos_slave_executor_env_variables': mesos_slave_executor_env_variables, 'mesos_slave_image_providers': mesos_slave_image_providers } } mock_get_params.assert_called_once_with(mock_context, mock_baymodel, mock_bay, **expected_kwargs)
def test_mesos_get_heat_param(self): k8s_def = tdef.UbuntuMesosTemplateDefinition() heat_param = k8s_def.get_heat_param(bay_attr='node_count') self.assertEqual(heat_param, 'number_of_slaves')