Repository: ambari Updated Branches: refs/heads/trunk 84bd9ca44 -> 9a4c0d6bd
AMBARI-16673. Fix for parsing multiple lines in output while looking for created 'llap package' name. Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/9a4c0d6b Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/9a4c0d6b Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/9a4c0d6b Branch: refs/heads/trunk Commit: 9a4c0d6bd1017787ee3e4d03fe4bb1eec321c771 Parents: 84bd9ca Author: Swapan Shridhar <[email protected]> Authored: Fri May 13 17:06:38 2016 -0700 Committer: Swapan Shridhar <[email protected]> Committed: Sat May 14 11:56:28 2016 -0700 ---------------------------------------------------------------------- .../package/scripts/hive_server_interactive.py | 15 +++-- .../stacks/2.5/HIVE/test_hive_server_int.py | 58 +++++++++++++++++++- 2 files changed, 67 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/9a4c0d6b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py index e94b22e..2fb8f0b 100644 --- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py +++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_server_interactive.py @@ -236,11 +236,16 @@ class HiveServerInteractiveDefault(HiveServerInteractive): # E.g., output: # Prepared llap-slider-05Apr2016/run.sh for running LLAP on Slider exp = r"Prepared (.*?run.sh) for running LLAP" - m = re.match(exp, output, re.I) - if m and len(m.groups()) == 1: - run_file_name = m.group(1) - run_file_path = os.path.join(params.hive_user_home_dir, run_file_name) - else: + run_file_path = None + out_splits = output.split("\n") + for line in out_splits: + line = line.strip() + m = re.match(exp, line, re.I) + if m and len(m.groups()) == 1: + run_file_name = m.group(1) + run_file_path = os.path.join(params.hive_user_home_dir, run_file_name) + break + if not run_file_path: raise Fail("Did not find run.sh file in output: " + str(output)) Logger.info(format("Run file path: {run_file_path}")) http://git-wip-us.apache.org/repos/asf/ambari/blob/9a4c0d6b/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py b/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py index dc02f9f..ee93f9e 100644 --- a/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py +++ b/ambari-server/src/test/python/stacks/2.5/HIVE/test_hive_server_int.py @@ -68,11 +68,15 @@ class TestHiveServerInteractive(RMFTestCase): self.assert_configure_default() self.assertNoMoreResources() + """ + Tests HSI start with llap package creation output having single line. + Sample output : "Prepared llap-slider-05Apr2016/run.sh for running LLAP" + """ @patch("os.path.isfile") @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs") @patch("socket.socket") @patch("time.sleep") - def test_start_default(self, sleep_mock, socket_mock, copy_to_hfds_mock, is_file_mock): + def test_start_default_with_llap_single_line_output(self, sleep_mock, socket_mock, copy_to_hfds_mock, is_file_mock): self.maxDiff = None copy_to_hfds_mock.return_value = False s = socket_mock.return_value @@ -115,6 +119,58 @@ class TestHiveServerInteractive(RMFTestCase): ) self.assertNoMoreResources() + """ + Tests HSI start with llap package creation output having multiple lines. + Sample output : "UNWANTED STRING \n Prepared llap-slider-05Apr2016/run.sh for running LLAP \n UNWANTED STRING \n" + """ + @patch("os.path.isfile") + @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs") + @patch("socket.socket") + @patch("time.sleep") + def test_start_default_with_llap_multi_line_output(self, sleep_mock, socket_mock, copy_to_hfds_mock, is_file_mock): + self.maxDiff = None + copy_to_hfds_mock.return_value = False + s = socket_mock.return_value + is_file_mock.return_value = True + self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/hive_server_interactive.py", + classname="HiveServerInteractive", + command="start", + config_file=self.get_src_folder() + "/test/python/stacks/2.5/configs/hsi_default.json", + stack_version=self.STACK_VERSION, + target=RMFTestCase.TARGET_COMMON_SERVICES, + checked_call_mocks=[(0, "UNWANTED_STRING \n " + " Prepared llap-slider-05Apr2016/run.sh for running LLAP \n " + "UNWANTED_STRING \n ", ""), + (0, "{\"state\":\"RUNNING_ALL\"}", ""), (0, "OK.", "")], + ) + + self.assert_configure_default() + + self.assertResourceCalled('Execute', + '/home/hive/llap-slider-05Apr2016/run.sh', + user='hive' + ) + self.assertResourceCalled('Execute', + 'hive --config /usr/hdp/current/hive-server2-hive2/conf/conf.server --service metatool -updateLocation hdfs://c6401.ambari.apache.org:8020 OK.', + environment={'PATH': '/usr/hdp/current/hadoop-client/bin'}, + user='hive' + ) + self.assertResourceCalled('Execute', + '/tmp/start_hiveserver2_interactive_script /var/run/hive/hive-server2-interactive.out /var/log/hive/hive-server2-interactive.err /var/run/hive/hive-interactive.pid /usr/hdp/current/hive-server2-hive2/conf/conf.server /var/log/hive', + environment={'HADOOP_HOME': '/usr/hdp/current/hadoop-client', + 'HIVE_BIN': 'hive2', + 'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'}, + not_if="ls /var/run/hive/hive-interactive.pid >/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1", + user='hive', + path=['/bin:/usr/hdp/current/hive-server2-hive2/bin:/usr/hdp/current/hadoop-client/bin'], + ) + self.assertResourceCalled('Execute', + '/usr/jdk64/jdk1.7.0_45/bin/java -cp /usr/lib/ambari-agent/DBConnectionVerification.jar:/usr/hdp/current/hive-server2-hive2/lib/mysql-connector-java.jar org.apache.ambari.server.DBConnectionVerification \'jdbc:mysql://c6402.ambari.apache.org/hive?createDatabaseIfNotExist=true\' hive \'!`"\'"\'"\' 1\' com.mysql.jdbc.Driver', + path=['/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin'], + tries=5, + try_sleep=10 + ) + self.assertNoMoreResources() def test_stop_default(self): self.maxDiff = None
