def test_show_full_history(self, print_mock): self.m_history_api = self.m_request.get( '/api/v1/transactions/1/deployment_history/?' 'nodes=&' 'statuses=&' 'tasks_names=', json=utils.get_fake_deployment_history()) self.execute(['fuel', 'deployment-tasks', '--tid', '1']) print_mock.assert_called_once_with( utils.get_fake_deployment_history(convert_legacy_fields=True), format_table( utils.get_fake_deployment_history(convert_legacy_fields=True), acceptable_keys=DeploymentHistoryClient.history_records_keys))
def test_show_full_history(self, print_mock): self.m_history_api = self.m_request.get( '/api/v1/transactions/1/deployment_history/?' 'nodes=&' 'statuses=&' 'tasks_names=', json=utils.get_fake_deployment_history()) self.execute( ['fuel', 'deployment-tasks', '--tid', '1'] ) print_mock.assert_called_once_with( utils.get_fake_deployment_history(convert_legacy_fields=True), format_table( utils.get_fake_deployment_history(convert_legacy_fields=True), acceptable_keys=DeploymentHistoryClient.history_records_keys))
def test_deployment_history_parameters(self): matcher = self.m_request.get( self.get_url( nodes='1,2', statuses='ready,error,pending', tasks_names='controller-remaining-tasks,' 'ironic-compute,pending-task' ), json=utils.get_fake_deployment_history(add_task_data=True), ) tasks_after_facade = self.client.get_all( transaction_id=self.transaction_id, nodes=['1', '2'], statuses=['ready', 'error', 'pending'], tasks_names=['controller-remaining-tasks', 'ironic-compute', 'pending-task'], show_parameters=True ) self.assertTrue(matcher.called) self.assertItemsEqual( utils.get_fake_deployment_history_w_params(), tasks_after_facade)
def setUp(self): super(TestDeploymentHistoryFacade, self).setUp() self.version = 'v1' self.transaction_id = '1' self.res_uri = '/api/{0}/transactions/{1}'\ '/deployment_history/' \ ''.format(self.version, self.transaction_id) self.fake_history = utils.get_fake_deployment_history() self.client = fuelclient.get_client('deployment_history', self.version)
def test_deployment_history_include_summary(self): fake_history = utils.get_fake_deployment_history(include_summary=True) matcher = self.m_request.get( self.get_url(nodes='1,2', statuses='ready,error,pending', tasks_names='controller-remaining-tasks,' 'ironic-compute,pending-task') + '&include_summary=1', json=fake_history) tasks_after_facade = self.client.get_all( transaction_id=self.transaction_id, nodes=['1', '2'], statuses=['ready', 'error', 'pending'], tasks_names=[ 'controller-remaining-tasks', 'ironic-compute', 'pending-task' ], include_summary=True, show_parameters=False) self.assertTrue(matcher.called) self.assertItemsEqual( utils.get_fake_deployment_history(convert_legacy_fields=True, include_summary=True), tasks_after_facade)
def test_task_history_show(self): task_id = 42 args = 'task history show {task_id} '.format(task_id=task_id) self.m_client.get_all.return_value = \ utils.get_fake_deployment_history() self.exec_command(args) self.m_get_client.assert_called_once_with('deployment_history', mock.ANY) self.m_client.get_all.assert_called_once_with(transaction_id=task_id, nodes=None, statuses=None, tasks_names=None, show_parameters=False)
def test_show_tasks_history_with_parameters(self, print_mock): tasks_after_facade = [{ 'task_name': 'controller-remaining-tasks', 'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/' 'modules/osnailyfacter/modular/globals/' 'globals.pp,\n puppet_modules: /etc/' 'puppet/modules, timeout: 3600}\nrole: ' '[controller]\ntype: puppet\nversion: 2.0.0' '\n', 'status_by_node': '1 - ready - 2016-03-25T17:22:10 - ' '2016-03-25T17:22:30\n' '2 - ready - 2016-03-25T17:22:10 - ' '2016-03-25T17:22:30' }, { 'task_name': 'pending-task', 'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/' 'modules/osnailyfacter/modular/globals/' 'globals.pp,\n puppet_modules: /etc/puppet' '/modules, timeout: 3600}\nrole: ' '[controller]\ntype: puppet\nversion: 2.0.0' '\n', 'status_by_node': '1 - pending - not started - not ended\n' '2 - pending - not started - not ended' }] self.m_history_api = self.m_request.get( '/api/v1/transactions/1/deployment_history/?' 'nodes=&' 'statuses=&' 'tasks_names=controller-remaining-tasks,pending-task', json=utils.get_fake_deployment_history(add_task_data=True)) self.execute([ 'fuel', 'deployment-tasks', '--tid', '1', '--task-name', 'controller-remaining-tasks,pending-task', '--node', '1,2', '--show-parameters' ]) print_mock.assert_called_once_with( tasks_after_facade, format_table( tasks_after_facade, acceptable_keys=DeploymentHistoryClient.tasks_records_keys))
def test_show_tasks_history_with_parameters(self, print_mock): tasks_after_facade = [ { 'task_name': 'controller-remaining-tasks', 'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/' 'modules/osnailyfacter/modular/globals/' 'globals.pp,\n puppet_modules: /etc/' 'puppet/modules, timeout: 3600}\nrole: ' '[controller]\ntype: puppet\nversion: 2.0.0' '\n', 'status_by_node': '1 - ready - 2016-03-25T17:22:10 - ' '2016-03-25T17:22:30\n' '2 - ready - 2016-03-25T17:22:10 - ' '2016-03-25T17:22:30' }, { 'task_name': 'pending-task', 'task_parameters': 'parameters: {puppet_manifest: /etc/puppet/' 'modules/osnailyfacter/modular/globals/' 'globals.pp,\n puppet_modules: /etc/puppet' '/modules, timeout: 3600}\nrole: ' '[controller]\ntype: puppet\nversion: 2.0.0' '\n', 'status_by_node': '1 - pending - not started - not ended\n' '2 - pending - not started - not ended' } ] self.m_history_api = self.m_request.get( '/api/v1/transactions/1/deployment_history/?' 'nodes=&' 'statuses=&' 'tasks_names=controller-remaining-tasks,pending-task', json=utils.get_fake_deployment_history(add_task_data=True)) self.execute( ['fuel', 'deployment-tasks', '--tid', '1', '--task-name', 'controller-remaining-tasks,pending-task', '--node', '1,2', '--show-parameters'] ) print_mock.assert_called_once_with( tasks_after_facade, format_table( tasks_after_facade, acceptable_keys=DeploymentHistoryClient.tasks_records_keys))
def test_task_history_parameters(self): task_id = 42 args = 'task history show {task_id} ' \ '--tasks-names task1 task2 ' \ '--statuses ready error --nodes 1 2 ' \ '--show-parameters'.format(task_id=task_id) self.m_client.get_all.return_value = \ utils.get_fake_deployment_history() self.exec_command(args) self.m_get_client.assert_called_once_with('deployment_history', mock.ANY) self.m_client.get_all.assert_called_once_with( transaction_id=task_id, nodes=['1', '2'], statuses=['ready', 'error'], tasks_names=['task1', 'task2'], show_parameters=True)
def test_task_history_parameters(self): task_id = 42 args = 'task history show {task_id} ' \ '--tasks-names task1 task2 ' \ '--statuses ready error --nodes 1 2 ' \ '--show-parameters'.format(task_id=task_id) self.m_client.get_all.return_value = \ utils.get_fake_deployment_history() self.exec_command(args) self.m_get_client.assert_called_once_with('deployment_history', mock.ANY) self.m_client.get_all.assert_called_once_with( transaction_id=task_id, nodes=['1', '2'], statuses=['ready', 'error'], tasks_names=['task1', 'task2'], include_summary=False, show_parameters=True)
def test_deployment_history_parameters(self): matcher = self.m_request.get( self.get_url(nodes='1,2', statuses='ready,error,pending', tasks_names='controller-remaining-tasks,' 'ironic-compute,pending-task'), json=utils.get_fake_deployment_history(add_task_data=True), ) tasks_after_facade = self.client.get_all( transaction_id=self.transaction_id, nodes=['1', '2'], statuses=['ready', 'error', 'pending'], tasks_names=[ 'controller-remaining-tasks', 'ironic-compute', 'pending-task' ], show_parameters=True) self.assertTrue(matcher.called) self.assertItemsEqual(utils.get_fake_deployment_history_w_params(), tasks_after_facade)