ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From swa...@apache.org
Subject [1/2] ambari git commit: AMBARI-16673. Fix for parsing multiple lines in output while looking for created 'llap package' name.
Date Tue, 13 Sep 2016 23:06:53 GMT
Repository: ambari
Updated Branches:
  refs/heads/remote/branch-2.4 [created] 9f6d0b005


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/11751f5a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/11751f5a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/11751f5a

Branch: refs/heads/remote/branch-2.4
Commit: 11751f5abc9e5bb6b900beba43e73f52455a1859
Parents: 1184a18
Author: Swapan Shridhar <sshridhar@hortonworks.com>
Authored: Fri May 13 17:06:38 2016 -0700
Committer: Swapan Shridhar <sshridhar@hortonworks.com>
Committed: Fri May 13 18:56:59 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/11751f5a/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/11751f5a/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


Mime
View raw message