Repository: ambari Updated Branches: refs/heads/branch-2.0.0 ee666561a -> 4db3c6b4f refs/heads/trunk 0ae915896 -> e0ee513d3
AMBARI-9975. Local unit tests failing in TestCheckHost.py (aonishuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/e0ee513d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/e0ee513d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/e0ee513d Branch: refs/heads/trunk Commit: e0ee513d36733dc6ea4256461102db9d72e69944 Parents: 0ae9158 Author: Andrew Onishuk <[email protected]> Authored: Sat Mar 7 17:42:00 2015 +0200 Committer: Andrew Onishuk <[email protected]> Committed: Sat Mar 7 17:42:00 2015 +0200 ---------------------------------------------------------------------- .../src/test/python/custom_actions/TestCheckHost.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/e0ee513d/ambari-server/src/test/python/custom_actions/TestCheckHost.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/test/python/custom_actions/TestCheckHost.py b/ambari-server/src/test/python/custom_actions/TestCheckHost.py index 101eac9..ff16298 100644 --- a/ambari-server/src/test/python/custom_actions/TestCheckHost.py +++ b/ambari-server/src/test/python/custom_actions/TestCheckHost.py @@ -32,6 +32,7 @@ from unittest import TestCase from check_host import CheckHost from only_for_platform import only_for_platform, get_platform, PLATFORM_LINUX, PLATFORM_WINDOWS +from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler if get_platform() != PLATFORM_WINDOWS: os_distro_value = ('Suse','11','Final') @@ -39,7 +40,10 @@ else: os_distro_value = ('win2012serverr2','6.3','WindowsServer') [email protected](HostCheckReportFileHandler, "writeHostChecksCustomActionsFile", new=MagicMock()) [email protected](HostCheckReportFileHandler, "resolve_ambari_config", new=MagicMock()) class TestCheckHost(TestCase): + current_dir = os.path.dirname(os.path.realpath(__file__)) @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value)) @patch("os.path.isfile") @patch.object(Script, 'get_config') @@ -55,8 +59,6 @@ class TestCheckHost(TestCase): checkHost = CheckHost() checkHost.actionexecute(None) - print os_isfile_mock.call_args - self.assertEquals(os_isfile_mock.call_args[0][0], '/tmp/ambari-agent/hostcheck_custom_actions.result') self.assertEquals(structured_out_mock.call_args[0][0], {'java_home_check': {'message': 'Java home exists!', 'exit_code': 0}}) # test, java home doesn't exist @@ -65,7 +67,6 @@ class TestCheckHost(TestCase): checkHost.actionexecute(None) - self.assertEquals(os_isfile_mock.call_args[0][0], '/tmp/ambari-agent/hostcheck_custom_actions.result') self.assertEquals(structured_out_mock.call_args[0][0], {'java_home_check': {"message": "Java home doesn't exist!", "exit_code" : 1}}) @@ -186,7 +187,7 @@ class TestCheckHost(TestCase): @patch("resource_management.libraries.script.Script.put_structured_out") def testHostResolution(self, structured_out_mock, get_tmp_dir_mock, mock_config, mock_socket): mock_socket.return_value = "192.168.1.1" - jsonFilePath = os.path.join("../resources/custom_actions", "check_host_ip_addresses.json") + jsonFilePath = os.path.join(TestCheckHost.current_dir+"/../../resources/custom_actions", "check_host_ip_addresses.json") with open(jsonFilePath, "r") as jsonFile: jsonPayload = json.load(jsonFile) @@ -225,7 +226,7 @@ class TestCheckHost(TestCase): @patch.object(Script, 'get_tmp_dir') @patch("resource_management.libraries.script.Script.put_structured_out") def testInvalidCheck(self, structured_out_mock, get_tmp_dir_mock, mock_config): - jsonFilePath = os.path.join("../resources/custom_actions", "invalid_check.json") + jsonFilePath = os.path.join(TestCheckHost.current_dir+"/../../resources/custom_actions", "invalid_check.json") with open(jsonFilePath, "r") as jsonFile: jsonPayload = json.load(jsonFile) @@ -256,7 +257,7 @@ class TestCheckHost(TestCase): def testLastAgentEnv(self, time_mock, checkReverseLookup_mock, checkIptables_mock, getTransparentHugePage_mock, getUMask_mock, checkLiveServices_mock, javaProcs_mock, put_structured_out_mock, get_tmp_dir_mock, get_config_mock, systemmock): - jsonFilePath = os.path.join("../resources/custom_actions", "check_last_agent_env.json") + jsonFilePath = os.path.join(TestCheckHost.current_dir+"/../../resources/custom_actions", "check_last_agent_env.json") with open(jsonFilePath, "r") as jsonFile: jsonPayload = json.load(jsonFile)
