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 2015/09/17 14:24:58 UTC

[1/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)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 154c4c392 -> d4f935532
  refs/heads/trunk b58fa9258 -> b99ba4d24


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/d4f93553
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/d4f93553
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/d4f93553

Branch: refs/heads/branch-2.1
Commit: d4f935532a1ff7e14362aed6236273763ffb5273
Parents: 154c4c3
Author: Lisnichenko Dmitro <dl...@hortonworks.com>
Authored: Thu Sep 17 15:23:54 2015 +0300
Committer: Lisnichenko Dmitro <dl...@hortonworks.com>
Committed: Thu Sep 17 15:23:54 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/d4f93553/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/d4f93553/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 2bfaf2a..addfce3 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -3824,6 +3824,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     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")
@@ -3836,12 +3837,13 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
   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:path12'
     get_conf_dir_mock.return_value = '/etc/conf'
-    command = '/usr/lib/java/bin/java -cp /etc/conf:test: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 ' \
               '> /var/log/ambari-server/ambari-server.out 2>&1'
     environ = {}
@@ -3852,8 +3854,9 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
     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)


[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)

Posted by dm...@apache.org.
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 <dl...@hortonworks.com>
Authored: Thu Sep 17 12:59:48 2015 +0300
Committer: Lisnichenko Dmitro <dl...@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)