Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 3b09d1bde -> 62cefee4a


Revert "AMBARI-17306. Filter out MOTD logging from 'llapstatus' command in 
order to get the output which is JSON parsable."

This reverts commit c1565ae471061e03b1a1a52bc28ea77ad17d71c4.


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

Branch: refs/heads/branch-2.4
Commit: 62cefee4a6e6f4cf3be777b3d64723b7a3460894
Parents: 3b09d1b
Author: Sumit Mohanty <[email protected]>
Authored: Mon Jun 20 07:27:22 2016 -0700
Committer: Sumit Mohanty <[email protected]>
Committed: Mon Jun 20 07:27:22 2016 -0700

----------------------------------------------------------------------
 .../package/alerts/alert_llap_app_status.py     |  78 +-------
 .../package/scripts/hive_server_interactive.py  |  80 +-------
 .../stacks/2.5/HIVE/appComplete_withMOTDmsg.txt |  12 --
 .../stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt  |   5 -
 .../2.5/HIVE/oneContainerDown_withMOTDmsg.txt   |  35 ----
 .../stacks/2.5/HIVE/running_withMOTDmsg.txt     |  43 -----
 .../stacks/2.5/HIVE/starting_withMOTDmsg.txt    |  18 --
 .../stacks/2.5/HIVE/test_hive_server_int.py     | 189 +------------------
 8 files changed, 8 insertions(+), 452 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_llap_app_status.py
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_llap_app_status.py
 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_llap_app_status.py
index 33bf139..d65322d 100644
--- 
a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_llap_app_status.py
+++ 
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_llap_app_status.py
@@ -31,7 +31,6 @@ from ambari_commons.os_family_impl import OsFamilyFuncImpl, 
OsFamilyImpl
 from resource_management.core import shell
 from resource_management.core.resources import Execute
 from resource_management.core import global_lock
-from resource_management.core.exceptions import Fail
 
 
 OK_MESSAGE = "The application reported a '{0}' state in {1:.3f}s"
@@ -165,8 +164,7 @@ def execute(configurations={}, parameters={}, 
host_name=None):
     code, output, error = shell.checked_call(llap_status_cmd, user=hive_user, 
stderr=subprocess.PIPE,
                                              timeout=check_command_timeout,
                                              logoutput=False)
-    # Call for getting JSON
-    llap_app_info = make_valid_json(output)
+    llap_app_info = json.loads(output)
 
     if llap_app_info is None or 'state' not in llap_app_info:
       alert_label = traceback.format_exc()
@@ -221,76 +219,4 @@ def execute(configurations={}, parameters={}, 
host_name=None):
     alert_label = traceback.format_exc()
     traceback.format_exc()
     result_code = UKNOWN_STATUS_CODE
-  return (result_code, [alert_label])
-
-
-"""
-Remove extra lines from 'llapstatus' status output (eg: because of MOTD 
logging) so as to have a valid JSON data to be passed in
-to JSON converter.
-"""
-def make_valid_json(output):
-  '''
-
-  Note: It is assumed right now that extra lines will be only at the start and 
not at the end.
-
-  Sample expected JSON to be passed for 'loads' is either of the form :
-
-  Case 'A':
-  {
-      "amInfo" : {
-      "appName" : "llap0",
-      "appType" : "org-apache-slider",
-      "appId" : "APP1",
-      "containerId" : "container_1466036628595_0010_01_000001",
-      "hostname" : "hostName",
-      "amWebUrl" : "http://hostName:port/";
-    },
-    "state" : "LAUNCHING",
-    ....
-    "desiredInstances" : 1,
-    "liveInstances" : 0,
-    ....
-    ....
-  }
-
-  or
-
-  Case 'B':
-  {
-    "state" : "APP_NOT_FOUND"
-  }
-
-  '''
-  splits = output.split("\n")
-
-  len_splits = len(splits)
-  if (len_splits < 3):
-    raise Fail("Malformed JSON data received from 'llapstatus' command. 
Exiting ....")
-
-  marker_idx = None  # To detect where from to start reading for JSON data
-  for idx, split in enumerate(splits):
-    curr_elem = split.strip()
-    if idx + 2 > len_splits:
-      raise Fail(
-        "Iterated over the received 'llapstatus' comamnd. Couldn't validate 
the received output for JSON parsing.")
-    next_elem = (splits[(idx + 1)]).strip()
-    if curr_elem == "{":
-      if next_elem == "\"amInfo\" : {" and (splits[len_splits - 1]).strip() == 
'}':
-        # For Case 'A'
-        marker_idx = idx
-        break;
-      elif idx + 3 == len_splits and next_elem.startswith('"state" : ') and 
(splits[idx + 2]).strip() == '}':
-        # For Case 'B'
-        marker_idx = idx
-        break;
-
-
-  # Remove extra logging from possible JSON output
-  if marker_idx is None:
-    raise Fail("Couldn't validate the received output for JSON parsing.")
-  else:
-    del splits[0:marker_idx]
-
-  scanned_output = '\n'.join(splits)
-  llap_app_info = json.loads(scanned_output)
-  return llap_app_info
+  return (result_code, [alert_label])
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/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 d1c8401..c055cf1 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
@@ -54,7 +54,6 @@ from hive_service_interactive import hive_service_interactive
 from hive_interactive import hive_interactive
 from hive_server import HiveServerDefault
 
-import traceback
 
 class HiveServerInteractive(Script):
   pass
@@ -196,7 +195,6 @@ class HiveServerInteractiveDefault(HiveServerInteractive):
       import params
       env.set_params(params)
       Logger.info("Starting LLAP")
-      LLAP_PACKAGE_CREATION_PATH = Script.get_tmp_dir()
       LLAP_APP_NAME = 'llap0'
 
       unique_name = "llap-slider%s" % 
datetime.utcnow().strftime('%Y-%m-%d_%H-%M-%S')
@@ -204,7 +202,7 @@ class HiveServerInteractiveDefault(HiveServerInteractive):
       cmd = format("{stack_root}/current/hive-server2-hive2/bin/hive --service 
llap --instances {params.num_llap_nodes}"
                    " --slider-am-container-mb {params.slider_am_container_mb} 
--size {params.llap_daemon_container_size}m "
                    " --cache {params.hive_llap_io_mem_size}m --xmx 
{params.llap_heap_size}m --loglevel {params.llap_log_level}"
-                   " --output {LLAP_PACKAGE_CREATION_PATH}/{unique_name}")
+                   " --output {unique_name}")
       if params.security_enabled:
         llap_keytab_splits = params.hive_llap_keytab_file.split("/")
         Logger.debug("llap_keytab_splits : {0}".format(llap_keytab_splits))
@@ -297,80 +295,7 @@ class HiveServerInteractiveDefault(HiveServerInteractive):
       llap_status_cmd = 
format("{stack_root}/current/hive-server2-hive2/bin/hive --service llapstatus 
--name {app_name} -findAppTimeout {LLAP_APP_STATUS_CMD_TIMEOUT}")
       code, output, error = shell.checked_call(llap_status_cmd, 
user=status_params.hive_user, stderr=subprocess.PIPE,
                                                logoutput=False)
-      Logger.info("Received 'llapstatus' command 'output' : 
{0}".format(output))
-      return self._make_valid_json(output)
-
-
-    """
-    Remove extra lines from 'llapstatus' status output (eg: because of MOTD 
logging) so as to have a valid JSON data to be passed in
-    to JSON converter.
-    """
-    def _make_valid_json(self, output):
-      '''
-
-      Note: It is assumed right now that extra lines will be only at the start 
and not at the end.
-
-      Sample expected JSON to be passed for 'loads' is either of the form :
-
-      Case 'A':
-      {
-          "amInfo" : {
-          "appName" : "llap0",
-          "appType" : "org-apache-slider",
-          "appId" : "APP1",
-          "containerId" : "container_1466036628595_0010_01_000001",
-          "hostname" : "hostName",
-          "amWebUrl" : "http://hostName:port/";
-        },
-        "state" : "LAUNCHING",
-        ....
-        "desiredInstances" : 1,
-        "liveInstances" : 0,
-        ....
-        ....
-      }
-
-      or
-
-      Case 'B':
-      {
-        "state" : "APP_NOT_FOUND"
-      }
-
-      '''
-      splits = output.split("\n")
-
-      len_splits = len(splits)
-      if (len_splits < 3):
-        raise Fail ("Malformed JSON data received from 'llapstatus' command. 
Exiting ....")
-
-      marker_idx = None # To detect where from to start reading for JSON data
-      for idx, split in enumerate(splits):
-        curr_elem = split.strip()
-        if idx+2 > len_splits:
-          raise Fail("Iterated over the received 'llapstatus' comamnd. 
Couldn't validate the received output for JSON parsing.")
-        next_elem = (splits[(idx + 1)]).strip()
-        if curr_elem == "{":
-          if next_elem == "\"amInfo\" : {" and (splits[len_splits-1]).strip() 
== '}':
-            # For Case 'A'
-            marker_idx = idx
-            break;
-          elif idx+3 == len_splits and next_elem.startswith('"state" : ') and 
(splits[idx + 2]).strip() == '}':
-              # For Case 'B'
-              marker_idx = idx
-              break;
-
-      Logger.info("Marker index for start of JSON data for 'llapsrtatus' 
comamnd : {0}".format(marker_idx))
-
-      # Remove extra logging from possible JSON output
-      if marker_idx is None:
-        raise Fail("Couldn't validate the received output for JSON parsing.")
-      else:
-        del splits[0:marker_idx]
-        Logger.info("Removed lines: '1-{0}' from the received 'llapstatus' 
output to make it valid for JSON parsing.".format(marker_idx))
-
-      scanned_output = '\n'.join(splits)
-      llap_app_info = json.loads(scanned_output)
+      llap_app_info = json.loads(output)
       return llap_app_info
 
 
@@ -457,7 +382,6 @@ class HiveServerInteractiveDefault(HiveServerInteractive):
       except Exception, e:
         Logger.info("LLAP app '{0}' did not come up after a wait of {1} 
seconds.".format(llap_app_name,
                                                                                
           time.time() - curr_time))
-        traceback.print_exc()
         return False
 
     def get_log_folder(self):

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/test/python/stacks/2.5/HIVE/appComplete_withMOTDmsg.txt
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/appComplete_withMOTDmsg.txt 
b/ambari-server/src/test/python/stacks/2.5/HIVE/appComplete_withMOTDmsg.txt
deleted file mode 100644
index 34b8d67..0000000
--- a/ambari-server/src/test/python/stacks/2.5/HIVE/appComplete_withMOTDmsg.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-######## Hortonworks #############
-This is MOTD message, added for testing in qe infra
-{
-  "amInfo" : {
-    "appName" : "llap",
-    "appType" : "org-apache-slider",
-    "appId" : "application_1455662455106_10882"
-  },
-  "state" : "COMPLETE",
-  "appStartTime" : 1459625790218,
-  "appFinishTime" : 1459625939033
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/test/python/stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt 
b/ambari-server/src/test/python/stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt
deleted file mode 100644
index f7d2832..0000000
--- a/ambari-server/src/test/python/stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-######## Hortonworks #############
-This is MOTD message, added for testing in qe infra
-{
-  "state" : "APP_NOT_FOUND"
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/test/python/stacks/2.5/HIVE/oneContainerDown_withMOTDmsg.txt
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/oneContainerDown_withMOTDmsg.txt
 
b/ambari-server/src/test/python/stacks/2.5/HIVE/oneContainerDown_withMOTDmsg.txt
deleted file mode 100644
index 84b331a..0000000
--- 
a/ambari-server/src/test/python/stacks/2.5/HIVE/oneContainerDown_withMOTDmsg.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-######## Hortonworks #############
-This is MOTD message, added for testing in qe infra
-{
-  "amInfo" : {
-    "appName" : "llap",
-    "appType" : "org-apache-slider",
-    "appId" : "application_1455662455106_10882",
-    "containerId" : "container_e14_1455662455106_10882_01_000001",
-    "hostname" : "HOST_REPLACED",
-    "amWebUrl" : "http://HOST_REPLACED:1025/";
-  },
-  "state" : "RUNNING_PARTIAL",
-  "originalConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/snapshot",
-  "generatedConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/generated",
-  "desiredInstances" : 3,
-  "liveInstances" : 2,
-  "appStartTime" : 1459625802169,
-  "llapInstances" : [ {
-    "hostname" : "HOST_REPLACED",
-    "containerId" : "container_e14_1455662455106_10882_01_000003",
-    "statusUrl" : "http://HOST_REPLACED:15002/status";,
-    "webUrl" : "http://HOST_REPLACED:15002";,
-    "rpcPort" : 15001,
-    "mgmtPort" : 15004,
-    "shufflePort" : 15551
-  }, {
-    "hostname" : "HOST_REPLACED",
-    "containerId" : "container_e14_1455662455106_10882_01_000002",
-    "statusUrl" : "http://HOST_REPLACED:15002/status";,
-    "webUrl" : "http://HOST_REPLACED:15002";,
-    "rpcPort" : 15001,
-    "mgmtPort" : 15004,
-    "shufflePort" : 15551
-  } ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/test/python/stacks/2.5/HIVE/running_withMOTDmsg.txt
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/running_withMOTDmsg.txt 
b/ambari-server/src/test/python/stacks/2.5/HIVE/running_withMOTDmsg.txt
deleted file mode 100644
index d5a4b8c..0000000
--- a/ambari-server/src/test/python/stacks/2.5/HIVE/running_withMOTDmsg.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-######## Hortonworks #############
-This is MOTD message, added for testing in qe infra
-{
-  "amInfo" : {
-    "appName" : "llap",
-    "appType" : "org-apache-slider",
-    "appId" : "application_1455662455106_10882",
-    "containerId" : "container_e14_1455662455106_10882_01_000001",
-    "hostname" : "HOST_REPLACED",
-    "amWebUrl" : "http://HOST_REPLACED:1025/";
-  },
-  "state" : "RUNNING_ALL",
-  "originalConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/snapshot",
-  "generatedConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/generated",
-  "desiredInstances" : 3,
-  "liveInstances" : 3,
-  "appStartTime" : 1459625802169,
-  "llapInstances" : [ {
-    "hostname" : "HOST_REPLACED",
-    "containerId" : "container_e14_1455662455106_10882_01_000003",
-    "statusUrl" : "http://HOST_REPLACED:15002/status";,
-    "webUrl" : "http://HOST_REPLACED:15002";,
-    "rpcPort" : 15001,
-    "mgmtPort" : 15004,
-    "shufflePort" : 15551
-  }, {
-    "hostname" : "HOST_REPLACED",
-    "containerId" : "container_e14_1455662455106_10882_01_000002",
-    "statusUrl" : "http://HOST_REPLACED:15002/status";,
-    "webUrl" : "http://HOST_REPLACED:15002";,
-    "rpcPort" : 15001,
-    "mgmtPort" : 15004,
-    "shufflePort" : 15551
-  }, {
-    "hostname" : "HOST_REPLACED",
-    "containerId" : "container_e14_1455662455106_10882_01_000004",
-    "statusUrl" : "http://HOST_REPLACED:15002/status";,
-    "webUrl" : "http://HOST_REPLACED:15002";,
-    "rpcPort" : 15001,
-    "mgmtPort" : 15004,
-    "shufflePort" : 15551
-  } ]
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/ambari-server/src/test/python/stacks/2.5/HIVE/starting_withMOTDmsg.txt
----------------------------------------------------------------------
diff --git 
a/ambari-server/src/test/python/stacks/2.5/HIVE/starting_withMOTDmsg.txt 
b/ambari-server/src/test/python/stacks/2.5/HIVE/starting_withMOTDmsg.txt
deleted file mode 100644
index 507217f..0000000
--- a/ambari-server/src/test/python/stacks/2.5/HIVE/starting_withMOTDmsg.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-######## Hortonworks #############
-This is MOTD message, added for testing in qe infra
-{
-  "amInfo" : {
-    "appName" : "llap",
-    "appType" : "org-apache-slider",
-    "appId" : "application_1455662455106_10882",
-    "containerId" : "container_e14_1455662455106_10882_01_000001",
-    "hostname" : "HOST_REPLACED",
-    "amWebUrl" : "http://HOST_REPLACED:1025/";
-  },
-  "state" : "LAUNCHING",
-  "originalConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/snapshot",
-  "generatedConfigurationPath" : 
"hdfs://HOST_REPLACED:8020/user/USER_REPLACED/.slider/cluster/llap/generated",
-  "desiredInstances" : 3,
-  "liveInstances" : 0,
-  "appStartTime" : 1459625802169
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/62cefee4/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 1e1850e..348a17d 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
@@ -28,10 +28,7 @@ from resource_management.libraries import functions
 from resource_management.core.logger import Logger
 from resource_management.libraries.script.config_dictionary import 
UnknownConfiguration
 from hive_server_interactive import HiveServerInteractiveDefault
-from resource_management.libraries.script.script import Script
-from resource_management.core import shell
 
-@patch("resource_management.libraries.Script.get_tmp_dir", 
new=MagicMock(return_value=('/var/lib/ambari-agent/tmp')))
 @patch.object(functions, "get_stack_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",
@@ -75,17 +72,15 @@ class TestHiveServerInteractive(RMFTestCase):
   Tests HSI start with llap package creation output having single line.
   Sample output : "Prepared llap-slider-05Apr2016/run.sh for running LLAP"
   """
-  #@patch("Script.get_tmp_dir()")
   @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_single_line_output(self, sleep_mock, 
socket_mock, copy_to_hfds_mock, is_file_mock): #, get_tmp_dir_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
     is_file_mock.return_value = True
-    #get_tmp_dir_mock.return_value = "/var/lib/ambari-agent/tmp"
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + 
"/scripts/hive_server_interactive.py",
                        classname="HiveServerInteractive",
                        command="start",
@@ -93,13 +88,7 @@ class TestHiveServerInteractive(RMFTestCase):
                        stack_version=self.STACK_VERSION,
                        target=RMFTestCase.TARGET_COMMON_SERVICES,
                        checked_call_mocks=[(0, "Prepared 
llap-slider-05Apr2016/run.sh for running LLAP", ""),
-                                           (0, """{
-                                                      \"state\" : 
\"RUNNING_ALL\"
-                                                   }""", ""),
-                                           (0, """{
-                                                      \"state\" : 
\"RUNNING_ALL\"
-                                                   }""", ""),
-                                           (0, "OK.", "")],
+                                           (0, "{\"state\":\"RUNNING_ALL\"}", 
""), (0, "OK.", "")],
     )
 
     self.assert_configure_default()
@@ -152,12 +141,7 @@ class TestHiveServerInteractive(RMFTestCase):
                        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, """{
-                                                      \"state\" : 
\"RUNNING_ALL\"
-                                                   }""", ""), (0, "OK.", "")],
+                                           (0, "{\"state\":\"RUNNING_ALL\"}", 
""), (0, "OK.", "")],
                        )
 
     self.assert_configure_default()
@@ -400,172 +384,7 @@ class TestHiveServerInteractive(RMFTestCase):
 
 
 
-
-
-
-
-  # Tests for function '_make_valid_json()' with will be passed in with 
'llapstatus' output which may be :
-  #     (1). A string parseable as JSON, or
-  #     (2). May have extra lines in beginning (eg: from MOTD logging 
embedded), which needs to be removed before parsed as JSON
-
-  # Status : RUNNING having MOTD lines in beginning
-  def test_make_valid_json_1(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/running_withMOTDmsg.txt","r")
-    llap_app_info = input_file_handle.read()
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Set up expected output
-    expected_ouput_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/running.json","r")
-    expected_ouput_data = expected_ouput_file_handle.read()
-    expected_ouput_data_as_json = json.loads(expected_ouput_data)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_ouput_data_as_json)
-
-  # Status : RUNNING w/o MOTD lines in beginning
-  # Expected : No change
-  def test_make_valid_json_2(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/running.json","r")
-    llap_app_info = input_file_handle.read()
-    expected_llap_app_info_as_json = json.loads(llap_app_info)
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_llap_app_info_as_json)
-
-
-
-  # Status : RUNNING_PARTIAL (2 out of 3 running -> < 80% instances ON) having 
MOTD lines in beginning
-  def test_make_valid_json_3(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/oneContainerDown_withMOTDmsg.txt","r")
-    llap_app_info = input_file_handle.read()
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Set up expected output
-    expected_ouput_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/oneContainerDown.json","r")
-    expected_ouput_data = expected_ouput_file_handle.read()
-    expected_ouput_data_as_json = json.loads(expected_ouput_data)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_ouput_data_as_json)
-
-  # Status : RUNNING_PARTIAL (2 out of 3 running -> < 80% instances ON) w/o 
MOTD lines in beginning
-  # Expected : No change
-  def test_make_valid_json_4(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/oneContainerDown.json","r")
-    llap_app_info = input_file_handle.read()
-    expected_llap_app_info_as_json = json.loads(llap_app_info)
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_llap_app_info_as_json)
-
-
-
-  # Status : LAUNCHING having MOTD lines in beginning
-  def test_make_valid_json_5(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/starting_withMOTDmsg.txt","r")
-    llap_app_info = input_file_handle.read()
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Set up expected output
-    expected_ouput_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/starting.json","r")
-    expected_ouput_data = expected_ouput_file_handle.read()
-    expected_ouput_data_as_json = json.loads(expected_ouput_data)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_ouput_data_as_json)
-
-  # Status : LAUNCHING w/o MOTD lines in beginning
-  # Expected : No change
-  def test_make_valid_json_6(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/starting.json","r")
-    llap_app_info = input_file_handle.read()
-    expected_llap_app_info_as_json = json.loads(llap_app_info)
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_llap_app_info_as_json)
-
-
-
-  # Status : COMPLETE having MOTD lines in beginning
-  def test_make_valid_json_7(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/appComplete_withMOTDmsg.txt","r")
-    llap_app_info = input_file_handle.read()
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Set up expected output
-    expected_ouput_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/appComplete.json","r")
-    expected_ouput_data = expected_ouput_file_handle.read()
-    expected_ouput_data_as_json = json.loads(expected_ouput_data)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_ouput_data_as_json)
-
-  # Status : COMPLETE w/o MOTD lines in beginning
-  # Expected : No change
-  def test_make_valid_json_8(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/appComplete.json","r")
-    llap_app_info = input_file_handle.read()
-    expected_llap_app_info_as_json = json.loads(llap_app_info)
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_llap_app_info_as_json)
-
-
-
-  # Status : INVALID APP having MOTD lines in beginning
-  def test_make_valid_json_9(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/invalidApp_withMOTDmsg.txt","r")
-    llap_app_info = input_file_handle.read()
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Set up expected output
-    expected_ouput_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/invalidApp.json","r")
-    expected_ouput_data = expected_ouput_file_handle.read()
-    expected_ouput_data_as_json = json.loads(expected_ouput_data)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_ouput_data_as_json)
-
-  # Status : INVALID APP w/o MOTD lines in beginning
-  # Expected : No change
-  def test_make_valid_json_10(self):
-    # Setting up input for fn. '_make_valid_json()'
-    input_file_handle = open(self.get_src_folder() + 
"/test/python/stacks/2.5/HIVE/invalidApp.json","r")
-    llap_app_info = input_file_handle.read()
-    expected_llap_app_info_as_json = json.loads(llap_app_info)
-
-    llap_app_info_as_json = self.hsi._make_valid_json(llap_app_info)
-
-    # Verification
-    self.assertEqual(llap_app_info_as_json, expected_llap_app_info_as_json)
-
-
-
-
-  # Tests for fn : 'check_llap_app_status()'
-
+  # llap app 'status check' related tests
 
   # Status : RUNNING
   @patch("time.sleep")

Reply via email to