Updated Branches: refs/heads/trunk e92df28ec -> 062480094
AMBARI-3262. Upgrade from Comanche to BWGA is failed (Dmytro Sen via dlysnichenko) Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/06248009 Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/06248009 Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/06248009 Branch: refs/heads/trunk Commit: 062480094dd2f2f59fb59e3b10ccf1c194f69b35 Parents: e92df28 Author: Lisnichenko Dmitro <[email protected]> Authored: Wed Sep 18 15:10:58 2013 +0300 Committer: Lisnichenko Dmitro <[email protected]> Committed: Wed Sep 18 15:11:49 2013 +0300 ---------------------------------------------------------------------- ambari-server/src/main/python/ambari-server.py | 4 +++- .../src/test/python/TestAmbariServer.py | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/06248009/ambari-server/src/main/python/ambari-server.py ---------------------------------------------------------------------- diff --git a/ambari-server/src/main/python/ambari-server.py b/ambari-server/src/main/python/ambari-server.py index 44c0600..14920ee 100755 --- a/ambari-server/src/main/python/ambari-server.py +++ b/ambari-server/src/main/python/ambari-server.py @@ -2392,13 +2392,15 @@ def upgrade(args): if properties == -1: print_error_msg ("Error getting ambari properties") return -1 + print_warning_msg(JDBC_DATABASE_PROPERTY + " property isn't set in " + + AMBARI_PROPERTIES_FILE + ". Setting it to default value - " + DEFAULT_DB_NAME) properties.process_pair(JDBC_DATABASE_PROPERTY, DEFAULT_DB_NAME) conf_file = find_properties_file() try: properties.store(open(conf_file, "w")) except Exception, e: print_error_msg('Could not write ambari config file "%s": %s' % (conf_file, e)) - return -1 + return -1 parse_properties_file(args) if args.persistence_type == "remote": http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/06248009/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 fdf4e07..ef23709 100644 --- a/ambari-server/src/test/python/TestAmbariServer.py +++ b/ambari-server/src/test/python/TestAmbariServer.py @@ -2442,6 +2442,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV + @patch("__builtin__.open") + @patch.object(ambari_server.Properties, "store") + @patch.object(ambari_server, "find_properties_file") @patch.object(ambari_server, "adjust_directory_permissions") @patch.object(ambari_server, "print_warning_msg") @patch.object(ambari_server, "read_ambari_user") @@ -2459,7 +2462,8 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV update_ambari_properties_mock, check_postgre_up_mock, execute_db_script_mock, check_db_consistency_mock, read_ambari_user_mock, - print_warning_msg_mock, adjust_directory_permissions_mock): + print_warning_msg_mock, adjust_directory_permissions_mock, + find_properties_file_mock, properties_store_mock, open_mock): args = MagicMock() check_database_name_property_mock = MagicMock() @@ -2497,14 +2501,23 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV ambari_server.upgrade(args) self.assertTrue(adjust_directory_permissions_mock.called) - # Test if check_database_name_property raise exception + # Test if check_database_name_property raise exception, added default + # JDBC_DATABASE_PROPERTY and upgrade process doesn't fails def effect(): raise FatalException() + properties = ambari_server.Properties() + get_ambari_properties_mock.return_value = properties + check_database_name_property_mock.side_effect = effect - ambari_server.upgrade(args) + parse_properties_file_mock.called = False + retcode = ambari_server.upgrade(args) self.assertTrue(get_ambari_properties_mock.called) + self.assertTrue(properties.get_property(ambari_server.JDBC_DATABASE_PROPERTY)) + self.assertNotEqual(-1, retcode) + self.assertTrue(parse_properties_file_mock.called) + #Test remote upgrade get_db_cli_tool_mock.return_value = "psql" execute_remote_script_mock.return_value = (0, "test", "test")
