summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Hurley <jhurley@hortonworks.com>2016-11-14 15:52:31 -0500
committerJonathan Hurley <jhurley@hortonworks.com>2016-11-14 16:59:49 -0500
commit54e52197c7447bcc6a48cec9b9d116c031b8cf14 (patch)
tree5056e814b6ae3e039844ac7e77ba402c23478292
parente4c9890b78c5c9412849b4cd71d31965f30deb55 (diff)
AMBARI-18887 - Hive Service Check Fails During Upgrade Due to Missing Imports (jonathanhurley)
-rw-r--r--ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py2
-rw-r--r--ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py12
-rw-r--r--ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py43
3 files changed, 49 insertions, 8 deletions
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
index 5e3e2335c3..c060ad3ec5 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/params_linux.py
@@ -106,8 +106,6 @@ hive_user_home_dir = "/home/hive"
hive_server2_hive2_dir = None
hive_server2_hive2_lib = None
-version = default("/commandParams/version", None)
-
if check_stack_feature(StackFeature.HIVE_SERVER_INTERACTIVE, version_for_stack_feature_checks):
# the name of the hiveserver2-hive2 component
hive_server2_hive2_component = status_params.SERVER_ROLE_DIRECTORY_MAP["HIVE_SERVER_INTERACTIVE"]
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py
index 2e47ee3e05..a521d6d09b 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/scripts/service_check.py
@@ -18,9 +18,7 @@ limitations under the License.
"""
-from resource_management import *
-import socket
-import sys
+import os
import time
import subprocess
@@ -28,9 +26,13 @@ from hcat_service_check import hcat_service_check
from webhcat_service_check import webhcat_service_check
from ambari_commons import OSConst
from ambari_commons.os_family_impl import OsFamilyImpl
-from resource_management.core import shell
from resource_management.core.logger import Logger
from resource_management.libraries.functions import get_unique_id_and_date
+from resource_management.libraries.script.script import Script
+from resource_management.libraries.functions.format import format
+from resource_management.libraries.functions.hive_check import check_thrift_port_sasl
+from resource_management.core.resources.system import Execute
+from resource_management.core.exceptions import Fail
class HiveServiceCheck(Script):
pass
@@ -168,7 +170,7 @@ class HiveServiceCheckDefault(HiveServiceCheck):
beeline_url.append('principal={key}')
exec_path = params.execute_path
- if params.version and params.stack_root:
+ if params.version:
upgrade_hive_bin = format("{stack_root}/{version}/hive2/bin")
exec_path = os.environ['PATH'] + os.pathsep + params.hadoop_bin_dir + os.pathsep + upgrade_hive_bin
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
index 273bd96323..daabe1c955 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_service_check.py
@@ -259,7 +259,6 @@ class TestServiceCheck(RMFTestCase):
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:
@@ -289,3 +288,45 @@ class TestServiceCheck(RMFTestCase):
tries = 3,
user = 'ambari-qa',
try_sleep = 5)
+
+
+ def test_service_check_during_upgrade_for_llap(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)
+
+ # populate version and an LLAP instance to trigger the LLAP service check
+ json_content['commandParams']['version'] = "2.3.0.0-1234"
+ json_content['clusterHostInfo']['hive_server_interactive_hosts'] = ["c6402.ambari.apache.org"]
+ json_content['configurations']['hive-interactive-env'] = {}
+ json_content['configurations']['hive-interactive-env']['enable_hive_interactive'] = True
+
+
+ self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/service_check.py",
+ classname = "HiveServiceCheck",
+ command = "service_check",
+ config_dict = json_content,
+ 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('Execute',
+ "! beeline -u 'jdbc:hive2://c6402.ambari.apache.org:10500/;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')
+
+ # LLAP call
+ self.assertResourceCalled('Execute',
+ "! beeline -u 'jdbc:hive2://c6402.ambari.apache.org:10500/;transportMode=binary' --hiveconf \"hiveLlapServiceCheck=\" -f /usr/hdp/current/hive-server2-hive2/scripts/llap/sql/serviceCheckScript.sql -e '' 2>&1| awk '{print}'|grep -i -e 'Invalid status\|Invalid URL\|command not found\|Connection refused'",
+ path = ['/usr/sbin', '/usr/local/bin', '/bin', '/usr/bin', '/bin:/usr/hdp/current/hadoop-client/bin:/usr/hdp/2.3.0.0-1234/hive2/bin'],
+ tries = 1,
+ stderr = -1,
+ wait_for_finish = True,
+ logoutput = True,
+ user = 'hive')