You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by jl...@apache.org on 2015/08/21 20:29:03 UTC

ambari git commit: AMBARI-12842: Ambari Agent unit test failures on Mac (Nahappan Somasundaram via jluniya)

Repository: ambari
Updated Branches:
  refs/heads/trunk a696f9ffd -> 991feb736


AMBARI-12842: Ambari Agent unit test failures on Mac (Nahappan Somasundaram via jluniya)


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

Branch: refs/heads/trunk
Commit: 991feb736702af00332133e369e5ffde3a65f4b1
Parents: a696f9f
Author: Jayush Luniya <jl...@hortonworks.com>
Authored: Fri Aug 21 11:28:57 2015 -0700
Committer: Jayush Luniya <jl...@hortonworks.com>
Committed: Fri Aug 21 11:28:57 2015 -0700

----------------------------------------------------------------------
 .../src/test/python/ambari_agent/TestController.py       |  7 ++++---
 .../src/test/python/ambari_agent/TestHardware.py         |  3 ++-
 .../src/test/python/ambari_agent/TestHeartbeat.py        | 11 ++++++-----
 .../src/test/python/ambari_agent/TestRegistration.py     |  3 ++-
 4 files changed, 14 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/991feb73/ambari-agent/src/test/python/ambari_agent/TestController.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestController.py b/ambari-agent/src/test/python/ambari_agent/TestController.py
index a18d159..fd20dce 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestController.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestController.py
@@ -180,7 +180,7 @@ class TestController(unittest.TestCase):
     self.assertTrue(actionQueue.put_status.called)
 
 
-
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(FacterLinux, "facterInfo", new = MagicMock(return_value={}))
   @patch.object(FacterLinux, "__init__", new = MagicMock(return_value = None))
@@ -189,7 +189,7 @@ class TestController(unittest.TestCase):
   @patch.object(Controller, "ActionQueue")
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")
-  def test_run(self, get_os_version_mock, get_os_type_mock, ActionQueue_mock, installMock, buildMock):
+  def test_run(self, get_os_version_mock, get_os_type_mock, ActionQueue_mock, installMock, buildMock, Popen_mock):
     aq = MagicMock()
     ActionQueue_mock.return_value = aq
     get_os_type_mock.return_value = "suse"
@@ -222,6 +222,7 @@ class TestController(unittest.TestCase):
     self.assertTrue(aq.start.called)
 
 
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(FacterLinux, "facterInfo", new = MagicMock(return_value={}))
   @patch.object(FacterLinux, "__init__", new = MagicMock(return_value = None))
@@ -231,7 +232,7 @@ class TestController(unittest.TestCase):
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")
   def test_repeatRegistration(self, get_os_version_mock, get_os_type_mock,
-                              run_mock, installMock, buildMock):
+                              run_mock, installMock, buildMock, Popen_mock):
 
     registerAndHeartbeat = MagicMock(name="registerAndHeartbeat")
     get_os_type_mock.return_value = "suse"

http://git-wip-us.apache.org/repos/asf/ambari/blob/991feb73/ambari-agent/src/test/python/ambari_agent/TestHardware.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHardware.py b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
index c24c166..9ab02dc 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHardware.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHardware.py
@@ -40,7 +40,8 @@ eth1   1500   0        0      0      0      0        6      0      0      0 BMRU
 eth2   1500   0        0      0      0      0        6      0      0      0 BMRU
 lo    16436   0        2      0      0      0        2      0      0      0 LRU'''))
 class TestHardware(TestCase):
-
+ 
+  @patch.object(Hardware, "osdisks", new = MagicMock(return_value=[]))
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(FacterLinux, "get_ip_address_by_ifname", new = MagicMock(return_value=None))
   @patch.object(OSCheck, "get_os_type")

http://git-wip-us.apache.org/repos/asf/ambari/blob/991feb73/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
index 0c78fdb..1f3609d 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHeartbeat.py
@@ -76,11 +76,11 @@ class TestHeartbeat(TestCase):
     self.assertEquals((len(result) is 6) or (len(result) is 7), True)
     self.assertEquals(not heartbeat.reports, True, "Heartbeat should not contain task in progress")
 
-
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(ActionQueue, "result")
   @patch.object(HostInfoLinux, "register")
-  def test_no_mapping(self, register_mock, result_mock):
+  def test_no_mapping(self, register_mock, result_mock, Popen_mock):
     result_mock.return_value = {
       'reports': [{'status': 'IN_PROGRESS',
                    'stderr': 'Read from /tmp/errors-3.txt',
@@ -201,10 +201,10 @@ class TestHeartbeat(TestCase):
     self.assertEqual.__self__.maxDiff = None
     self.assertEquals(hb, expected)
 
-
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(HostInfoLinux, 'register')
-  def test_heartbeat_no_host_check_cmd_in_queue(self, register_mock):
+  def test_heartbeat_no_host_check_cmd_in_queue(self, register_mock, Popen_mock):
     config = AmbariConfig.AmbariConfig()
     config.set('agent', 'prefix', 'tmp')
     config.set('agent', 'cache_dir', "/var/lib/ambari-agent/cache")
@@ -229,9 +229,10 @@ class TestHeartbeat(TestCase):
     self.assertFalse(args[1])
 
 
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(HostInfoLinux, 'register')
-  def test_heartbeat_host_check_no_cmd(self, register_mock):
+  def test_heartbeat_host_check_no_cmd(self, register_mock, Popen_mock):
     config = AmbariConfig.AmbariConfig()
     config.set('agent', 'prefix', 'tmp')
     config.set('agent', 'cache_dir', "/var/lib/ambari-agent/cache")

http://git-wip-us.apache.org/repos/asf/ambari/blob/991feb73/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
index 18a1c15..bac4945 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestRegistration.py
@@ -33,13 +33,14 @@ from ambari_agent.Facter import FacterLinux
 @not_for_platform(PLATFORM_WINDOWS)
 class TestRegistration(TestCase):
 
+  @patch("subprocess.Popen")
   @patch.object(Hardware, "_chk_mount", new = MagicMock(return_value=True))
   @patch.object(FacterLinux, "facterInfo", new = MagicMock(return_value={}))
   @patch.object(FacterLinux, "__init__", new = MagicMock(return_value = None))
   @patch("ambari_commons.firewall.run_os_command")
   @patch.object(OSCheck, "get_os_type")
   @patch.object(OSCheck, "get_os_version")
-  def test_registration_build(self, get_os_version_mock, get_os_type_mock, run_os_cmd_mock):
+  def test_registration_build(self, get_os_version_mock, get_os_type_mock, run_os_cmd_mock, Popen_mock):
     config = AmbariConfig().getConfig()
     tmpdir = tempfile.gettempdir()
     config.set('agent', 'prefix', tmpdir)