ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yus...@apache.org
Subject git commit: AMBARI-8032. ambari-server unit test failures: testDBConnectionCheck failure. (Florian Barca via yusaku)
Date Thu, 30 Oct 2014 21:46:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-windows-dev e51e6f1fd -> e3277f9f4


AMBARI-8032. ambari-server unit test failures: testDBConnectionCheck failure. (Florian Barca
via yusaku)


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

Branch: refs/heads/branch-windows-dev
Commit: e3277f9f41147a0eccfd25d4c5d3381ab30925fb
Parents: e51e6f1
Author: Yusaku Sako <yusaku@hortonworks.com>
Authored: Thu Oct 30 14:46:22 2014 -0700
Committer: Yusaku Sako <yusaku@hortonworks.com>
Committed: Thu Oct 30 14:46:22 2014 -0700

----------------------------------------------------------------------
 ambari-server/src/test/python/TestCheckHost.py | 51 ++++++++++-----------
 1 file changed, 24 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/e3277f9f/ambari-server/src/test/python/TestCheckHost.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestCheckHost.py b/ambari-server/src/test/python/TestCheckHost.py
index d4fbeb1..e2494c6 100644
--- a/ambari-server/src/test/python/TestCheckHost.py
+++ b/ambari-server/src/test/python/TestCheckHost.py
@@ -22,6 +22,8 @@ from stacks.utils.RMFTestCase import *
 import json
 import os
 import socket
+import subprocess
+from ambari_commons import inet_utils
 from resource_management import Script,ConfigDictionary
 from mock.mock import patch
 from mock.mock import MagicMock
@@ -62,12 +64,12 @@ class TestCheckHost(TestCase):
 
   @patch.object(Script, 'get_config')
   @patch.object(Script, 'get_tmp_dir')
-  @patch("check_host.Execute")
+  @patch("check_host.download_file")
   @patch("resource_management.libraries.script.Script.put_structured_out")
   @patch("subprocess.Popen")
   @patch("check_host.format")
   @patch("os.path.isfile")
-  def testDBConnectionCheck(self, isfile_mock, format_mock, popenMock, structured_out_mock,
execute_mock, get_tmp_dir_mock, mock_config):
+  def testDBConnectionCheck(self, isfile_mock, format_mock, popenMock, structured_out_mock,
download_file_mock, get_tmp_dir_mock, mock_config):
     # test, download DBConnectionVerification.jar failed
     mock_config.return_value = {"commandParams" : {"check_execute_list" : "db_connection_check",
                                                    "java_home" : "test_java_home",
@@ -77,9 +79,10 @@ class TestCheckHost(TestCase):
                                                    "db_connection_url" : "test_db_connection_url",
                                                    "user_name" : "test_user_name",
                                                    "user_passwd" : "test_user_passwd",
-                                                   "jdk_name" : "test_jdk_name"}}
+                                                   "jdk_name" : "test_jdk_name"},
+                                "hostLevelParams": { "agentCacheDir": "/nonexistent_tmp"
}}
     get_tmp_dir_mock.return_value = "/tmp"
-    execute_mock.side_effect = Exception("test exception")
+    download_file_mock.side_effect = Exception("test exception")
     isfile_mock.return_value = True
     checkHost = CheckHost()
     checkHost.actionexecute(None)
@@ -87,11 +90,6 @@ class TestCheckHost(TestCase):
     self.assertEquals(structured_out_mock.call_args[0][0], {'db_connection_check': {'message':
'Error downloading ' \
                      'DBConnectionVerification.jar from Ambari Server resources. Check network
access to Ambari ' \
                      'Server.\ntest exception', 'exit_code': 1}})
-    
-    self.assertEquals(format_mock.call_args_list[2][0][0], "/bin/sh -c 'cd /usr/lib/ambari-agent/
&& curl -kf " \
-                      "--retry 5 {jdk_location}{check_db_connection_jar_name} -o {check_db_connection_jar_name}'")
-    
-    self.assertEquals(format_mock.call_args_list[3][0][0], "[ -f /usr/lib/ambari-agent/{check_db_connection_jar_name}]")
 
     # test, download jdbc driver failed
     mock_config.return_value = {"commandParams" : {"check_execute_list" : "db_connection_check",
@@ -102,11 +100,12 @@ class TestCheckHost(TestCase):
                                                    "db_connection_url" : "test_db_connection_url",
                                                    "user_name" : "test_user_name",
                                                    "user_passwd" : "test_user_passwd",
-                                                   "jdk_name" : "test_jdk_name"}}
+                                                   "jdk_name" : "test_jdk_name"},
+                                "hostLevelParams": { "agentCacheDir": "/nonexistent_tmp"
}}
     format_mock.reset_mock()
-    execute_mock.reset_mock()
+    download_file_mock.reset_mock()
     p = MagicMock()
-    execute_mock.side_effect = [p, Exception("test exception")]
+    download_file_mock.side_effect = [p, Exception("test exception")]
 
     checkHost.actionexecute(None)
 
@@ -116,24 +115,21 @@ class TestCheckHost(TestCase):
                   'Server host to make the JDBC driver available for download and to enable
testing '
                   'the database connection.\n')
     self.assertEquals(structured_out_mock.call_args[0][0]['db_connection_check']['exit_code'],
1)
-    self.assertEquals(format_mock.call_args_list[4][0][0], "/bin/sh -c 'cd /usr/lib/ambari-agent/
&& curl -kf " \
-                                                            "--retry 5 {jdbc_url} -o {jdbc_name}'")
-    
-    self.assertEquals(format_mock.call_args_list[5][0][0], "[ -f /usr/lib/ambari-agent/{jdbc_name}]")
 
     # test, no connection to remote db
     mock_config.return_value = {"commandParams" : {"check_execute_list" : "db_connection_check",
                                                    "java_home" : "test_java_home",
                                                    "ambari_server_host" : "test_host",
                                                    "jdk_location" : "test_jdk_location",
-                                                   "db_name" : "postgresql",
+                                                   "db_name" : "postgres",
                                                    "db_connection_url" : "test_db_connection_url",
                                                    "user_name" : "test_user_name",
                                                    "user_passwd" : "test_user_passwd",
-                                                   "jdk_name" : "test_jdk_name"}}
+                                                   "jdk_name" : "test_jdk_name"},
+                                "hostLevelParams": { "agentCacheDir": "/nonexistent_tmp"
}}
     format_mock.reset_mock()
-    execute_mock.reset_mock()
-    execute_mock.side_effect = [p, p]
+    download_file_mock.reset_mock()
+    download_file_mock.side_effect = [p, p]
     s = MagicMock()
     s.communicate.return_value = ("test message", "")
     s.returncode = 1
@@ -143,14 +139,14 @@ class TestCheckHost(TestCase):
 
     self.assertEquals(structured_out_mock.call_args[0][0], {'db_connection_check': {'message':
'test message',
                                                                                     'exit_code':
1}})
-    self.assertEquals(format_mock.call_args[0][0],'{java64_home}/bin/java -cp /usr/lib/ambari-agent/{check_db_'
\
-                                                'connection_jar_name}:/usr/lib/ambari-agent/{jdbc_name}
org.' \
-                                                'apache.ambari.server.DBConnectionVerification
\'{db_connection_url}\' ' \
-                                                '{user_name} {user_passwd!p} {jdbc_driver}')
+    self.assertEquals(format_mock.call_args[0][0],'{java_exec} -cp '\
+            '{check_db_connection_path}{class_path_delimiter}{jdbc_path} -Djava.library.path={agent_cache_dir}
'\
+            'org.apache.ambari.server.DBConnectionVerification {db_connection_url} '\
+            '{user_name} {user_passwd!p} {jdbc_driver}')
 
     # test, db connection success
-    execute_mock.reset_mock()
-    execute_mock.side_effect = [p, p]
+    download_file_mock.reset_mock()
+    download_file_mock.side_effect = [p, p]
     s.returncode = 0
 
     checkHost.actionexecute(None)
@@ -166,7 +162,8 @@ class TestCheckHost(TestCase):
                                                    "db_connection_url" : "test_db_connection_url",
                                                    "user_name" : "test_user_name",
                                                    "user_passwd" : "test_user_passwd",
-                                                   "db_name" : "postgresql"}}
+                                                   "db_name" : "postgres"},
+                                "hostLevelParams": { "agentCacheDir": "/nonexistent_tmp"
}}
 
     isfile_mock.return_value = False
     checkHost.actionexecute(None)


Mime
View raw message