Repository: ambari Updated Branches: refs/heads/trunk 38690dd42 -> c1d73a614
AMBARI-5111. Host confirmation failed on suse.(vbrodetskyi) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c1d73a61 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c1d73a61 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c1d73a61 Branch: refs/heads/trunk Commit: c1d73a6148ee1969aa45841b8e9aa0534c7acdf6 Parents: 38690dd Author: Vitaly Brodetskyi <[email protected]> Authored: Mon Mar 17 19:05:40 2014 +0200 Committer: Vitaly Brodetskyi <[email protected]> Committed: Mon Mar 17 19:05:53 2014 +0200 ---------------------------------------------------------------------- ambari-server/src/main/python/setupAgent.py | 3 +++ ambari-server/src/test/python/TestSetupAgent.py | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c1d73a61/ambari-server/src/main/python/setupAgent.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/setupAgent.py b/ambari-server/src/main/python/setupAgent.py index 9a4eaa9..69f357a 100755 --- a/ambari-server/src/main/python/setupAgent.py +++ b/ambari-server/src/main/python/setupAgent.py @@ -68,6 +68,9 @@ def runAgent(passPhrase, expected_hostname): os.environ[AMBARI_PASSPHRASE_VAR] = passPhrase agent_retcode = subprocess.call("/usr/sbin/ambari-agent restart --expected-hostname=" +\ expected_hostname, shell=True) + # need this, because, very rarely, + # main.py(ambari-agent) starts a bit later then it should be started + time.sleep(1) try: ret = execOsCommand(["tail", "-20", "/var/log/ambari-agent/ambari-agent.log"]) try: http://git-wip-us.apache.org/repos/asf/ambari/blob/c1d73a61/ambari-server/src/test/python/TestSetupAgent.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestSetupAgent.py b/ambari-server/src/test/python/TestSetupAgent.py index 7846220..b9c6056 100644 --- a/ambari-server/src/test/python/TestSetupAgent.py +++ b/ambari-server/src/test/python/TestSetupAgent.py @@ -55,7 +55,8 @@ class TestSetupAgent(TestCase): @patch.object(setup_agent, 'execOsCommand') @patch("os.environ") @patch("subprocess.call") - def test_runAgent(self, call_mock, environ_mock, execOsCommand_mock): + @patch("time.sleep") + def test_runAgent(self, sleep_mock, call_mock, environ_mock, execOsCommand_mock): expected_hostname = "test.hst" passphrase = "passphrase" call_mock.return_value = 0 @@ -65,6 +66,7 @@ class TestSetupAgent(TestCase): cmdStr = str(call_mock.call_args_list[0][0]) self.assertTrue(expected_hostname in cmdStr) self.assertEqual(ret, 0) + self.assertTrue(sleep_mock.called) # Key 'log' not found execOsCommand_mock.return_value = None ret = setup_agent.runAgent(passphrase, expected_hostname)
