You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by dm...@apache.org on 2013/11/25 18:19:18 UTC

git commit: AMBARI-3875. Ambari Client unit test output should be redirected to a log file like the agent logs (Eugene Chekanskiy via dlysnichenko)

Updated Branches:
  refs/heads/trunk a018cc3bc -> b8cc8ea55


AMBARI-3875. Ambari Client unit test output should be redirected to a log file like the agent logs (Eugene Chekanskiy via dlysnichenko)


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

Branch: refs/heads/trunk
Commit: b8cc8ea55dfab5d78aaf45c2493fbafd7cbc59ed
Parents: a018cc3
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Mon Nov 25 19:17:46 2013 +0200
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Mon Nov 25 19:19:05 2013 +0200

----------------------------------------------------------------------
 ambari-client/src/test/python/TestAmbariClient.py        |  7 ++++++-
 ambari-client/src/test/python/TestClusterModel.py        | 10 +++++++---
 ambari-client/src/test/python/TestComponentModel.py      |  6 +++++-
 ambari-client/src/test/python/TestHostModel.py           |  6 +++++-
 ambari-client/src/test/python/TestServiceModel.py        |  6 +++++-
 ambari-client/src/test/python/TestStatusModel.py         |  6 +++++-
 ambari-client/src/test/python/unitTests.py               |  7 ++++++-
 ambari-client/src/test/python/utils/HttpClientInvoker.py |  7 +++++--
 8 files changed, 44 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestAmbariClient.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestAmbariClient.py b/ambari-client/src/test/python/TestAmbariClient.py
index 5e20957..660d105 100755
--- a/ambari-client/src/test/python/TestAmbariClient.py
+++ b/ambari-client/src/test/python/TestAmbariClient.py
@@ -24,9 +24,14 @@ from ambari_client.ambari_api import  AmbariClient
 from HttpClientInvoker import HttpClientInvoker
 from ambari_client.model.stack import StackConfigModel, StackComponentModel
 import unittest
+import logging
 
 class TestAmbariClient(unittest.TestCase):
-  
+
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_client(self, http_client_mock = MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestClusterModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestClusterModel.py b/ambari-client/src/test/python/TestClusterModel.py
index 519419e..742906d 100644
--- a/ambari-client/src/test/python/TestClusterModel.py
+++ b/ambari-client/src/test/python/TestClusterModel.py
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-
+import logging
 
 from mock.mock import MagicMock, patch
 from HttpClientInvoker import HttpClientInvoker
@@ -29,7 +29,11 @@ from ambari_client.core.errors import BadRequest
 import unittest
 
 class TestClusterModel(unittest.TestCase):
-  
+
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_cluster(self, http_client_mock = MagicMock()):    
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)
@@ -80,7 +84,7 @@ class TestClusterModel(unittest.TestCase):
     self.assertEqual(hostlist.to_json_dict(), expected_dict_output)
     self.assertEqual(hostlist[1].host_name, 'dev06.hortonworks.com')
     self.assertEqual(len(hostlist), 2)  
-    
+
   def test_get_host(self):
     """
     Get cluster host

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestComponentModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestComponentModel.py b/ambari-client/src/test/python/TestComponentModel.py
index 6502a71..9dc8336 100644
--- a/ambari-client/src/test/python/TestComponentModel.py
+++ b/ambari-client/src/test/python/TestComponentModel.py
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-
+import logging
 
 from mock.mock import MagicMock, patch
 from HttpClientInvoker import HttpClientInvoker
@@ -28,6 +28,10 @@ import unittest
 
 class TestClusterModel(unittest.TestCase):
 
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_component(self, http_client_mock = MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestHostModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestHostModel.py b/ambari-client/src/test/python/TestHostModel.py
index 06b95db..084b518 100644
--- a/ambari-client/src/test/python/TestHostModel.py
+++ b/ambari-client/src/test/python/TestHostModel.py
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-
+import logging
 
 from mock.mock import MagicMock, patch
 from HttpClientInvoker import HttpClientInvoker
@@ -28,6 +28,10 @@ import unittest
 
 class TestHostModel(unittest.TestCase):
 
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_host(self, http_client_mock = MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestServiceModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestServiceModel.py b/ambari-client/src/test/python/TestServiceModel.py
index b1315d5..80168a3 100644
--- a/ambari-client/src/test/python/TestServiceModel.py
+++ b/ambari-client/src/test/python/TestServiceModel.py
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-
+import logging
 
 from mock.mock import MagicMock, patch
 from HttpClientInvoker import HttpClientInvoker
@@ -28,6 +28,10 @@ import unittest
 
 class TestServiceModel(unittest.TestCase):
 
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_service(self, http_client_mock = MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/TestStatusModel.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/TestStatusModel.py b/ambari-client/src/test/python/TestStatusModel.py
index 00f3e0f..c2faf28 100644
--- a/ambari-client/src/test/python/TestStatusModel.py
+++ b/ambari-client/src/test/python/TestStatusModel.py
@@ -17,7 +17,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
 '''
-
+import logging
 
 from ambari_client.model.status import StatusModel
 from mock.mock import MagicMock, patch
@@ -28,6 +28,10 @@ import unittest
 
 class TestStatusModel(unittest.TestCase):
 
+  def setUp(self):
+    http_client_logger = logging.getLogger()
+    http_client_logger.info('Running test:' + self.id())
+
   def create_service(self, http_client_mock = MagicMock()):
     http_client_mock.invoke.side_effect = HttpClientInvoker.http_client_invoke_side_effects
     client = AmbariClient("localhost", 8080, "admin", "admin", version=1, client=http_client_mock)

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/unitTests.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/unitTests.py b/ambari-client/src/test/python/unitTests.py
index 0ba2cea..701ac99 100755
--- a/ambari-client/src/test/python/unitTests.py
+++ b/ambari-client/src/test/python/unitTests.py
@@ -79,7 +79,12 @@ def main():
   logger.info('------------------------------------------------------------------------')
   runner = unittest.TextTestRunner(verbosity=2, stream=sys.stdout)
   suite = all_tests_suite()
-  status = runner.run(suite).wasSuccessful()
+  result = runner.run(suite)
+  for error in result.errors:
+    logger.error('Failed test:' + error[0]._testMethodName + '\n' + error[1])
+  for failure in result.failures:
+    logger.error('Failed test:' + failure[0]._testMethodName + '\n' + failure[1])
+  status = result.wasSuccessful()
 
   if not status:
     logger.error('-----------------------------------------------------------------------')

http://git-wip-us.apache.org/repos/asf/ambari/blob/b8cc8ea5/ambari-client/src/test/python/utils/HttpClientInvoker.py
----------------------------------------------------------------------
diff --git a/ambari-client/src/test/python/utils/HttpClientInvoker.py b/ambari-client/src/test/python/utils/HttpClientInvoker.py
index 7c72b3e..1409a06 100644
--- a/ambari-client/src/test/python/utils/HttpClientInvoker.py
+++ b/ambari-client/src/test/python/utils/HttpClientInvoker.py
@@ -1,8 +1,11 @@
+import logging
+import unittest
 class HttpClientInvoker():
   @staticmethod
   def http_client_invoke_side_effects(*args, **kwargs):
-      print locals()
-      
+      localss = locals()
+      logger = logging.getLogger()
+      logger.info(localss)
       http_method = args[0]
       url = args[1]
       payload = kwargs.get("payload",None)