ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vbrodets...@apache.org
Subject ambari git commit: AMBARI-13796. SERVICE_CHECK HIVE is Failed (Critical Alert is present).(vbrodetskyi)
Date Mon, 09 Nov 2015 17:23:57 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 0936c4357 -> 29bac55b6


AMBARI-13796. SERVICE_CHECK HIVE is Failed (Critical Alert is present).(vbrodetskyi)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/29bac55b
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/29bac55b
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/29bac55b

Branch: refs/heads/branch-2.1
Commit: 29bac55b68d8fe720638fcdfbb399dd0f6af7d05
Parents: 0936c43
Author: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Authored: Mon Nov 9 19:22:57 2015 +0200
Committer: Vitaly Brodetskyi <vbrodetskyi@hortonworks.com>
Committed: Mon Nov 9 19:24:03 2015 +0200

----------------------------------------------------------------------
 .../0.12.0.2.0/package/scripts/hive_service.py  |  9 +++---
 .../stacks/2.0.6/HIVE/test_hive_metastore.py    | 25 ++++++++-------
 .../stacks/2.0.6/HIVE/test_hive_server.py       | 33 ++++++++++----------
 .../stacks/2.1/HIVE/test_hive_metastore.py      | 27 ++++++++--------
 4 files changed, 49 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/29bac55b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
index cda869e..5f11715 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/hive_service.py
@@ -30,6 +30,7 @@ from resource_management.core.resources.service import Service
 from resource_management.core.exceptions import Fail
 from resource_management.core.shell import as_user
 from resource_management.libraries.functions.hive_check import check_thrift_port_sasl
+from resource_management.libraries.functions import get_user_call_output
 
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
@@ -64,8 +65,8 @@ def hive_service(name, action='start', upgrade_type=None):
       hive_kinit_cmd = format("{kinit_path_local} -kt {hive_server2_keytab} {hive_principal};
")
       Execute(hive_kinit_cmd, user=params.hive_user)
 
-  pid_expression = "`" + as_user(format("cat {pid_file}"), user=params.hive_user) + "`"
-  process_id_exists_command = format("ls {pid_file} >/dev/null 2>&1 &&
ps -p {pid_expression} >/dev/null 2>&1")
+  pid = get_user_call_output.get_user_call_output(format("cat {pid_file}"), user=params.hive_user,
is_checked_call=False)[1]
+  process_id_exists_command = format("ls {pid_file} >/dev/null 2>&1 &&
ps -p {pid} >/dev/null 2>&1")
 
   if action == 'start':
     if name == 'hiveserver2':
@@ -103,8 +104,8 @@ def hive_service(name, action='start', upgrade_type=None):
               path='/usr/sbin:/sbin:/usr/local/bin:/bin:/usr/bin', tries=5, try_sleep=10)
   elif action == 'stop':
 
-    daemon_kill_cmd = format("{sudo} kill {pid_expression}")
-    daemon_hard_kill_cmd = format("{sudo} kill -9 {pid_expression}")
+    daemon_kill_cmd = format("{sudo} kill {pid}")
+    daemon_hard_kill_cmd = format("{sudo} kill -9 {pid}")
 
     Execute(daemon_kill_cmd,
       not_if = format("! ({process_id_exists_command})")

http://git-wip-us.apache.org/repos/asf/ambari/blob/29bac55b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
index 517d71c..5df0fb8 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_metastore.py
@@ -22,6 +22,7 @@ import os
 from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0,'123','')))
 class TestHiveMetastore(RMFTestCase):
   COMMON_SERVICES_PACKAGE_DIR = "HIVE/0.12.0.2.0/package"
   STACK_VERSION = "2.0.6"
@@ -50,7 +51,7 @@ class TestHiveMetastore(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh
su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'` >/dev/null
2>&1",
+        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p 123
>/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -70,13 +71,13 @@ class TestHiveMetastore(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )
@@ -109,7 +110,7 @@ class TestHiveMetastore(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh
su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'` >/dev/null
2>&1",
+        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p 123
>/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -129,13 +130,13 @@ class TestHiveMetastore(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/29bac55b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
index 8aa2b53..747a25d 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
@@ -33,6 +33,7 @@ from resource_management.core.logger import Logger
 
 @patch.object(functions, "get_hdp_version", new = MagicMock(return_value="2.0.0.0-1234"))
 @patch("resource_management.libraries.functions.check_thrift_port_sasl", new=MagicMock())
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0,'123','')))
 class TestHiveServer(RMFTestCase):
   COMMON_SERVICES_PACKAGE_DIR = "HIVE/0.12.0.2.0/package"
   STACK_VERSION = "2.0.6"
@@ -80,7 +81,7 @@ class TestHiveServer(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p 123 >/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -112,7 +113,7 @@ class TestHiveServer(RMFTestCase):
                               environment = {'HADOOP_HOME': '/usr',
                                              'HIVE_BIN': 'hive',
                                              'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-                              not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1
&& ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+                              not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1
&& ps -p 123 >/dev/null 2>&1",
                               user = 'hive',
                               path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
                               )
@@ -144,7 +145,7 @@ class TestHiveServer(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p 123 >/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -176,7 +177,7 @@ class TestHiveServer(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p 123 >/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -208,7 +209,7 @@ class TestHiveServer(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p 123 >/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -228,13 +229,13 @@ class TestHiveServer(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`",
-        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p 123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`",
-        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive-server.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p 123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive-server.pid
>/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive-server.pid'` >/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )
@@ -281,7 +282,7 @@ class TestHiveServer(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1",
+        not_if = "ls /var/run/hive/hive-server.pid >/dev/null 2>&1 && ps
-p 123 >/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -311,13 +312,13 @@ class TestHiveServer(RMFTestCase):
                               user = 'hive',
                               )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`",
-        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p 123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`",
-        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive-server.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive-server.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive-server.pid >/dev/null 2>&1 &&
ps -p 123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive-server.pid
>/dev/null 2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive-server.pid'` >/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive-server.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )

http://git-wip-us.apache.org/repos/asf/ambari/blob/29bac55b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
index 29e616f..7decf19 100644
--- a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
@@ -23,6 +23,7 @@ from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 
 @patch("platform.linux_distribution", new = MagicMock(return_value="Linux"))
+@patch("resource_management.libraries.functions.get_user_call_output.get_user_call_output",
new=MagicMock(return_value=(0,'123','')))
 class TestHiveMetastore(RMFTestCase):
   COMMON_SERVICES_PACKAGE_DIR = "HIVE/0.12.0.2.0/package"
   STACK_VERSION = "2.0.6"
@@ -52,7 +53,7 @@ class TestHiveMetastore(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh
su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'` >/dev/null
2>&1",
+        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p 123
>/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -82,7 +83,7 @@ class TestHiveMetastore(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh
su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'` >/dev/null
2>&1",
+        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p 123
>/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -103,13 +104,13 @@ class TestHiveMetastore(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )
@@ -143,7 +144,7 @@ class TestHiveMetastore(RMFTestCase):
         environment = {'HADOOP_HOME': '/usr',
            'HIVE_BIN': 'hive',
            'JAVA_HOME': u'/usr/jdk64/jdk1.7.0_45'},
-        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p `ambari-sudo.sh
su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'` >/dev/null
2>&1",
+        not_if = "ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p 123
>/dev/null 2>&1",
         user = 'hive',
         path = ['/bin:/usr/lib/hive/bin:/usr/bin'],
     )
@@ -163,13 +164,13 @@ class TestHiveMetastore(RMFTestCase):
                        target = RMFTestCase.TARGET_COMMON_SERVICES
     )
 
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill `ambari-sudo.sh su hive -l
-s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1)",
     )
-    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 `ambari-sudo.sh su hive
-l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`",
-        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
`ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat
/var/run/hive/hive.pid'` >/dev/null 2>&1) )",
+    self.assertResourceCalled('Execute', "ambari-sudo.sh kill -9 123",
+        not_if = "! (ls /var/run/hive/hive.pid >/dev/null 2>&1 && ps -p
123 >/dev/null 2>&1) || ( sleep 5 && ! (ls /var/run/hive/hive.pid >/dev/null
2>&1 && ps -p 123 >/dev/null 2>&1) )",
     )
-    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p `ambari-sudo.sh su hive -l -s /bin/bash -c '[RMF_EXPORT_PLACEHOLDER]cat /var/run/hive/hive.pid'`
>/dev/null 2>&1)",
+    self.assertResourceCalled('Execute', "! (ls /var/run/hive/hive.pid >/dev/null 2>&1
&& ps -p 123 >/dev/null 2>&1)",
         tries = 20,
         try_sleep = 3,
     )


Mime
View raw message