You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by fb...@apache.org on 2015/01/27 20:34:03 UTC
ambari git commit: AMBARI-9342 Unit tests fail with python 2.6
Repository: ambari
Updated Branches:
refs/heads/trunk 14852dc8a -> b624ce914
AMBARI-9342 Unit tests fail with python 2.6
Replaced unsupported assert
Fixed random test condition in test_start()
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b624ce91
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b624ce91
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b624ce91
Branch: refs/heads/trunk
Commit: b624ce91476ebe227d4608c756d3fb56ebad390f
Parents: 14852dc
Author: Florian Barca <fb...@hortonworks.com>
Authored: Tue Jan 27 11:33:47 2015 -0800
Committer: Florian Barca <fb...@hortonworks.com>
Committed: Tue Jan 27 11:33:47 2015 -0800
----------------------------------------------------------------------
.../src/test/python/TestAmbariServer.py | 27 ++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/b624ce91/ambari-server/src/test/python/TestAmbariServer.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestAmbariServer.py b/ambari-server/src/test/python/TestAmbariServer.py
index 10596fe..8f13295 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -538,7 +538,7 @@ class TestAmbariServer(TestCase):
self.assertFalse(False, get_verbose())
self.assertFalse(False, get_silent())
- self.assertIsNone(options.exit_message)
+ self.assertTrue(options.exit_message is None)
pass
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
@@ -3253,7 +3253,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
p.process_pair(PERSISTENCE_TYPE_PROPERTY, 'remote')
find_jdbc_driver_mock.reset_mock()
- find_jdbc_driver_mock.return_value = 0
+ find_jdbc_driver_mock.return_value = -1
try:
_ambari_server_.start(args)
except FatalException as e:
@@ -3266,6 +3266,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
p.process_pair(JDBC_DATABASE_PROPERTY, 'oracle')
p.process_pair(PERSISTENCE_TYPE_PROPERTY, 'remote')
+ find_jdbc_driver_mock.reset_mock()
+ find_jdbc_driver_mock.return_value = 0
+
# Test exception handling on resource files housekeeping
perform_housekeeping_mock.reset_mock()
perform_housekeeping_mock.side_effect = KeeperException("some_reason")
@@ -3309,6 +3312,26 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
# Case: custom user is "root"
read_ambari_user_mock.return_value = "root"
+
+ # Java failed to start
+ proc = MagicMock()
+ proc.pid = -186
+ popenMock.return_value = proc
+
+ try:
+ _ambari_server_.start(args)
+ except FatalException as e:
+ # Expected
+ self.assertTrue(popenMock.called)
+ self.assertTrue('Ambari Server java process died' in e.reason)
+ self.assertTrue(perform_housekeeping_mock.called)
+
+ args = reset_mocks()
+
+ # Java OK
+ proc.pid = 186
+ popenMock.reset_mock()
+
_ambari_server_.start(args)
self.assertTrue(popenMock.called)
popen_arg = popenMock.call_args[0][0]