You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/12/08 16:25:50 UTC

ambari git commit: AMBARI-14268. UT failures for Ambari Server and Agent in trunk and branch-2.2.(vbrodetskyi)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 e1232f334 -> e1f407c60


AMBARI-14268. UT failures for Ambari Server and Agent in trunk and branch-2.2.(vbrodetskyi)


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

Branch: refs/heads/branch-2.2
Commit: e1f407c60b585845cd82db869528162ca07f1901
Parents: e1232f3
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Tue Dec 8 17:25:02 2015 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Tue Dec 8 17:25:02 2015 +0200

----------------------------------------------------------------------
 .../ambari_agent/TestHostCheckReportFileHandler.py     | 13 +++++++++++--
 .../python/resource_management/TestLinkResource.py     |  6 +++---
 .../src/test/python/stacks/2.0.6/HDFS/test_datanode.py | 13 +++++++++----
 .../test/python/stacks/2.0.6/HIVE/test_hive_client.py  |  4 +++-
 .../test/python/stacks/2.0.6/HIVE/test_hive_server.py  |  4 +++-
 .../python/stacks/2.0.6/OOZIE/test_oozie_client.py     |  5 +++--
 .../test/python/stacks/2.0.6/YARN/test_nodemanager.py  |  4 +++-
 .../test/python/stacks/2.1/HIVE/test_hive_metastore.py |  4 +++-
 8 files changed, 38 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py b/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
index c595082..fcfc29e 100644
--- a/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
+++ b/ambari-agent/src/test/python/ambari_agent/TestHostCheckReportFileHandler.py
@@ -49,8 +49,13 @@ class TestHostCheckReportFileHandler(TestCase):
       users = configValidator.get('users', 'usr_list')
       self.assertEquals(users, '')
 
-  def test_write_host_check_report_empty(self):
+
+  @patch("os.path.exists")
+  @patch("os.listdir")
+  def test_write_host_check_report_empty(self, list_mock, exists_mock):
     tmpfile = tempfile.mktemp()
+    exists_mock.return_value = False
+    list_mock.return_value = []
 
     config = ConfigParser.RawConfigParser()
     config.add_section('agent')
@@ -88,8 +93,12 @@ class TestHostCheckReportFileHandler(TestCase):
     time = configValidator.get('metadata', 'created')
     self.assertTrue(time != None)
 
-  def test_write_host_check_report(self):
+  @patch("os.path.exists")
+  @patch("os.listdir")
+  def test_write_host_check_report(self, list_mock, exists_mock):
     tmpfile = tempfile.mktemp()
+    exists_mock.return_value = False
+    list_mock.return_value = []
 
     config = ConfigParser.RawConfigParser()
     config.add_section('agent')

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-agent/src/test/python/resource_management/TestLinkResource.py
----------------------------------------------------------------------
diff --git a/ambari-agent/src/test/python/resource_management/TestLinkResource.py b/ambari-agent/src/test/python/resource_management/TestLinkResource.py
index ceac076..2fa0ad3 100644
--- a/ambari-agent/src/test/python/resource_management/TestLinkResource.py
+++ b/ambari-agent/src/test/python/resource_management/TestLinkResource.py
@@ -134,9 +134,9 @@ class TestLinkResource(TestCase):
                        str(e)) 
         
   @patch.object(sudo, "unlink")
-  @patch.object(sudo, "path_exists")
-  def test_action_delete(self, exists_mock, unlink_mock):     
-    exists_mock.return_value = True
+  @patch.object(sudo, "path_lexists")
+  def test_action_delete(self, lexists_mock, unlink_mock):
+    lexists_mock.return_value = True
     
     with Environment('/') as env:
       Link("/some_path",

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py
index c6f8c1d..ab6fa5c 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HDFS/test_datanode.py
@@ -475,8 +475,9 @@ class TestDatanode(RMFTestCase):
        mocks_dict['call'].call_args_list[0][0][0])
 
 
+  @patch("socket.gethostbyname")
   @patch('time.sleep')
-  def test_post_upgrade_restart(self, time_mock):
+  def test_post_upgrade_restart(self, time_mock, socket_gethostbyname_mock):
     shell_call_output = """
       Live datanodes (2):
 
@@ -498,6 +499,7 @@ class TestDatanode(RMFTestCase):
       Last contact: Fri Dec 12 20:47:21 UTC 2014
     """
     mocks_dict = {}
+    socket_gethostbyname_mock.return_value = "test_host"
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/datanode.py",
                        classname = "DataNode",
                        command = "post_upgrade_restart",
@@ -512,10 +514,11 @@ class TestDatanode(RMFTestCase):
     self.assertEqual(mocks_dict['call'].call_count,1)
 
 
-
+  @patch("socket.gethostbyname")
   @patch('time.sleep')
-  def test_post_upgrade_restart_datanode_not_ready(self, time_mock):
+  def test_post_upgrade_restart_datanode_not_ready(self, time_mock, socket_gethostbyname_mock):
     mocks_dict = {}
+    socket_gethostbyname_mock.return_value = "test_host"
     try:
       self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/datanode.py",
                          classname = "DataNode",
@@ -532,10 +535,12 @@ class TestDatanode(RMFTestCase):
       self.assertEqual(mocks_dict['call'].call_count,12)
 
 
+  @patch("socket.gethostbyname")
   @patch('time.sleep')
-  def test_post_upgrade_restart_bad_returncode(self, time_mock):
+  def test_post_upgrade_restart_bad_returncode(self, time_mock, socket_gethostbyname_mock):
     try:
       mocks_dict = {}
+      socket_gethostbyname_mock.return_value = "test_host"
       self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/datanode.py",
                          classname = "DataNode",
                          command = "post_upgrade_restart",

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_client.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_client.py
index 7de494e..40b475d 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_client.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_client.py
@@ -191,9 +191,11 @@ class TestHiveClient(RMFTestCase):
                               ('hdp-select', 'set', 'hadoop-client', version), sudo=True,)
     self.assertNoMoreResources()
 
+  @patch("os.path.exists")
   @patch("resource_management.core.shell.call")
-  def test_pre_upgrade_restart_23(self, call_mock):
+  def test_pre_upgrade_restart_23(self, call_mock, os_path__exists_mock):
     config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    os_path__exists_mock.return_value = False
     with open(config_file, "r") as f:
       json_content = json.load(f)
     version = '2.3.0.0-1234'

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
index 4c7cfe6..43d27d7 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/HIVE/test_hive_server.py
@@ -918,11 +918,13 @@ From source with checksum 150f554beae04f76f814f59549dead8b"""
     )
     self.assertNoMoreResources()
 
+  @patch("os.path.exists")
   @patch("resource_management.core.shell.call")
   @patch.object(Script, "is_hdp_stack_greater_or_equal", new = MagicMock(return_value=True))
   @patch("resource_management.libraries.functions.copy_tarball.copy_to_hdfs")
-  def test_pre_upgrade_restart_23(self, copy_to_hdfs_mock, call_mock):
+  def test_pre_upgrade_restart_23(self, copy_to_hdfs_mock, call_mock, os_path__exists_mock):
     config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    os_path__exists_mock.return_value = False
     with open(config_file, "r") as f:
       json_content = json.load(f)
     version = '2.3.0.0-1234'

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
index d310b7c..dd36ba9 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/OOZIE/test_oozie_client.py
@@ -214,10 +214,11 @@ class TestOozieClient(RMFTestCase):
                               ('hdp-select', 'set', 'oozie-client', version), sudo=True)
     self.assertNoMoreResources()
 
-  
+  @patch("os.path.exists")
   @patch("resource_management.core.shell.call")
-  def test_pre_upgrade_restart_23(self, call_mock):
+  def test_pre_upgrade_restart_23(self, call_mock, os_path__exists_mock):
     config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    os_path__exists_mock.return_value = False
     with open(config_file, "r") as f:
       json_content = json.load(f)
     version = '2.3.0.0-1234'

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py
index 7779792..e25f460 100644
--- a/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py
+++ b/ambari-server/src/test/python/stacks/2.0.6/YARN/test_nodemanager.py
@@ -522,13 +522,15 @@ class TestNodeManager(RMFTestCase):
                               group = 'hadoop',
                               )
 
+  @patch("socket.gethostbyname")
   @patch('time.sleep')
   @patch.object(resource_management.libraries.functions, "get_hdp_version", new = MagicMock(return_value='2.3.0.0-1234'))
-  def test_post_upgrade_restart(self, time_mock):
+  def test_post_upgrade_restart(self, time_mock, socket_gethostbyname_mock):
     process_output = """
       c6401.ambari.apache.org:45454  RUNNING  c6401.ambari.apache.org:8042  0
     """
     mocks_dict = {}
+    socket_gethostbyname_mock.return_value = "test_host"
 
     self.executeScript(self.COMMON_SERVICES_PACKAGE_DIR + "/scripts/nodemanager.py",
       classname = "Nodemanager",

http://git-wip-us.apache.org/repos/asf/ambari/blob/e1f407c6/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
index 1c798b1..2560273 100644
--- a/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
+++ b/ambari-server/src/test/python/stacks/2.1/HIVE/test_hive_metastore.py
@@ -504,9 +504,11 @@ class TestHiveMetastore(RMFTestCase):
                               ('hdp-select', 'set', 'hive-metastore', version), sudo=True,)
     self.assertNoMoreResources()
 
+  @patch("os.path.exists")
   @patch("resource_management.core.shell.call")
-  def test_pre_upgrade_restart_23(self, call_mock):
+  def test_pre_upgrade_restart_23(self, call_mock, os_path__exists_mock):
     config_file = self.get_src_folder()+"/test/python/stacks/2.0.6/configs/default.json"
+    os_path__exists_mock.return_value = False
     with open(config_file, "r") as f:
       json_content = json.load(f)
     version = '2.3.0.0-1234'