ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [2/2] ambari git commit: AMBARI-10323 - Alerts: Hive Metastore And HS2 Process Alerts Do Not Work With Custom Smoke User (jonathanhurley)
Date Tue, 14 Apr 2015 15:52:08 GMT
AMBARI-10323 - Alerts: Hive Metastore And HS2 Process Alerts Do Not Work With Custom Smoke
User (jonathanhurley)


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

Branch: refs/heads/branch-2.0.maint
Commit: 0ff32cd45aa2b5b90c8f2eb7c686dcb27e5101ae
Parents: 4f15078
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Wed Apr 1 20:24:02 2015 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Apr 14 11:51:37 2015 -0400

----------------------------------------------------------------------
 .../package/alerts/alert_hive_metastore.py      |  2 +-
 .../package/alerts/alert_hive_thrift_port.py    | 22 +++--
 .../resources/host_scripts/alert_disk_space.py  | 44 +++++-----
 .../package/files/alert_hive_thrift_port.py     | 89 ++++++++++++++++----
 .../python/host_scripts/TestAlertDiskSpace.py   | 74 ++++++++--------
 5 files changed, 134 insertions(+), 97 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0ff32cd4/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
index 1802c3d..d501461 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_metastore.py
@@ -125,7 +125,7 @@ def execute(parameters=None, host_name=None):
       label = OK_MESSAGE.format(total_time)
     except Exception, exception:
       result_code = 'CRITICAL'
-      label = CRITICAL_MESSAGE.format(host_name, exception.message)
+      label = CRITICAL_MESSAGE.format(host_name, str(exception))
 
   except Exception, e:
     label = str(e)

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ff32cd4/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_thrift_port.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_thrift_port.py
b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_thrift_port.py
index c1ac0aa..3e32db9 100644
--- a/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_thrift_port.py
+++ b/ambari-server/src/main/resources/common-services/HIVE/0.12.0.2.0/package/alerts/alert_hive_thrift_port.py
@@ -24,8 +24,8 @@ from resource_management.libraries.functions import hive_check
 from resource_management.libraries.functions import format
 from resource_management.libraries.functions import get_kinit_path
 
-OK_MESSAGE = "TCP OK - %.4f response on port %s"
-CRITICAL_MESSAGE = "Connection failed on host {0}:{1}"
+OK_MESSAGE = "TCP OK - {0:.3f}s response on port {1}"
+CRITICAL_MESSAGE = "Connection failed on host {0}:{1} ({2})"
 
 HIVE_SERVER_THRIFT_PORT_KEY = '{{hive-site/hive.server2.thrift.port}}'
 HIVE_SERVER_THRIFT_HTTP_PORT_KEY = '{{hive-site/hive.server2.thrift.http.port}}'
@@ -71,7 +71,7 @@ def execute(parameters=None, host_name=None):
   """
 
   if parameters is None:
-    return (('UNKNOWN', ['There were no parameters supplied to the script.']))
+    return ('UNKNOWN', ['There were no parameters supplied to the script.'])
 
   transport_mode = HIVE_SERVER_TRANSPORT_MODE_DEFAULT
   if HIVE_SERVER_TRANSPORT_MODE_KEY in parameters:
@@ -105,7 +105,9 @@ def execute(parameters=None, host_name=None):
     hive_server_principal = HIVE_SERVER_PRINCIPAL_DEFAULT
     if HIVE_SERVER_PRINCIPAL_KEY in parameters:
       hive_server_principal = parameters[HIVE_SERVER_PRINCIPAL_KEY]
+
     smokeuser_keytab = SMOKEUSER_KEYTAB_DEFAULT
+
     if SMOKEUSER_KEYTAB_KEY in parameters:
       smokeuser_keytab = parameters[SMOKEUSER_KEYTAB_KEY]
 
@@ -126,25 +128,21 @@ def execute(parameters=None, host_name=None):
       host_name = socket.getfqdn()
 
     start_time = time.time()
+
     try:
       hive_check.check_thrift_port_sasl(host_name, port,
         hive_server2_authentication, hive_server_principal, kinitcmd, smokeuser,
         transport_mode = transport_mode)
 
-      is_thrift_port_ok = True
-    except:
-      is_thrift_port_ok = False
-
-    if is_thrift_port_ok == True:
       result_code = 'OK'
       total_time = time.time() - start_time
-      label = OK_MESSAGE % (total_time, port)
-    else:
+      label = OK_MESSAGE.format(total_time, port)
+    except Exception, exception:
       result_code = 'CRITICAL'
-      label = CRITICAL_MESSAGE.format(host_name,port)
+      label = CRITICAL_MESSAGE.format(host_name, port, str(exception))
 
   except Exception, e:
     label = str(e)
     result_code = 'UNKNOWN'
 
-  return ((result_code, [label]))
+  return (result_code, [label])

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ff32cd4/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/host_scripts/alert_disk_space.py b/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
index f51db1f..68e22df 100644
--- a/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
+++ b/ambari-server/src/main/resources/host_scripts/alert_disk_space.py
@@ -24,7 +24,7 @@ import platform
 from ambari_commons.os_family_impl import OsFamilyFuncImpl, OsFamilyImpl
 from ambari_commons import OSConst
 
-DiskInfo = collections.namedtuple('DiskInfo', 'total used free')
+DiskInfo = collections.namedtuple('DiskInfo', 'total used free path')
 MIN_FREE_SPACE = 5000000000L   # 5GB
 
 # the location where HDP installs components when using HDP 2.2+
@@ -43,7 +43,10 @@ def get_tokens():
 @OsFamilyFuncImpl(os_family=OsFamilyImpl.DEFAULT)
 def execute(parameters=None, host_name=None):
   """
-  Performs advanced disk checks under Linux
+  Performs advanced disk checks under Linux. This will first attempt to
+  check the HDP installation directories if they exist. If they do not exist,
+  it will default to checking /
+
   Returns a tuple containing the result code and a pre-formatted result label
 
   Keyword arguments:
@@ -51,35 +54,23 @@ def execute(parameters=None, host_name=None):
   host_name (string): the name of this host where the alert is running
   """
 
-  # Check usage of root partition
-  try:
-    disk_usage = _get_disk_usage()
-    result_code, label = _get_warnings_for_partition(disk_usage)
-  except NotImplementedError, platform_error:
-    return 'CRITICAL', [str(platform_error)]
-
-  # determine the location of HDP home; if it exists then we should also
-  # check it in addition to /
+  # determine the location of HDP home
   hdp_home = None
   if os.path.isdir(HDP_HOME_DIR):
     hdp_home = HDP_HOME_DIR
   elif os.path.isdir(HDP_HOME_LEGACY_DIR):
     hdp_home = HDP_HOME_LEGACY_DIR
 
-  if result_code == 'OK' and hdp_home:
-    # Root partition seems to be OK, let's check HDP home
-    try:
-      disk_usage = _get_disk_usage(hdp_home)
-      result_code_usr_hdp, label_usr_hdp = _get_warnings_for_partition(disk_usage)
-      if result_code_usr_hdp != 'OK':
-        label = "{0}. Insufficient space at {1}: {2}".format(label, hdp_home, label_usr_hdp)
-        result_code = 'WARNING'
-    except NotImplementedError, platform_error:
-      return 'CRITICAL', [str(platform_error)]
-    pass
+  # if hdp home was found, use it; otherwise default to None
+  path = hdp_home if hdp_home is not None else None
 
-  return result_code, [label]
+  try:
+    disk_usage = _get_disk_usage(path)
+    result_code, label = _get_warnings_for_partition(disk_usage)
+  except NotImplementedError, platform_error:
+    return 'CRITICAL', [str(platform_error)]
 
+  return result_code, [label]
 
 def _get_warnings_for_partition(disk_usage):
   if disk_usage is None or disk_usage.total == 0:
@@ -96,6 +87,9 @@ def _get_warnings_for_partition(disk_usage):
     percent, _get_formatted_size(disk_usage.used),
     _get_formatted_size(disk_usage.total))
 
+  if disk_usage.path is not None:
+    label += ", path=" + disk_usage.path
+
   if result_code == 'OK':
     # Check absolute disk space value
     if disk_usage.free < MIN_FREE_SPACE:
@@ -141,7 +135,7 @@ def _get_disk_usage(path='/'):
   else:
     raise NotImplementedError("{0} is not a supported platform for this alert".format(platform.platform()))
 
-  return DiskInfo(total=total, used=used, free=free)
+  return DiskInfo(total=total, used=used, free=free, path=path)
 
 
 @OsFamilyFuncImpl(os_family=OSConst.WINSRV_FAMILY)
@@ -172,7 +166,7 @@ def _get_disk_usage(path=None):
     free += free_bytes.value
     used += total_bytes.value - free_bytes.value
 
-  return DiskInfo(total=total, used=used, free=free)
+  return DiskInfo(total=total, used=used, free=free, path=None)
 
 
 def _get_formatted_size(bytes):

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ff32cd4/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/package/files/alert_hive_thrift_port.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/package/files/alert_hive_thrift_port.py
b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/package/files/alert_hive_thrift_port.py
index 2e302f2..96d68b3 100644
--- a/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/package/files/alert_hive_thrift_port.py
+++ b/ambari-server/src/main/resources/stacks/BIGTOP/0.8/services/HIVE/package/files/alert_hive_thrift_port.py
@@ -21,25 +21,43 @@ limitations under the License.
 import socket
 import time
 from resource_management.libraries.functions import hive_check
+from resource_management.libraries.functions import format
+from resource_management.libraries.functions import get_kinit_path
 
-OK_MESSAGE = "TCP OK - %.4f response on port %s"
-CRITICAL_MESSAGE = "Connection failed on host {0}:{1}"
+OK_MESSAGE = "TCP OK - {0:.3f}s response on port {1}"
+CRITICAL_MESSAGE = "Connection failed on host {0}:{1} ({2})"
 
 HIVE_SERVER_THRIFT_PORT_KEY = '{{hive-site/hive.server2.thrift.port}}'
+HIVE_SERVER_THRIFT_HTTP_PORT_KEY = '{{hive-site/hive.server2.thrift.http.port}}'
+HIVE_SERVER_TRANSPORT_MODE_KEY = '{{hive-site/hive.server2.transport.mode}}'
 SECURITY_ENABLED_KEY = '{{cluster-env/security_enabled}}'
+HIVE_SERVER2_AUTHENTICATION_KEY = '{{hive-site/hive.server2.authentication}}'
+HIVE_SERVER_PRINCIPAL_KEY = '{{hive-site/hive.server2.authentication.kerberos.principal}}'
+SMOKEUSER_KEYTAB_KEY = '{{cluster-env/smokeuser_keytab}}'
+SMOKEUSER_PRINCIPAL_KEY = '{{cluster-env/smokeuser_principal_name}}'
+SMOKEUSER_KEY = '{{cluster-env/smokeuser}}'
 
 PERCENT_WARNING = 200
 PERCENT_CRITICAL = 200
 
 THRIFT_PORT_DEFAULT = 10000
+HIVE_SERVER_TRANSPORT_MODE_DEFAULT = 'binary'
+HIVE_SERVER_PRINCIPAL_DEFAULT = 'hive/_HOST@EXAMPLE.COM'
+HIVE_SERVER2_AUTHENTICATION_DEFAULT = 'NOSASL'
+SMOKEUSER_KEYTAB_DEFAULT = '/etc/security/keytabs/smokeuser.headless.keytab'
+SMOKEUSER_PRINCIPAL_DEFAULT = 'ambari-qa@EXAMPLE.COM'
+SMOKEUSER_DEFAULT = 'ambari-qa'
 
 def get_tokens():
   """
   Returns a tuple of tokens in the format {{site/property}} that will be used
   to build the dictionary passed into execute
   """
-  return (HIVE_SERVER_THRIFT_PORT_KEY,SECURITY_ENABLED_KEY)      
-  
+  return (HIVE_SERVER_THRIFT_PORT_KEY,SECURITY_ENABLED_KEY, SMOKEUSER_KEY,
+    HIVE_SERVER2_AUTHENTICATION_KEY,HIVE_SERVER_PRINCIPAL_KEY,
+    SMOKEUSER_KEYTAB_KEY,SMOKEUSER_PRINCIPAL_KEY,HIVE_SERVER_THRIFT_HTTP_PORT_KEY,
+    HIVE_SERVER_TRANSPORT_MODE_KEY)
+
 
 def execute(parameters=None, host_name=None):
   """
@@ -51,36 +69,71 @@ def execute(parameters=None, host_name=None):
   """
 
   if parameters is None:
-    return (('UNKNOWN', ['There were no parameters supplied to the script.']))
+    return ('UNKNOWN', ['There were no parameters supplied to the script.'])
+
+  transport_mode = HIVE_SERVER_TRANSPORT_MODE_DEFAULT
+  if HIVE_SERVER_TRANSPORT_MODE_KEY in parameters:
+    transport_mode = parameters[HIVE_SERVER_TRANSPORT_MODE_KEY]
 
-  thrift_port = THRIFT_PORT_DEFAULT
-  if HIVE_SERVER_THRIFT_PORT_KEY in parameters:
-    thrift_port = int(parameters[HIVE_SERVER_THRIFT_PORT_KEY])  
+  port = THRIFT_PORT_DEFAULT
+  if transport_mode.lower() == 'binary' and HIVE_SERVER_THRIFT_PORT_KEY in parameters:
+    port = int(parameters[HIVE_SERVER_THRIFT_PORT_KEY])
+  elif  transport_mode.lower() == 'http' and HIVE_SERVER_THRIFT_HTTP_PORT_KEY in parameters:
+    port = int(parameters[HIVE_SERVER_THRIFT_HTTP_PORT_KEY])
 
   security_enabled = False
   if SECURITY_ENABLED_KEY in parameters:
-    security_enabled = bool(parameters[SECURITY_ENABLED_KEY])  
+    security_enabled = str(parameters[SECURITY_ENABLED_KEY]).upper() == 'TRUE'
+
+  hive_server2_authentication = HIVE_SERVER2_AUTHENTICATION_DEFAULT
+  if HIVE_SERVER2_AUTHENTICATION_KEY in parameters:
+    hive_server2_authentication = parameters[HIVE_SERVER2_AUTHENTICATION_KEY]
+
+  smokeuser_principal = SMOKEUSER_PRINCIPAL_DEFAULT
+  if SMOKEUSER_PRINCIPAL_KEY in parameters:
+    smokeuser_principal = parameters[SMOKEUSER_PRINCIPAL_KEY]
+
+  smokeuser = SMOKEUSER_DEFAULT
+  if SMOKEUSER_KEY in parameters:
+    smokeuser = parameters[SMOKEUSER_KEY]
 
   result_code = None
 
+  if security_enabled:
+    hive_server_principal = HIVE_SERVER_PRINCIPAL_DEFAULT
+    if HIVE_SERVER_PRINCIPAL_KEY in parameters:
+      hive_server_principal = parameters[HIVE_SERVER_PRINCIPAL_KEY]
+
+    smokeuser_keytab = SMOKEUSER_KEYTAB_DEFAULT
+
+    if SMOKEUSER_KEYTAB_KEY in parameters:
+      smokeuser_keytab = parameters[SMOKEUSER_KEYTAB_KEY]
+    kinit_path_local = get_kinit_path()
+    kinitcmd=format("{kinit_path_local} -kt {smokeuser_keytab} {smokeuser_principal}; ")
+  else:
+    hive_server_principal = None
+    kinitcmd=None
+
   try:
     if host_name is None:
       host_name = socket.getfqdn()
 
     start_time = time.time()
-    is_thrift_port_ok = hive_check.check_thrift_port_sasl(host_name,
-        thrift_port, security_enabled=security_enabled)
-     
-    if is_thrift_port_ok == True:
+
+    try:
+      hive_check.check_thrift_port_sasl(host_name, port,
+        hive_server2_authentication, hive_server_principal, kinitcmd, smokeuser,
+        transport_mode = transport_mode)
+
       result_code = 'OK'
       total_time = time.time() - start_time
-      label = OK_MESSAGE % (total_time, thrift_port)
-    else:
+      label = OK_MESSAGE.format(total_time, port)
+    except Exception, exception:
       result_code = 'CRITICAL'
-      label = CRITICAL_MESSAGE.format(host_name,thrift_port)
+      label = CRITICAL_MESSAGE.format(host_name, port, str(exception))
 
   except Exception, e:
     label = str(e)
     result_code = 'UNKNOWN'
-        
-  return ((result_code, [label]))
\ No newline at end of file
+
+  return (result_code, [label])

http://git-wip-us.apache.org/repos/asf/ambari/blob/0ff32cd4/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
index 8194bba..c94dfa6 100644
--- a/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
+++ b/ambari-server/src/test/python/host_scripts/TestAlertDiskSpace.py
@@ -22,86 +22,78 @@ from mock.mock import patch, MagicMock
 from ambari_commons.os_check import OSCheck
 from stacks.utils.RMFTestCase import *
 
+from only_for_platform import get_platform, not_for_platform, only_for_platform, PLATFORM_LINUX,
PLATFORM_WINDOWS
+
+if get_platform() != PLATFORM_WINDOWS:
+  os_distro_value = ('Suse','11','Final')
+  from pwd import getpwnam
+else:
+  #No Windows tests for now, but start getting prepared
+  os_distro_value = ('win2012serverr2','6.3','WindowsServer')
 
 class TestAlertDiskSpace(RMFTestCase):
+
+  @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
   @patch('alert_disk_space._get_disk_usage')
   @patch("os.path.isdir")
   @patch.object(OSCheck, "get_os_family", new = MagicMock(return_value = 'redhat'))
   def test_linux_flow(self, isdir_mock, disk_usage_mock):
     isdir_mock.return_value = False
 
-    # / OK, /usr/hdp OK
+    # / OK
     disk_usage_mock.return_value = alert_disk_space.DiskInfo(
       total = 21673930752L, used = 5695861760L,
-      free = 15978068992L)
+      free = 15978068992L, path="/")
 
     res = alert_disk_space.execute()
     self.assertEqual(res,
-      ('OK', ['Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB]']))
+      ('OK', ['Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB], path=/']))
 
-    # / WARNING, /usr/hdp OK
+    # / WARNING
     disk_usage_mock.return_value = alert_disk_space.DiskInfo(
       total = 21673930752L, used = 14521533603L,
-      free = 7152397149L)
+      free = 7152397149L, path="/")
 
     res = alert_disk_space.execute()
     self.assertEqual(res, (
       'WARNING',
-      ['Capacity Used: [67.00%, 14.5 GB], Capacity Total: [21.7 GB]']))
+      ['Capacity Used: [67.00%, 14.5 GB], Capacity Total: [21.7 GB], path=/']))
 
-    # / CRITICAL, /usr/hdp OK
+    # / CRITICAL
     disk_usage_mock.return_value = alert_disk_space.DiskInfo(
       total = 21673930752L, used = 20590234214L,
-      free = 1083696538)
+      free = 1083696538, path="/")
 
     res = alert_disk_space.execute()
     self.assertEqual(res, ('CRITICAL',
-    ['Capacity Used: [95.00%, 20.6 GB], Capacity Total: [21.7 GB]']))
+    ['Capacity Used: [95.00%, 20.6 GB], Capacity Total: [21.7 GB], path=/']))
 
-    # / < 5GB, /usr/hdp OK
+    # / OK but < 5GB
     disk_usage_mock.return_value = alert_disk_space.DiskInfo(
       total = 5418482688L, used = 1625544806L,
-      free = 3792937882L)
+      free = 3792937882L, path="/")
 
     res = alert_disk_space.execute()
     self.assertEqual(res, ('WARNING', [
-      'Capacity Used: [30.00%, 1.6 GB], Capacity Total: [5.4 GB]. Total free space is less
than 5.0 GB']))
-
-    # / OK, /usr/hdp WARNING
-    disk_usage_mock.side_effect = [
-      alert_disk_space.DiskInfo(total = 21673930752L, used = 5695861760L,
-        free = 15978068992L),
-      alert_disk_space.DiskInfo(total = 21673930752L, used = 14521533603L,
-        free = 7152397149L)]
+      'Capacity Used: [30.00%, 1.6 GB], Capacity Total: [5.4 GB], path=/. Total free space
is less than 5.0 GB']))
 
     # trigger isdir(/usr/hdp) to True
     isdir_mock.return_value = True
 
-    res = alert_disk_space.execute()
-    self.assertEqual(res, (
-      'WARNING', ["Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB]. "
-                  "Insufficient space at /usr/hdp: Capacity Used: [67.00%, 14.5 GB], Capacity
Total: [21.7 GB]"]))
-
-    # / OK, /usr/hdp CRITICAL
-    disk_usage_mock.side_effect = [
-      alert_disk_space.DiskInfo(total = 21673930752L, used = 5695861760L,
-        free = 15978068992L),
-      alert_disk_space.DiskInfo(total = 21673930752L, used = 20590234214L,
-        free = 1083696538L)]
+    # / OK
+    disk_usage_mock.return_value = alert_disk_space.DiskInfo(
+      total = 21673930752L, used = 5695861760L,
+      free = 15978068992L, path="/usr/hdp")
 
     res = alert_disk_space.execute()
-    self.assertEqual(res, (
-      'WARNING', ["Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB]. "
-                  "Insufficient space at /usr/hdp: Capacity Used: [95.00%, 20.6 GB], Capacity
Total: [21.7 GB]"]))
+    self.assertEqual(res,
+      ('OK', ['Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB], path=/usr/hdp']))
 
-    # / OK, /usr/hdp < 5GB
-    disk_usage_mock.side_effect = [
-      alert_disk_space.DiskInfo(total = 21673930752L, used = 5695861760L,
-        free = 15978068992L),
-      alert_disk_space.DiskInfo(total = 5418482688L, used = 1625544806L,
-        free = 3792937882L)]
+    # /usr/hdp < 5GB
+    disk_usage_mock.return_value = alert_disk_space.DiskInfo(
+      total = 5418482688L, used = 1625544806L,
+      free = 3792937882L, path="/usr/hdp")
 
     res = alert_disk_space.execute()
     self.assertEqual(res, (
-      'WARNING', ["Capacity Used: [26.28%, 5.7 GB], Capacity Total: [21.7 GB]. "
-                  "Insufficient space at /usr/hdp: Capacity Used: [30.00%, 1.6 GB], Capacity
Total: [5.4 GB]. Total free space is less than 5.0 GB"]))
+      'WARNING', ["Capacity Used: [30.00%, 1.6 GB], Capacity Total: [5.4 GB], path=/usr/hdp.
Total free space is less than 5.0 GB"]))


Mime
View raw message