You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@slider.apache.org by sm...@apache.org on 2014/11/09 17:15:55 UTC

incubator-slider git commit: Test Commit 4

Repository: incubator-slider
Updated Branches:
  refs/heads/feature/python_unittests 52591a9fa -> 4c21c63a3


Test Commit 4


Project: http://git-wip-us.apache.org/repos/asf/incubator-slider/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-slider/commit/4c21c63a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-slider/tree/4c21c63a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-slider/diff/4c21c63a

Branch: refs/heads/feature/python_unittests
Commit: 4c21c63a3c09134b3bc1f015d22f8c5337a7ad99
Parents: 52591a9
Author: Sumit Mohanty <sm...@hortonworks.com>
Authored: Sun Nov 9 08:15:49 2014 -0800
Committer: Sumit Mohanty <sm...@hortonworks.com>
Committed: Sun Nov 9 08:15:49 2014 -0800

----------------------------------------------------------------------
 slider-agent/src/main/python/agent/main.py      |   3 +-
 .../src/test/python/agent/TestActionQueue.py    |  15 +++
 .../src/test/python/agent/TestPythonExecutor.py |   2 +-
 .../resource_management/TestContentSources.py   | 124 -------------------
 4 files changed, 18 insertions(+), 126 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4c21c63a/slider-agent/src/main/python/agent/main.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/main/python/agent/main.py b/slider-agent/src/main/python/agent/main.py
index 48d84cd..3a75cb1 100644
--- a/slider-agent/src/main/python/agent/main.py
+++ b/slider-agent/src/main/python/agent/main.py
@@ -172,7 +172,8 @@ def stop_agent():
     if pid == -1:
       print ("Agent process is not running")
     else:
-      os.kill(pid, signal.SIGKILL)
+      if not IS_WINDOWS:
+        os.kill(pid, signal.SIGKILL)
     os._exit(1)
 
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4c21c63a/slider-agent/src/test/python/agent/TestActionQueue.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/test/python/agent/TestActionQueue.py b/slider-agent/src/test/python/agent/TestActionQueue.py
index 1a0b2cf..48260a0 100644
--- a/slider-agent/src/test/python/agent/TestActionQueue.py
+++ b/slider-agent/src/test/python/agent/TestActionQueue.py
@@ -38,6 +38,8 @@ from CustomServiceOrchestrator import CustomServiceOrchestrator
 from PythonExecutor import PythonExecutor
 from CommandStatusDict import CommandStatusDict
 from AgentToggleLogger import AgentToggleLogger
+import platform
+IS_WINDOWS = platform.system() == "Windows"
 
 
 class TestActionQueue(TestCase):
@@ -347,6 +349,19 @@ class TestActionQueue(TestCase):
                 'taskId': 3,
                 'exitcode': 777,
                 'reportResult': True}
+    if IS_WINDOWS:
+      expected = {'status': 'IN_PROGRESS',
+                  'stderr': 'Read from {0}\\errors-3.txt'.format(tempdir),
+                  'stdout': 'Read from {0}\\output-3.txt'.format(tempdir),
+                  'structuredOut': '',
+                  'clusterName': u'cc',
+                  'roleCommand': u'INSTALL',
+                  'serviceName': u'HBASE',
+                  'role': u'HBASE_MASTER',
+                  'actionId': '1-1',
+                  'taskId': 3,
+                  'exitcode': 777,
+                  'reportResult': True}
     self.assertEqual(report['reports'][0], expected)
     # Continue command execution
     unfreeze_flag.set()

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4c21c63a/slider-agent/src/test/python/agent/TestPythonExecutor.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/test/python/agent/TestPythonExecutor.py b/slider-agent/src/test/python/agent/TestPythonExecutor.py
index 630d18c..5451e65 100644
--- a/slider-agent/src/test/python/agent/TestPythonExecutor.py
+++ b/slider-agent/src/test/python/agent/TestPythonExecutor.py
@@ -136,7 +136,7 @@ class TestPythonExecutor(TestCase):
     executor.runShellKillPgrp = runShellKillPgrp_method
     subproc_mock.returncode = 0
     subproc_mock.should_finish_event.set()
-    result = executor.run_file("file", ["arg1", "arg2"], tmpoutfile, tmperrfile, PYTHON_TIMEOUT_SECONDS, tmpstroutfile, "INFO")
+    result = executor.run_file("file", ["arg1", "arg2"], tmpoutfile, tmperrfile, PYTHON_TIMEOUT_SECONDS, tmpstroutfile, "INFO", True, None)
     self.assertEquals(result, {'exitcode': 0, 'stderr': 'Dummy err', 'stdout': 'Dummy output',
                                'structuredOut': {}})
 

http://git-wip-us.apache.org/repos/asf/incubator-slider/blob/4c21c63a/slider-agent/src/test/python/resource_management/TestContentSources.py
----------------------------------------------------------------------
diff --git a/slider-agent/src/test/python/resource_management/TestContentSources.py b/slider-agent/src/test/python/resource_management/TestContentSources.py
index 2527f30..3913ba1 100644
--- a/slider-agent/src/test/python/resource_management/TestContentSources.py
+++ b/slider-agent/src/test/python/resource_management/TestContentSources.py
@@ -108,130 +108,6 @@ class TestContentSources(TestCase):
     self.assertEqual(exists_mock.call_count, 1)
     pass
 
-  @patch.object(urllib2, "urlopen")
-  @patch.object(os, "makedirs")
-  @patch.object(os.path, "exists")
-  def test_download_source_get_content_nocache(self, exists_mock, makedirs_mock, urlopen_mock):
-    """
-    Testing DownloadSource.get_content without cache
-    """
-    exists_mock.return_value = True
-    web_file_mock = MagicMock()
-    web_file_mock.read.return_value = 'web_content'
-    urlopen_mock.return_value = web_file_mock
-
-    with Environment("/base") as env:
-      download_source = DownloadSource("http://download/source", cache=False)
-    content = download_source.get_content()
-
-    self.assertEqual('web_content', content)
-    self.assertEqual(urlopen_mock.call_count, 1)
-    urlopen_mock.assert_called_with('http://download/source')
-    self.assertEqual(web_file_mock.read.call_count, 1)
-
-  @patch.object(urllib2, "urlopen")
-  @patch.object(os, "makedirs")
-  @patch.object(os.path, "exists")
-  def test_download_source_get_content_cache_new(self, exists_mock, makedirs_mock, urlopen_mock):
-    """
-    Testing DownloadSource.get_content with cache on non-cached resource
-    """
-    exists_mock.side_effect = [True, False]
-    web_file_mock = MagicMock()
-    web_file_mock.read.return_value = 'web_content'
-    urlopen_mock.return_value = web_file_mock
-
-    with Environment("/base") as env:
-      download_source = DownloadSource("http://download/source", cache=True)
-    content = download_source.get_content()
-
-    self.assertEqual('web_content', content)
-    self.assertEqual(urlopen_mock.call_count, 1)
-    urlopen_mock.assert_called_with('http://download/source')
-    self.assertEqual(web_file_mock.read.call_count, 1)
-
-  @patch("__builtin__.open")
-  @patch.object(os, "makedirs")
-  @patch.object(os.path, "exists")
-  def test_download_source_get_content_cache_existent(self, exists_mock, makedirs_mock, open_mock):
-    """
-    Testing DownloadSource.get_content with cache on cached resource
-    """
-    exists_mock.side_effect = [True, True, False]
-
-    file_mock = MagicMock(name = 'file_mock')
-    file_mock.__enter__.return_value = file_mock
-    file_mock.read.return_value = 'cached_content'
-    open_mock.return_value = file_mock
-
-
-    with Environment("/base") as env:
-      download_source = DownloadSource("http://download/source", cache=True)
-    content = download_source.get_content()
-
-    self.assertEqual('cached_content', content)
-    self.assertEqual(open_mock.call_count, 1)
-    open_mock.assert_called_with('/var/tmp/downloads/source')
-    self.assertEqual(file_mock.read.call_count, 1)
-
-  @patch.object(urllib2, "urlopen")
-  @patch("__builtin__.open")
-  @patch.object(os, "makedirs")
-  @patch.object(os.path, "exists")
-  def test_download_source_get_content_cache_existent_md5_match(self, exists_mock, makedirs_mock, open_mock,
-                                                                urlopen_mock):
-    """
-    Testing DownloadSource.get_content with cache on cached resource with md5 check
-    """
-    exists_mock.side_effect = [True, True, False]
-
-    file_mock = MagicMock(name = 'file_mock')
-    file_mock.__enter__.return_value = file_mock
-    file_mock.read.return_value = 'cached_content'
-    open_mock.return_value = file_mock
-
-
-    with Environment("/base") as env:
-      download_source = DownloadSource("http://download/source", cache=True)
-    content = download_source.get_content()
-
-    self.assertEqual('cached_content', content)
-    self.assertEqual(open_mock.call_count, 1)
-    open_mock.assert_called_with('/var/tmp/downloads/source')
-    self.assertEqual(file_mock.read.call_count, 1)
-    self.assertEqual(urlopen_mock.call_count, 0)
-
-  @patch.object(urllib2, "urlopen")
-  @patch("__builtin__.open")
-  @patch.object(os, "makedirs")
-  @patch.object(os.path, "exists")
-  def test_download_source_get_content_cache_existent_md5_unmatch(self, exists_mock, makedirs_mock, open_mock,
-                                                                  urlopen_mock):
-    """
-    Testing DownloadSource.get_content with cache on cached resource with md5 check
-    """
-    exists_mock.side_effect = [True, True, False]
-    fake_md5 = "144c9defac04969c7bfad8efaa8ea194"
-    file_mock = MagicMock(name = 'file_mock')
-    file_mock.__enter__.return_value = file_mock
-    file_mock.read.return_value = 'cached_content'
-    open_mock.return_value = file_mock
-    web_file_mock = MagicMock()
-    web_file_mock.read.return_value = 'web_content'
-    urlopen_mock.return_value = web_file_mock
-
-    with Environment("/base") as env:
-      download_source = DownloadSource("http://download/source", cache=True, md5sum=fake_md5)
-    content = download_source.get_content()
-
-    self.assertEqual('web_content', content)
-    self.assertEqual(open_mock.call_count, 2)
-    open_mock.assert_once_called('/var/tmp/downloads/source', 'w')
-    open_mock.assert_once_called('/var/tmp/downloads/source')
-    self.assertEqual(file_mock.read.call_count, 1)
-    self.assertEqual(urlopen_mock.call_count, 1)
-    urlopen_mock.assert_called_with('http://download/source')
-
   @patch("__builtin__.open")
   @patch.object(os.path, "getmtime")
   @patch.object(os.path, "exists")