Commit b832faf0 by Shwetha GS

ATLAS-56 atlas_config.py should give an informative error if jar or java…

ATLAS-56 atlas_config.py should give an informative error if jar or java binaries can't be found (dossett@gmail.com via shwethags)
parent 5e00edea
...@@ -8,6 +8,7 @@ ATLAS-54 Rename configs in hive hook (shwethags) ...@@ -8,6 +8,7 @@ ATLAS-54 Rename configs in hive hook (shwethags)
ATLAS-3 Mixed Index creation fails with Date types (suma.shivaprasad via shwethags) ATLAS-3 Mixed Index creation fails with Date types (suma.shivaprasad via shwethags)
ALL CHANGES: ALL CHANGES:
ATLAS-56 atlas_config.py should give an informative error if jar or java binaries can't be found (dossett@gmail.com via shwethags)
ATLAS-45 Entity submit fails (suma.shivaprasad via shwethags) ATLAS-45 Entity submit fails (suma.shivaprasad via shwethags)
ATLAS-46 Different data directory with restart (shwethags) ATLAS-46 Different data directory with restart (shwethags)
ATLAS-81 atlas debian packaing fails in maven build (vijay_k via shwethags) ATLAS-81 atlas debian packaing fails in maven build (vijay_k via shwethags)
......
...@@ -116,6 +116,9 @@ def java(classname, args, classpath, jvm_opts_list, logdir=None): ...@@ -116,6 +116,9 @@ def java(classname, args, classpath, jvm_opts_list, logdir=None):
else: else:
prg = which("java") prg = which("java")
if prg is None:
raise EnvironmentError('The java binary could not be found in your path or JAVA_HOME')
commandline = [prg] commandline = [prg]
commandline.extend(jvm_opts_list) commandline.extend(jvm_opts_list)
commandline.append("-classpath") commandline.append("-classpath")
...@@ -131,6 +134,9 @@ def jar(path): ...@@ -131,6 +134,9 @@ def jar(path):
else: else:
prg = which("jar") prg = which("jar")
if prg is None:
raise EnvironmentError('The jar binary could not be found in your path or JAVA_HOME')
commandline = [prg] commandline = [prg]
commandline.append("-xf") commandline.append("-xf")
commandline.append(path) commandline.append(path)
......
...@@ -19,6 +19,7 @@ limitations under the License. ...@@ -19,6 +19,7 @@ limitations under the License.
''' '''
import sys import sys
from os import environ
from mock import patch from mock import patch
import unittest import unittest
import logging import logging
...@@ -59,6 +60,28 @@ class TestMetadata(unittest.TestCase): ...@@ -59,6 +60,28 @@ class TestMetadata(unittest.TestCase):
['-Datlas.log.dir=metadata_home/logs', '-Datlas.log.file=application.log', '-Datlas.home=metadata_home', '-Duser.dir=metadata_home', '-Datlas.conf=metadata_home/conf', '-Xmx1024m'], 'metadata_home/logs') ['-Datlas.log.dir=metadata_home/logs', '-Datlas.log.file=application.log', '-Datlas.home=metadata_home', '-Duser.dir=metadata_home', '-Datlas.conf=metadata_home/conf', '-Xmx1024m'], 'metadata_home/logs')
pass pass
def test_jar_java_lookups_fail(self):
java_home = environ['JAVA_HOME']
del environ['JAVA_HOME']
orig_path = environ['PATH']
environ['PATH'] = "/dev/null"
self.assertRaises(EnvironmentError, mc.jar, "foo")
self.assertRaises(EnvironmentError, mc.java, "empty", "empty", "empty", "empty")
environ['JAVA_HOME'] = java_home
environ['PATH'] = orig_path
@patch.object(mc, "runProcess")
@patch.object(mc, "which", return_value="foo")
def test_jar_java_lookups_succeed_from_path(self, which_mock, runProcess_mock):
java_home = environ['JAVA_HOME']
del environ['JAVA_HOME']
mc.jar("foo")
mc.java("empty", "empty", "empty", "empty")
environ['JAVA_HOME'] = java_home
if __name__ == "__main__": if __name__ == "__main__":
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG) logging.basicConfig(format='%(asctime)s %(message)s', level=logging.DEBUG)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment