Преглед изворни кода

AMBARI-10166. Enable python unit tests to run on Mac

Sumit Mohanty пре 10 година
родитељ
комит
b681b55a95

+ 2 - 2
ambari-agent/src/test/python/ambari_agent/TestActionQueue.py

@@ -37,7 +37,7 @@ from ambari_agent.CommandStatusDict import CommandStatusDict
 from ambari_agent.ActualConfigHandler import ActualConfigHandler
 from FileCache import FileCache
 from ambari_commons import OSCheck
-from only_for_platform import only_for_platform, get_platform, PLATFORM_LINUX, PLATFORM_WINDOWS
+from only_for_platform import only_for_platform, get_platform, not_for_platform, PLATFORM_LINUX, PLATFORM_WINDOWS
 
 if get_platform() != PLATFORM_WINDOWS:
   os_distro_value = ('Suse','11','Final')
@@ -661,7 +661,7 @@ class TestActionQueue(TestCase):
     report = actionQueue.result()
     self.assertEqual(len(report['reports']),1)
 
-  @only_for_platform(PLATFORM_LINUX)
+  @not_for_platform(PLATFORM_WINDOWS)
   @patch.object(CustomServiceOrchestrator, "resolve_script_path")
   @patch.object(StackVersionsFileHandler, "read_stack_version")
   def test_execute_python_executor(self, read_stack_version_mock, resolve_script_path_mock):

+ 2 - 2
ambari-agent/src/test/python/ambari_agent/TestController.py

@@ -29,7 +29,7 @@ import platform
 from threading import Event
 import json
 from ambari_commons import OSCheck
-from only_for_platform import only_for_platform, get_platform, PLATFORM_LINUX, PLATFORM_WINDOWS
+from only_for_platform import not_for_platform, only_for_platform, get_platform, PLATFORM_LINUX, PLATFORM_WINDOWS
 
 if get_platform() != PLATFORM_WINDOWS:
   os_distro_value = ('Suse','11','Final')
@@ -44,7 +44,7 @@ with patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_
   from ambari_agent.Hardware import Hardware
   import ambari_commons
 
-@only_for_platform(PLATFORM_LINUX)
+@not_for_platform(PLATFORM_WINDOWS)
 @patch.object(OSCheck, "os_distribution", new = os_distro_value)
 class TestController(unittest.TestCase):
 

+ 1 - 1
ambari-agent/src/test/python/unitTests.py

@@ -106,7 +106,7 @@ def main():
       exit(1)
   else:
     logger.info('------------------------------------------------------------------------')
-    logger.info('Python unit tests finished succesfully')
+    logger.info('Python unit tests finished successfully')
     logger.info('------------------------------------------------------------------------')
 
 if __name__ == '__main__':

+ 6 - 0
ambari-common/src/main/python/ambari_commons/os_check.py

@@ -163,6 +163,10 @@ class OSCheck:
         distribution = platform.dist()
       else:
         distribution = platform.linux_distribution()
+
+    if distribution[0] == '' and platform.system().lower() == 'darwin':
+      # mac - used for unit tests
+      distribution = ("Darwin", "TestOnly", "1.1.1", "1.1.1", "1.1")
     
     return distribution
 
@@ -188,6 +192,8 @@ class OSCheck:
       return 'sles'
     elif operatingSystem.startswith('red hat enterprise linux'):
       return 'redhat'
+    elif operatingSystem.startswith('darwin'):
+      return 'mac'
 
     if operatingSystem != '':
       return operatingSystem