Repository: ambari Updated Branches: refs/heads/branch-2.5 98b2b9124 -> 379b95b63
AMBARI-21340. Pending status commands during long running execution commands are not removed (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/379b95b6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/379b95b6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/379b95b6 Branch: refs/heads/branch-2.5 Commit: 379b95b6351e5165232741d828ef651a46376415 Parents: 98b2b91 Author: Andrew Onishuk <[email protected]> Authored: Mon Jun 26 15:27:13 2017 +0300 Committer: Andrew Onishuk <[email protected]> Committed: Mon Jun 26 15:27:13 2017 +0300 ---------------------------------------------------------------------- .../test/python/ambari_agent/TestHeartbeat.py | 40 ++++++++++++++++++++ 1 file changed, 40 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/379b95b6/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py ---------------------------------------------------------------------- diff --git a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py index de07743..811cf5a 100644 --- a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py +++ b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py @@ -26,6 +26,7 @@ import StringIO import sys import multiprocessing from ambari_agent.RecoveryManager import RecoveryManager +from ambari_agent.StatusCommandsExecutor import SingleProcessStatusCommandsExecutor with patch("platform.linux_distribution", return_value = ('Suse','11','Final')): @@ -231,6 +232,45 @@ class TestHeartbeat(TestCase): self.assertFalse(args[2]) self.assertFalse(args[1]) + @patch("subprocess.Popen") + @patch.object(Hardware, "_chk_writable_mount", new = MagicMock(return_value=True)) + @patch.object(HostInfoLinux, 'register') + def test_status_commands_does_not_stack_up(self, register_mock, Popen_mock): + config = AmbariConfig.AmbariConfig() + config.set('agent', 'prefix', 'tmp') + config.set('agent', 'cache_dir', "/var/lib/ambari-agent/cache") + config.set('agent', 'tolerate_download_failures', "true") + + dummy_controller = MagicMock() + actionQueue = ActionQueue(config, dummy_controller) + + dummy_controller.statusCommandsExecutor = SingleProcessStatusCommandsExecutor(config, actionQueue) + + statusCommands = [{ + "serviceName" : 'HDFS', + "commandType" : "STATUS_COMMAND", + "clusterName" : "c1", + "componentName" : "DATANODE", + "role" : "DATANODE", + 'configurations':{'cluster-env' : {}} + }, + { + "serviceName" : 'HDFS', + "commandType" : "STATUS_COMMAND", + "clusterName" : "c1", + "componentName" : "NAMENODE", + "role" : "NAMENODE", + 'configurations':{'cluster-env' : {}} + } + ] + + # add commands ten times + for i in range(10): + actionQueue.put_status(statusCommands) + + # status commands should not stack up. Size should be 2 not 20. + self.assertEquals(len(dummy_controller.statusCommandsExecutor.statusCommandQueue.queue), 2) + @patch("subprocess.Popen") @patch.object(Hardware, "_chk_writable_mount", new = MagicMock(return_value=True))
