Repository: ambari Updated Branches: refs/heads/trunk bc6c65460 -> c97c276ae
AMBARI-4918. Entering valid directory but not a java home is not validated.(vbrodetskyi) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/c97c276a Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/c97c276a Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/c97c276a Branch: refs/heads/trunk Commit: c97c276ae6db90ab4d7938ef2d815234329d61fe Parents: bc6c654 Author: Vitaly Brodetskyi <vbrodets...@hortonworks.com> Authored: Mon Mar 3 19:50:53 2014 +0200 Committer: Vitaly Brodetskyi <vbrodets...@hortonworks.com> Committed: Mon Mar 3 19:52:45 2014 +0200 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 4 ++-- ambari-server/src/test/python/TestAmbariServer.py | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/c97c276a/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index c8abe47..9cc78c2 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -1670,8 +1670,8 @@ def download_jdk(args): jcePolicyWarn = "JCE Policy files are required for configuring Kerberos security. If you plan to use Kerberos," \ "please make sure JCE Unlimited Strength Jurisdiction Policy Files are valid on all hosts." if args.java_home: - if not os.path.exists(args.java_home): - err = "Path to java home " + args.java_home + " does not exists" + if not os.path.exists(args.java_home) or not os.path.isfile(os.path.join(args.java_home,"bin","java")): + err = "Path to java home " + args.java_home + " or java binary file does not exists" raise FatalException(1, err) print_warning_msg("JAVA_HOME " + args.java_home + " must be valid on ALL hosts") http://git-wip-us.apache.org/repos/asf/ambari/blob/c97c276a/ambari-server/src/test/python/TestAmbariServer.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py index 7281e0b..d8eec44 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -1937,6 +1937,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV args.java_home = "somewhere" path_existsMock.side_effect = [True,False,False] get_JAVA_HOME_mock.return_value = True + path_isfileMock.return_value = True ambari_server.download_jdk(args) self.assertTrue(write_property_mock.call_count == 1) self.assertTrue(remove_property_mock.call_count == 2) @@ -1986,7 +1987,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV ambari_server.download_jdk(args) self.fail("Should throw exception") except FatalException as fe: - self.assertTrue("Path to java home somewhere does not exists" in fe.reason) + self.assertTrue("Path to java home somewhere or java binary file does not exists" in fe.reason) #Test case: Setup ambari-server with jdk location passed. Path to JDK doesn't not exists args.java_home = None args.jdk_location = "/existing/jdk/file"