You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2016/02/14 20:07:35 UTC
ambari git commit: AMBARI-14023. Agents should not ask for auto-start
command details if it has the details (smohanty)
Repository: ambari
Updated Branches:
refs/heads/trunk 604040fbf -> 230c1d662
AMBARI-14023. Agents should not ask for auto-start command details if it has the details (smohanty)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/230c1d66
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/230c1d66
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/230c1d66
Branch: refs/heads/trunk
Commit: 230c1d662d5322623e5402fee3f5d766bf985e6f
Parents: 604040f
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Sun Feb 14 11:07:20 2016 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Sun Feb 14 11:07:20 2016 -0800
----------------------------------------------------------------------
.../src/main/python/ambari_agent/ActionQueue.py | 3 +-
.../test/python/ambari_agent/TestActionQueue.py | 59 ++++++++++++++++++++
2 files changed, 61 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/230c1d66/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
index a4c433d..bf7b5d9 100644
--- a/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
+++ b/ambari-agent/src/main/python/ambari_agent/ActionQueue.py
@@ -451,7 +451,8 @@ class ActionQueue(threading.Thread):
if self.controller.recovery_manager.enabled() \
and self.controller.recovery_manager.configured_for_recovery(component):
self.controller.recovery_manager.update_current_status(component, component_status)
- request_execution_cmd = self.controller.recovery_manager.requires_recovery(component)
+ request_execution_cmd = self.controller.recovery_manager.requires_recovery(component) and \
+ not self.controller.recovery_manager.command_exists(component, ActionQueue.EXECUTION_COMMAND)
if component_status_result.has_key('structuredOut'):
component_extra = component_status_result['structuredOut']
http://git-wip-us.apache.org/repos/asf/ambari/blob/230c1d66/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
index f7e2894..3d7acbc 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestActionQueue.py
@@ -682,6 +682,65 @@ class TestActionQueue(TestCase):
self.assertEqual(report['componentStatus'][0], expected)
self.assertTrue(requestComponentStatus_mock.called)
+ @patch.object(RecoveryManager, "command_exists")
+ @patch.object(RecoveryManager, "requires_recovery")
+ @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
+ @patch.object(ActionQueue, "status_update_callback")
+ @patch.object(StackVersionsFileHandler, "read_stack_version")
+ @patch.object(CustomServiceOrchestrator, "requestComponentStatus")
+ @patch.object(CustomServiceOrchestrator, "requestComponentSecurityState")
+ @patch.object(ActionQueue, "execute_command")
+ @patch.object(LiveStatus, "build")
+ @patch.object(CustomServiceOrchestrator, "__init__")
+ def test_execute_status_command_recovery(self, CustomServiceOrchestrator_mock,
+ build_mock, execute_command_mock, requestComponentSecurityState_mock,
+ requestComponentStatus_mock, read_stack_version_mock,
+ status_update_callback, requires_recovery_mock,
+ command_exists_mock):
+ CustomServiceOrchestrator_mock.return_value = None
+ dummy_controller = MagicMock()
+ actionQueue = ActionQueue(AmbariConfig(), dummy_controller)
+
+ build_mock.return_value = {'dummy report': '' }
+ requires_recovery_mock.return_value = True
+ command_exists_mock.return_value = False
+
+ dummy_controller.recovery_manager = RecoveryManager(tempfile.mktemp(), True, False)
+
+ requestComponentStatus_mock.reset_mock()
+ requestComponentStatus_mock.return_value = {'exitcode': 0 }
+
+ requestComponentSecurityState_mock.reset_mock()
+ requestComponentSecurityState_mock.return_value = 'UNKNOWN'
+
+ actionQueue.execute_status_command(self.status_command)
+ report = actionQueue.result()
+ expected = {'dummy report': '',
+ 'securityState' : 'UNKNOWN',
+ 'sendExecCmdDet': 'True'}
+
+ self.assertEqual(len(report['componentStatus']), 1)
+ self.assertEqual(report['componentStatus'][0], expected)
+ self.assertTrue(requestComponentStatus_mock.called)
+
+ requires_recovery_mock.return_value = True
+ command_exists_mock.return_value = True
+ requestComponentStatus_mock.reset_mock()
+ requestComponentStatus_mock.return_value = {'exitcode': 0 }
+
+ requestComponentSecurityState_mock.reset_mock()
+ requestComponentSecurityState_mock.return_value = 'UNKNOWN'
+
+ actionQueue.execute_status_command(self.status_command)
+ report = actionQueue.result()
+ expected = {'dummy report': '',
+ 'securityState' : 'UNKNOWN',
+ 'sendExecCmdDet': 'False'}
+
+ self.assertEqual(len(report['componentStatus']), 1)
+ self.assertEqual(report['componentStatus'][0], expected)
+ self.assertTrue(requestComponentStatus_mock.called)
+
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
@patch.object(ActionQueue, "status_update_callback")
@patch.object(StackVersionsFileHandler, "read_stack_version")