You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2013/10/11 02:42:03 UTC
git commit: AMBARI-3486: Enable Security fails when ambari setup is
rerun to set java_home to oracle jdk7. (jaimin)
Updated Branches:
refs/heads/trunk d7514dcfc -> 1a219f0a7
AMBARI-3486: Enable Security fails when ambari setup is rerun to set java_home to oracle jdk7. (jaimin)
Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/1a219f0a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/1a219f0a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/1a219f0a
Branch: refs/heads/trunk
Commit: 1a219f0a7d5f8ea2ca4bc76215b49fe2a595c9bc
Parents: d7514dc
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Thu Oct 10 17:41:41 2013 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Thu Oct 10 17:41:41 2013 -0700
----------------------------------------------------------------------
ambari-server/src/main/python/ambari-server.py | 5 ++++
.../src/test/python/TestAmbariServer.py | 25 ++++++++++++++++----
2 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1a219f0a/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 eb84354..2c848b6 100755
--- a/ambari-server/src/main/python/ambari-server.py
+++ b/ambari-server/src/main/python/ambari-server.py
@@ -1634,6 +1634,11 @@ def download_jdk(args):
if get_JAVA_HOME() and not args.java_home:
pass # do nothing
elif args.java_home and os.path.exists(args.java_home):
+ jce_policy_path = os.path.join(properties[RESOURCES_DIR_PROPERTY], JCE_POLICY_FILENAME)
+ if os.path.exists(jce_policy_path):
+ err = "Command failed to execute. Please remove or move " + jce_policy_path + " and retry again"
+ raise FatalException(1, err)
+
print_warning_msg("JAVA_HOME " + args.java_home
+ " must be valid on ALL hosts")
write_property(JAVA_HOME_PROPERTY, args.java_home)
http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/1a219f0a/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 28b8a52..130d124 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -1666,15 +1666,17 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
get_ambari_properties_mock.return_value = p
p.__getitem__.return_value = "somewhere"
get_JAVA_HOME_mock.return_value = True
- path_existsMock.return_value = True
+ path_existsMock.side_effect = [True,False]
rcode = ambari_server.download_jdk(args)
self.assertEqual(0, rcode)
# Test case: java home setup
+ path_existsMock.side_effect = [True,False]
get_JAVA_HOME_mock.return_value = False
rcode = ambari_server.download_jdk(args)
self.assertEqual(0, rcode)
self.assertTrue(write_property_mock.called)
# Test case: JDK file does not exist, property not defined
+ path_existsMock.side_effect = None
path_existsMock.return_value = False
p = MagicMock()
get_ambari_properties_mock.return_value = p
@@ -1743,7 +1745,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
# Expected
self.assertTrue(copyfile_mock.called)
copyfile_mock.reset_mock()
- # Test case: jdk is already installed, ensure that JCE check is not skipped
+ # Test case: jdk is already installed, ensure that JCE check is not skipped if -j option is not supplied.
p = MagicMock()
get_ambari_properties_mock.return_value = p
p.__getitem__.return_value = "somewhere"
@@ -1757,11 +1759,26 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
write_property_mock.reset_mock()
args.java_home = "somewhere"
path_existsMock.return_value = True
- path_existsMock.side_effect = None
+ path_existsMock.side_effect = [True,False]
get_JAVA_HOME_mock.return_value = True
- rcode = ambari_server.download_jdk(args)
+ ambari_server.download_jdk(args)
self.assertTrue(write_property_mock.called)
+ # Test case: Negative test case JAVA_HOME location should not be updated if -j option is supplied and
+ # jce_policy file already exists in resources dir.
+ write_property_mock.reset_mock()
+ args.java_home = "somewhere"
+ path_existsMock.side_effect = None
+ path_existsMock.return_value = True
+ get_JAVA_HOME_mock.return_value = True
+ try:
+ ambari_server.download_jdk(args)
+ self.fail("Should throw exception")
+ except FatalException as fe:
+ # Expected
+ self.assertFalse(write_property_mock.called)
+ pass
+
@patch.object(ambari_server, "run_os_command")
def test_get_postgre_status(self, run_os_command_mock):