ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dmitriu...@apache.org
Subject [2/2] ambari git commit: AMBARI-13122. [Upgrade] ambari server schema upgrade failed for Path 1.6.1 -> 2.1.2 and 2.0.2->2.1.2 and 2.1.1->2.1.2 (dlysnichenko)
Date Thu, 17 Sep 2015 12:24:59 GMT
AMBARI-13122. [Upgrade] ambari server schema upgrade failed for Path 1.6.1 -> 2.1.2 and
2.0.2->2.1.2 and 2.1.1->2.1.2 (dlysnichenko)


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

Branch: refs/heads/trunk
Commit: b99ba4d24801fea17785a02c8c793eee341a6508
Parents: b58fa92
Author: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Authored: Thu Sep 17 12:59:48 2015 +0300
Committer: Lisnichenko Dmitro <dlysnichenko@hortonworks.com>
Committed: Thu Sep 17 15:24:37 2015 +0300

----------------------------------------------------------------------
 .../src/main/python/ambari_server/serverUpgrade.py     | 13 +++++++++----
 ambari-server/src/test/python/TestAmbariServer.py      |  9 ++++++---
 2 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b99ba4d2/ambari-server/src/main/python/ambari_server/serverUpgrade.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverUpgrade.py b/ambari-server/src/main/python/ambari_server/serverUpgrade.py
index f9d65e9..73961d8 100644
--- a/ambari-server/src/main/python/ambari_server/serverUpgrade.py
+++ b/ambari-server/src/main/python/ambari_server/serverUpgrade.py
@@ -30,7 +30,7 @@ import glob
 from ambari_commons.exceptions import FatalException
 from ambari_commons.logging_utils import print_info_msg, print_warning_msg, print_error_msg,
get_verbose
 from ambari_commons.os_utils import is_root, run_os_command
-from ambari_server.dbConfiguration import DBMSConfigFactory, check_jdbc_drivers
+from ambari_server.dbConfiguration import DBMSConfigFactory, check_jdbc_drivers, get_jdbc_driver_path
 from ambari_server.properties import Properties
 from ambari_server.serverConfiguration import configDefaults, \
   check_database_name_property, get_ambari_properties, get_ambari_version, get_full_ambari_classpath,
\
@@ -216,7 +216,7 @@ def upgrade_local_repo(args):
 # Schema upgrade
 #
 
-def run_schema_upgrade():
+def run_schema_upgrade(args):
   db_title = get_db_type(get_ambari_properties()).title
   confirm = get_YN_input("Ambari Server configured for %s. Confirm "
                         "you have made a backup of the Ambari Server database [y/n] (y)?
" % db_title, True)
@@ -234,7 +234,12 @@ def run_schema_upgrade():
 
   print 'Upgrading database schema'
 
-  command = SCHEMA_UPGRADE_HELPER_CMD.format(jdk_path, get_full_ambari_classpath())
+  class_path = get_full_ambari_classpath()
+  jdbc_driver_path = get_jdbc_driver_path(args, get_ambari_properties())
+  if jdbc_driver_path not in class_path:
+    class_path = class_path + os.pathsep + jdbc_driver_path
+
+  command = SCHEMA_UPGRADE_HELPER_CMD.format(jdk_path, class_path)
 
   ambari_user = read_ambari_user()
   current_user = ensure_can_start_under_current_user(ambari_user)
@@ -319,7 +324,7 @@ def upgrade(args):
   #TODO check database version
   change_objects_owner(args)
 
-  retcode = run_schema_upgrade()
+  retcode = run_schema_upgrade(args)
   if not retcode == 0:
     print_error_msg("Ambari server upgrade failed. Please look at {0}, for more details.".format(configDefaults.SERVER_LOG_FILE))
     raise FatalException(11, 'Schema upgrade failed.')

http://git-wip-us.apache.org/repos/asf/ambari/blob/b99ba4d2/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 6467cd8..48653d9 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -4668,6 +4668,7 @@ class TestAmbariServer(TestCase):
     pass
 
 
+  @patch("ambari_server.serverUpgrade.get_jdbc_driver_path")
   @patch("ambari_server.serverUpgrade.ensure_can_start_under_current_user")
   @patch("ambari_server.serverUpgrade.generate_env")
   @patch("ambari_server.serverUpgrade.read_ambari_user")
@@ -4680,12 +4681,13 @@ class TestAmbariServer(TestCase):
   def test_run_schema_upgrade(self, get_YN_input_mock, get_ambari_properties_mock, java_exe_path_mock,
run_os_command_mock,
                               get_ambari_classpath_mock, get_conf_dir_mock,
                               read_ambari_user_mock, generate_env_mock,
-                              ensure_can_start_under_current_user_mock):
+                              ensure_can_start_under_current_user_mock, get_jdbc_mock):
     java_exe_path_mock.return_value = "/usr/lib/java/bin/java"
     run_os_command_mock.return_value = (0, None, None)
     get_ambari_classpath_mock.return_value = 'test' + os.pathsep + 'path12'
     get_conf_dir_mock.return_value = '/etc/conf'
-    command = '/usr/lib/java/bin/java -cp /etc/conf' + os.pathsep + 'test' + os.pathsep +
'path12 ' \
+    command = '/usr/lib/java/bin/java -cp /etc/conf' + os.pathsep + 'test' + os.pathsep +
'path12' + \
+              os.pathsep +'/path/to/jdbc.jar ' \
               'org.apache.ambari.server.upgrade.SchemaUpgradeHelper ' \
               '> ' + os.sep + 'var' + os.sep + 'log' + os.sep + 'ambari-server' + os.sep
+ 'ambari-server.out 2>&1'
     environ = {}
@@ -4696,8 +4698,9 @@ class TestAmbariServer(TestCase):
     properties.process_pair(PERSISTENCE_TYPE_PROPERTY, "local")
     get_ambari_properties_mock.return_value = properties
     get_YN_input_mock.return_value = True
+    get_jdbc_mock.return_value = '/path/to/jdbc.jar'
 
-    run_schema_upgrade()
+    run_schema_upgrade(None)
 
     self.assertTrue(java_exe_path_mock.called)
     self.assertTrue(ensure_can_start_under_current_user_mock.called)


Mime
View raw message