You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sm...@apache.org on 2013/06/22 00:20:30 UTC

svn commit: r1495624 - in /incubator/ambari/trunk/ambari-server/src: main/python/ambari-server.py test/python/TestAmbaryServer.py

Author: smohanty
Date: Fri Jun 21 22:20:30 2013
New Revision: 1495624

URL: http://svn.apache.org/r1495624
Log:
AMBARI-2460. Running ambari-server upgrade if the upgrade has already been run leads to errors. (Dmitry Sen via smohanty)

Modified:
    incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
    incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py

Modified: incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py?rev=1495624&r1=1495623&r2=1495624&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py (original)
+++ incubator/ambari/trunk/ambari-server/src/main/python/ambari-server.py Fri Jun 21 22:20:30 2013
@@ -333,7 +333,8 @@ def update_ambari_properties():
   prev_conf_file = search_file(AMBARI_PROPERTIES_RPMSAVE_FILE, get_conf_dir())
   conf_file = search_file(AMBARI_PROPERTIES_FILE, get_conf_dir())
 
-  if not prev_conf_file: # Previous config file does not exist
+  # Previous config file does not exist
+  if (not prev_conf_file) or (prev_conf_file is None):
     print_warning_msg("Can not find ambari.properties.rpmsave file from previous version, skipping import of settings")
     return 0
 

Modified: incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py?rev=1495624&r1=1495623&r2=1495624&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py (original)
+++ incubator/ambari/trunk/ambari-server/src/test/python/TestAmbaryServer.py Fri Jun 21 22:20:30 2013
@@ -2157,6 +2157,24 @@ class TestAmbariServer(TestCase):
     result = ambari_server.update_ambari_properties()
     self.assertNotEquals(result, 0)
 
+  @patch.object(ambari_server.Properties, '__init__')
+  @patch.object(ambari_server, 'search_file')
+  def test_update_ambari_properties_negative_case(self, search_file_mock, properties_mock):
+    search_file_mock.return_value = None
+    #Call tested method
+    self.assertEquals(0, ambari_server.update_ambari_properties())
+    self.assertFalse(properties_mock.called)
+
+    search_file_mock.return_value = False
+    #Call tested method
+    self.assertEquals(0, ambari_server.update_ambari_properties())
+    self.assertFalse(properties_mock.called)
+
+    search_file_mock.return_value = ''
+    #Call tested method
+    self.assertEquals(0, ambari_server.update_ambari_properties())
+    self.assertFalse(properties_mock.called)
+
   @patch("sys.exit")
   @patch.object(ambari_server, "get_db_cli_tool")
   @patch.object(ambari_server, "store_remote_properties")