|
@@ -32,26 +32,19 @@ import ambari_commons
|
|
|
from ambari_commons import OSCheck
|
|
|
import os
|
|
|
from only_for_platform import not_for_platform, get_platform, PLATFORM_WINDOWS, PLATFORM_LINUX
|
|
|
-
|
|
|
-if get_platform() != PLATFORM_WINDOWS:
|
|
|
- os_distro_value = ('Suse','11','Final')
|
|
|
-else:
|
|
|
- os_distro_value = ('win2012serverr2','6.3','WindowsServer')
|
|
|
-
|
|
|
-with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value)):
|
|
|
- from ambari_commons.firewall import Firewall
|
|
|
- from ambari_commons.os_check import OSCheck, OSConst
|
|
|
- from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
|
|
|
- from ambari_agent.HostInfo import HostInfo, HostInfoLinux
|
|
|
- from ambari_agent.Hardware import Hardware
|
|
|
- from ambari_agent.AmbariConfig import AmbariConfig
|
|
|
- from resource_management.core.system import System
|
|
|
- from resource_management.libraries.functions import packages_analyzer
|
|
|
-
|
|
|
-@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
|
|
|
+from ambari_commons.firewall import Firewall
|
|
|
+from ambari_commons.os_check import OSCheck, OSConst
|
|
|
+from ambari_agent.HostCheckReportFileHandler import HostCheckReportFileHandler
|
|
|
+from ambari_agent.HostInfo import HostInfo, HostInfoLinux
|
|
|
+from ambari_agent.Hardware import Hardware
|
|
|
+from ambari_agent.AmbariConfig import AmbariConfig
|
|
|
+from resource_management.core.system import System
|
|
|
+from resource_management.libraries.functions import packages_analyzer
|
|
|
+
|
|
|
+@not_for_platform(PLATFORM_WINDOWS)
|
|
|
+@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = ('Suse','11','Final')))
|
|
|
class TestHostInfo(TestCase):
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, 'get_os_family')
|
|
|
@patch('resource_management.libraries.functions.packages_analyzer.subprocessWithTimeout')
|
|
|
def test_analyze_zypper_out(self, spwt_mock, get_os_family_mock):
|
|
@@ -82,7 +75,6 @@ class TestHostInfo(TestCase):
|
|
|
self.assertTrue(installedPackages[3][2], "HDP")
|
|
|
self.assertTrue(installedPackages[6][1], "11-38.13.9")
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
def test_perform_package_analysis(self):
|
|
|
installedPackages = [
|
|
|
["hadoop-a", "2.3", "HDP"], ["zk", "3.1", "HDP"], ["webhcat", "3.1", "HDP"],
|
|
@@ -129,7 +121,6 @@ class TestHostInfo(TestCase):
|
|
|
for package in expected:
|
|
|
self.assertTrue(package in allPackages)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, 'get_os_family')
|
|
|
@patch('resource_management.libraries.functions.packages_analyzer.subprocessWithTimeout')
|
|
|
def test_analyze_yum_output(self, subprocessWithTimeout_mock, get_os_family_mock):
|
|
@@ -185,7 +176,6 @@ class TestHostInfo(TestCase):
|
|
|
"koji-override-0/$releasever"])
|
|
|
self.assertFalse(package['repoName'] in ["AMBARI.dev-1.x"])
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, 'get_os_family')
|
|
|
@patch('resource_management.libraries.functions.packages_analyzer.subprocessWithTimeout')
|
|
|
def test_analyze_yum_output_err(self, subprocessWithTimeout_mock, get_os_family_mock):
|
|
@@ -216,8 +206,6 @@ class TestHostInfo(TestCase):
|
|
|
|
|
|
self.assertTrue(item in names)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
- @patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
|
|
|
@patch('os.path.exists')
|
|
|
@patch('__builtin__.open')
|
|
|
def test_checkUsers(self, builtins_open_mock, path_mock):
|
|
@@ -239,7 +227,6 @@ class TestHostInfo(TestCase):
|
|
|
self.assertTrue(newlist[1]['status'], "Invalid home directory")
|
|
|
print(path_mock.mock_calls)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "get_os_type")
|
|
|
@patch('os.umask')
|
|
|
@patch.object(HostCheckReportFileHandler, 'writeHostCheckFile')
|
|
@@ -277,7 +264,6 @@ class TestHostInfo(TestCase):
|
|
|
|
|
|
self.assertTrue('agentTimeStampAtReporting' in dict['hostHealth'])
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "get_os_type")
|
|
|
@patch('os.umask')
|
|
|
@patch.object(HostCheckReportFileHandler, 'writeHostCheckFile')
|
|
@@ -370,7 +356,6 @@ class TestHostInfo(TestCase):
|
|
|
result = host.dirType("/home")
|
|
|
self.assertEquals(result, 'unknown')
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch("os.path.exists")
|
|
|
@patch("glob.glob")
|
|
|
def test_hadoopVarRunCount(self, glob_glob_mock, os_path_exists_mock):
|
|
@@ -385,7 +370,6 @@ class TestHostInfo(TestCase):
|
|
|
result = hostInfo.hadoopVarRunCount()
|
|
|
self.assertEquals(result, 0)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch("os.path.exists")
|
|
|
@patch("glob.glob")
|
|
|
def test_hadoopVarLogCount(self, glob_glob_mock, os_path_exists_mock):
|
|
@@ -400,7 +384,6 @@ class TestHostInfo(TestCase):
|
|
|
result = hostInfo.hadoopVarLogCount()
|
|
|
self.assertEquals(result, 0)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = ('redhat','11','Final')))
|
|
|
@patch("os.listdir", create=True, autospec=True)
|
|
|
@patch("__builtin__.open", create=True, autospec=True)
|
|
@@ -422,7 +405,6 @@ class TestHostInfo(TestCase):
|
|
|
self.assertTrue(list[0]['hadoop'])
|
|
|
self.assertEquals(list[0]['user'], 'user')
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch("subprocess.Popen")
|
|
|
@patch.object(Hardware, 'extractMountInfo')
|
|
|
def test_osdiskAvailableSpace(self, extract_mount_info_mock, subproc_popen_mock):
|
|
@@ -440,7 +422,6 @@ class TestHostInfo(TestCase):
|
|
|
|
|
|
self.assertEquals(result, {})
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "get_os_type")
|
|
|
@patch("subprocess.Popen")
|
|
|
def test_checkLiveServices(self, subproc_popen, get_os_type_method):
|
|
@@ -484,7 +465,6 @@ class TestHostInfo(TestCase):
|
|
|
self.assertEquals(result[0]['name'], 'service1')
|
|
|
self.assertTrue(len(result[0]['desc']) > 0)
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = ('redhat','11','Final')))
|
|
|
@patch("os.path.exists")
|
|
|
@patch("os.listdir", create=True, autospec=True)
|
|
@@ -507,7 +487,6 @@ class TestHostInfo(TestCase):
|
|
|
self.assertEquals(result[0]['name'], 'config1')
|
|
|
self.assertEquals(result[0]['target'], 'real_path_to_conf')
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "get_os_family")
|
|
|
@patch.object(OSCheck, "get_os_type")
|
|
|
@patch.object(OSCheck, "get_os_major_version")
|
|
@@ -543,7 +522,6 @@ class TestHostInfo(TestCase):
|
|
|
|
|
|
self.assertFalse(hostInfo.checkReverseLookup())
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "get_os_family")
|
|
|
@patch.object(OSCheck, "get_os_type")
|
|
|
@patch.object(OSCheck, "get_os_major_version")
|
|
@@ -554,7 +532,6 @@ class TestHostInfo(TestCase):
|
|
|
run_os_command_mock.return_value = 3, "", ""
|
|
|
self.assertFalse(Firewall().getFirewallObject().check_firewall())
|
|
|
|
|
|
- @not_for_platform(PLATFORM_WINDOWS)
|
|
|
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = ('redhat','11','Final')))
|
|
|
@patch("os.path.isfile")
|
|
|
@patch('__builtin__.open')
|