ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aonis...@apache.org
Subject ambari git commit: AMBARI-8474. Tests fail on trunk (aonishuk)
Date Fri, 28 Nov 2014 16:43:18 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk a56e92474 -> 9c3ed394c


AMBARI-8474. Tests fail on trunk (aonishuk)


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

Branch: refs/heads/trunk
Commit: 9c3ed394cd5fa7236ee52ffc058e76c74f4dbe7c
Parents: a56e924
Author: Andrew Onishuk <aonishuk@hortonworks.com>
Authored: Fri Nov 28 18:43:00 2014 +0200
Committer: Andrew Onishuk <aonishuk@hortonworks.com>
Committed: Fri Nov 28 18:43:00 2014 +0200

----------------------------------------------------------------------
 .../python/resource_management/core/shell.py    |  4 ++--
 .../custom_actions/scripts/ru_execute_tasks.py  | 10 +++++-----
 .../HDFS/package/scripts/hdfs_namenode.py       |  4 ++--
 .../python/stacks/2.0.6/HDFS/test_namenode.py   | 21 +++++++++++---------
 4 files changed, 21 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9c3ed394/ambari-common/src/main/python/resource_management/core/shell.py
----------------------------------------------------------------------
diff --git a/ambari-common/src/main/python/resource_management/core/shell.py b/ambari-common/src/main/python/resource_management/core/shell.py
index 841e7e4..2a472f2 100644
--- a/ambari-common/src/main/python/resource_management/core/shell.py
+++ b/ambari-common/src/main/python/resource_management/core/shell.py
@@ -31,9 +31,9 @@ from exceptions import Fail
 from exceptions import ExecuteTimeoutException
 from resource_management.core.logger import Logger
 
-def checked_call(command, logoutput=False, throw_on_failure=True, 
+def checked_call(command, logoutput=False, 
          cwd=None, env=None, preexec_fn=None, user=None, wait_for_finish=True, timeout=None,
path=None, sudo=False):
-  return _call(command, logoutput, throw_on_failure, cwd, env, preexec_fn, user, wait_for_finish,
timeout, path, sudo)
+  return _call(command, logoutput, True, cwd, env, preexec_fn, user, wait_for_finish, timeout,
path, sudo)
 
 def call(command, logoutput=False, 
          cwd=None, env=None, preexec_fn=None, user=None, wait_for_finish=True, timeout=None,
path=None, sudo=False):

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c3ed394/ambari-server/src/main/resources/custom_actions/scripts/ru_execute_tasks.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/custom_actions/scripts/ru_execute_tasks.py b/ambari-server/src/main/resources/custom_actions/scripts/ru_execute_tasks.py
index 4e9b506..269abdb 100644
--- a/ambari-server/src/main/resources/custom_actions/scripts/ru_execute_tasks.py
+++ b/ambari-server/src/main/resources/custom_actions/scripts/ru_execute_tasks.py
@@ -26,7 +26,7 @@ import re
 import time
 
 from resource_management import *
-from resource_management.core.shell import checked_call
+from resource_management.core.shell import call, checked_call
 from resource_management.core.exceptions import Fail
 from resource_management.core.logger import Logger
 from resource_management.libraries.functions.list_ambari_managed_repos import *
@@ -97,20 +97,20 @@ class ExecuteUpgradeTasks(Script):
           unless = replace_variables(unless, host_name, version)
 
           if first:
-            code, out = checked_call(first, throw_on_failure=False)
+            code, out = call(first)
             Logger.info("Pre-condition command. Code: %s, Out: %s" % (str(code), str(out)))
             if code != 0:
               break
 
           if unless:
-            code, out = checked_call(unless, throw_on_failure=False)
+            code, out = call(unless)
             Logger.info("Unless command. Code: %s, Out: %s" % (str(code), str(out)))
             if code == 0:
               break
 
           for i in range(1, effective_times+1):
             # TODO, Execute already has a tries and try_sleep, see hdfs_namenode.py for an
example
-            code, out = checked_call(command, throw_on_failure=False)
+            code, out = call(command)
             Logger.info("Command. Code: %s, Out: %s" % (str(code), str(out)))
 
             if code == 0 or code in ignore_return_codes:
@@ -121,7 +121,7 @@ class ExecuteUpgradeTasks(Script):
               try:
                 if on_failure:
                   on_failure = replace_variables(on_failure, host_name, version)
-                  code_failure_handler, out_failure_handler = checked_call(on_failure, throw_on_failure=False)
+                  code_failure_handler, out_failure_handler = call(on_failure)
                   Logger.error("Failure Handler. Code: %s, Out: %s" % (str(code_failure_handler),
str(out_failure_handler)))
               except:
                 pass

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c3ed394/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/package/scripts/hdfs_namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/package/scripts/hdfs_namenode.py
b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/package/scripts/hdfs_namenode.py
index 76f6e3b..de7fd58 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/package/scripts/hdfs_namenode.py
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.6/services/HDFS/package/scripts/hdfs_namenode.py
@@ -66,13 +66,13 @@ def namenode(action=None, do_format=True):
     # If HA is enabled and it is in standby, then stay in safemode, otherwise, leave safemode.
     leave_safe_mode = True
     if dfs_check_nn_status_cmd is not None:
-      code, out = shell.checked_call(dfs_check_nn_status_cmd, throw_on_failure=False)
+      code, out = shell.call(dfs_check_nn_status_cmd)
       if code != 0:
         leave_safe_mode = False
 
     if leave_safe_mode:
       # First check if Namenode is not in 'safemode OFF' (equivalent to safemode ON), if
so, then leave it
-      code, out = shell.checked_call(namenode_safe_mode_off, throw_on_failure=False)
+      code, out = shell.call(namenode_safe_mode_off)
       if code != 0:
         leave_safe_mode_cmd = format("su -s /bin/bash - {hdfs_user} -c 'export PATH=$PATH:{hadoop_bin_dir}
; hdfs --config {hadoop_conf_dir} dfsadmin -safemode leave'")
         Execute(leave_safe_mode_cmd)

http://git-wip-us.apache.org/repos/asf/ambari/blob/9c3ed394/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
index f349cc6..d111b8d 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_namenode.py
@@ -22,10 +22,11 @@ from stacks.utils.RMFTestCase import *
 from ambari_commons import OSCheck
 from mock.mock import MagicMock, patch
 import resource_management
+from resource_management.core import shell
 
 import subprocess
 
-
+@patch.object(shell, "call", new=MagicMock(return_value=(1,"")))
 class TestNamenode(RMFTestCase):
 
   def test_configure_default(self):
@@ -83,11 +84,12 @@ class TestNamenode(RMFTestCase):
     self.assertResourceCalled('Execute', 'hdfs dfsadmin -report -live',
                               user='hdfs'
                               )
+    self.assertResourceCalled('Execute', "su -s /bin/bash - hdfs -c 'export PATH=$PATH:/usr/bin
; hdfs --config /etc/hadoop/conf dfsadmin -safemode leave'",)
     self.assertResourceCalled('Execute', "su -s /bin/bash - hdfs -c 'export PATH=$PATH:/usr/bin
; hdfs --config /etc/hadoop/conf dfsadmin -safemode get' | grep 'Safe mode is OFF'",
-                              tries = 40,
-                              only_if = None,
-                              try_sleep = 10,
-                              )
+        tries = 40,
+        only_if = None,
+        try_sleep = 10,
+    )
     self.assertResourceCalled('HdfsDirectory', '/tmp',
                               security_enabled = False,
                               keytab = UnknownConfigurationMock(),
@@ -198,11 +200,12 @@ class TestNamenode(RMFTestCase):
     self.assertResourceCalled('Execute', '/usr/bin/kinit -kt /etc/security/keytabs/hdfs.headless.keytab
hdfs',
                               user='hdfs',
                               )
+    self.assertResourceCalled('Execute', "su -s /bin/bash - hdfs -c 'export PATH=$PATH:/usr/bin
; hdfs --config /etc/hadoop/conf dfsadmin -safemode leave'",)
     self.assertResourceCalled('Execute', "su -s /bin/bash - hdfs -c 'export PATH=$PATH:/usr/bin
; hdfs --config /etc/hadoop/conf dfsadmin -safemode get' | grep 'Safe mode is OFF'",
-                              tries = 40,
-                              only_if = None,
-                              try_sleep = 10,
-                              )
+        tries = 40,
+        only_if = None,
+        try_sleep = 10,
+    )
     self.assertResourceCalled('HdfsDirectory', '/tmp',
                               security_enabled = True,
                               keytab = '/etc/security/keytabs/hdfs.headless.keytab',


Mime
View raw message