Explorar el Código

AMBARI-11783. Hive service check failed during Rolling upgrade due to JAVA_HOME not set (ncole)

Nate Cole hace 10 años
padre
commit
ce33632aa1

+ 3 - 2
ambari-common/src/main/python/resource_management/libraries/functions/hdp_select.py

@@ -69,7 +69,8 @@ SERVER_ROLE_DIRECTORY_MAP = {
 SERVICE_CHECK_DIRECTORY_MAP = {
   "HDFS_SERVICE_CHECK" : "hadoop-client",
   "TEZ_SERVICE_CHECK" : "hadoop-client",
-  "PIG_SERVICE_CHECK" : "hadoop-client"
+  "PIG_SERVICE_CHECK" : "hadoop-client",
+  "HIVE_SERVICE_CHECK" : "hadoop-client"
 }
 
 # /usr/hdp/current/hadoop-client/[bin|sbin|libexec|lib]
@@ -202,4 +203,4 @@ def _get_upgrade_stack():
   if direction and stack_name and stack_version:
     return (stack_name, stack_version)
 
-  return None
+  return None

+ 35 - 1
ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py

@@ -17,11 +17,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
+import json
 import os
 from mock.mock import MagicMock, call, patch
 from stacks.utils.RMFTestCase import *
 import datetime, sys, socket
-import  resource_management.libraries.functions
+import resource_management.libraries.functions
+
 @patch.object(resource_management.libraries.functions, "get_unique_id_and_date", new = MagicMock(return_value=''))
 @patch("socket.socket")
 @patch("time.time", new=MagicMock(return_value=1431110511.43))
@@ -246,3 +248,35 @@ class TestServiceCheck(RMFTestCase):
         try_sleep = 5,
     )
     self.assertNoMoreResources()
+
+
+  
+  def test_service_check_during_upgrade(self, socket_mock):
+    config_file = self.get_src_folder() + "/test/python/stacks/2.2/configs/hive-upgrade.json"
+    with open(config_file, 'r') as f:
+      json_content = json.load(f)
+
+    json_content['commandParams']['version'] = "2.3.0.0-1234"
+
+    self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/service_check.py",
+      classname="HiveServiceCheck",
+      command="service_check",
+      config_dict = json_content,
+      hdp_stack_version = self.STACK_VERSION,
+      target = RMFTestCase.TARGET_COMMON_SERVICES)
+
+    self.assertResourceCalled('Execute', "! beeline -u 'jdbc:hive2://c6402.ambari.apache.org:10010/;transportMode=binary' -e '' 2>&1| awk '{print}'|grep -i -e 'Connection refused' -e 'Invalid URL'",
+      path = ['/bin/', '/usr/bin/', '/usr/lib/hive/bin/', '/usr/sbin/'],
+      timeout = 30,
+      user = 'ambari-qa')
+
+    self.assertResourceCalled('File', '/tmp/hcatSmoke.sh',
+      content = StaticFile('hcatSmoke.sh'),
+      mode = 0755)
+
+    self.assertResourceCalled('Execute', "env JAVA_HOME=/usr/jdk64/jdk1.7.0_45 /tmp/hcatSmoke.sh hcatsmoke prepare",
+        logoutput = True,
+        path = ['/usr/sbin','/usr/local/bin','/bin','/usr/bin', '/bin:/usr/hdp/current/hadoop-client/bin:/usr/hdp/2.3.0.0-1234/hive/bin'],
+        tries = 3,
+        user = 'ambari-qa',
+        try_sleep = 5)