Repository: ambari Updated Branches: refs/heads/trunk b3408e387 -> 17ead15a7
AMBARI-5139 Error while host confirmation (bootstrap.py) (Dmytro Shkvyra via dsen) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/17ead15a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/17ead15a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/17ead15a Branch: refs/heads/trunk Commit: 17ead15a7634c46db6e806b47c116f481108fdaa Parents: b3408e3 Author: Dmitry Sen <[email protected]> Authored: Wed Mar 19 16:57:50 2014 +0200 Committer: Dmitry Sen <[email protected]> Committed: Wed Mar 19 16:57:50 2014 +0200 ---------------------------------------------------------------------- ambari-server/src/main/python/bootstrap.py | 6 +++++- ambari-server/src/test/python/TestBootstrap.py | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/17ead15a/ambari-server/src/main/python/bootstrap.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/bootstrap.py b/ambari-server/src/main/python/bootstrap.py index 33c9d47..9b4140d 100755 --- a/ambari-server/src/main/python/bootstrap.py +++ b/ambari-server/src/main/python/bootstrap.py @@ -422,7 +422,11 @@ class Bootstrap(threading.Thread): def try_to_execute(self, action): last_retcode = {"exitstatus": 177, "log":"Try to execute '{0}'".format(str(action)), "errormsg":"Execute of '{0}' failed".format(str(action))} try: - last_retcode = action() + retcode = action() + if isinstance(retcode, int): + last_retcode["exitstatus"] = retcode + else: + last_retcode = retcode except Exception, e: self.host_log.write("Traceback: " + traceback.format_exc()) return last_retcode http://git-wip-us.apache.org/repos/asf/ambari/blob/17ead15a/ambari-server/src/test/python/TestBootstrap.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestBootstrap.py b/ambari-server/src/test/python/TestBootstrap.py index ee4d81d..9a80213 100644 --- a/ambari-server/src/test/python/TestBootstrap.py +++ b/ambari-server/src/test/python/TestBootstrap.py @@ -620,10 +620,17 @@ class TestBootstrap(TestCase): None, "8440") bootstrap_obj = Bootstrap("hostname", shared_state) # Normal case - ret = bootstrap_obj.try_to_execute(lambda : {"exitstatus": expected}) + def act_normal_return_int(): + return 43 + ret = bootstrap_obj.try_to_execute(act_normal_return_int) + self.assertEqual(ret["exitstatus"], expected) + self.assertFalse(write_mock.called) + write_mock.reset_mock() + def act_normal_return(): + return {"exitstatus": 43} + ret = bootstrap_obj.try_to_execute(act_normal_return) self.assertEqual(ret["exitstatus"], expected) self.assertFalse(write_mock.called) - write_mock.reset_mock() # Exception scenario def act():
