You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by vb...@apache.org on 2015/02/02 12:43:58 UTC
ambari git commit: AMBARI-9400. ambari db upgrade 1.6.1 -> 2.0.0
fails.(vbrodetskyi)
Repository: ambari
Updated Branches:
refs/heads/trunk a0284cc33 -> cd03c3279
AMBARI-9400. ambari db upgrade 1.6.1 -> 2.0.0 fails.(vbrodetskyi)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/cd03c327
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/cd03c327
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/cd03c327
Branch: refs/heads/trunk
Commit: cd03c327952b5683a945f21a6a1f8b9dbbddd81b
Parents: a0284cc
Author: Vitaly Brodetskyi <vb...@hortonworks.com>
Authored: Mon Feb 2 12:39:44 2015 +0200
Committer: Vitaly Brodetskyi <vb...@hortonworks.com>
Committed: Mon Feb 2 12:40:35 2015 +0200
----------------------------------------------------------------------
.../python/ambari_server/serverConfiguration.py | 3 ++-
.../src/test/python/TestAmbariServer.py | 20 +++++++++++++++++---
2 files changed, 19 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/cd03c327/ambari-server/src/main/python/ambari_server/serverConfiguration.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverConfiguration.py b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
index 3f04840..ba5bf4b 100644
--- a/ambari-server/src/main/python/ambari_server/serverConfiguration.py
+++ b/ambari-server/src/main/python/ambari_server/serverConfiguration.py
@@ -497,7 +497,8 @@ def check_database_name_property(upgrade=False):
return -1
version = get_ambari_version(properties)
- if upgrade and compare_versions(version, "1.7.0") == 0:
+ if upgrade and (properties[JDBC_DATABASE_PROPERTY] not in ["postgres", "oracle", "mysql", "derby"]
+ or properties.has_key(JDBC_RCA_SCHEMA_PROPERTY)):
# This code exists for historic reasons in which property names changed from Ambari 1.6.1 to 1.7.0
persistence_type = properties[PERSISTENCE_TYPE_PROPERTY]
if persistence_type == "remote":
http://git-wip-us.apache.org/repos/asf/ambari/blob/cd03c327/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 caa1cf5..2971593 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -4236,7 +4236,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
get_ambari_properties_3_mock.reset_mock()
get_ambari_properties_3_mock.return_value = get_ambari_properties_2_mock.return_value = \
get_ambari_properties_mock.return_value = p
- p.__getitem__.side_effect = ["something", KeyError("test exception")]
+ p.__getitem__.side_effect = ["something", "something", "something", KeyError("test exception")]
fail = False
try:
@@ -6127,9 +6127,10 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
pass
@not_for_platform(PLATFORM_WINDOWS)
+ @patch("ambari_server.serverConfiguration.write_property")
@patch("ambari_server.serverConfiguration.get_ambari_properties")
@patch("ambari_server.serverConfiguration.get_ambari_version")
- def test_check_database_name_property(self, get_ambari_version_mock, get_ambari_properties_mock):
+ def test_check_database_name_property(self, get_ambari_version_mock, get_ambari_properties_mock, write_property_mock):
parser = OptionParser()
parser.add_option('--database', default=None, help="Database to use embedded|oracle|mysql|postgres", dest="dbms")
args = parser.parse_args()
@@ -6150,7 +6151,20 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
result = check_database_name_property()
except FatalException:
self.fail("Setup should be successful")
- pass
+
+ # Check upgrade. In Ambari < 1.7.1 "database" property contained db name for local db
+ dbname = "ambari"
+ database = "ambari"
+ persistence = "local"
+ get_ambari_properties_mock.reset_mock()
+ get_ambari_properties_mock.return_value = {JDBC_DATABASE_NAME_PROPERTY: dbname,
+ JDBC_DATABASE_PROPERTY: database,
+ PERSISTENCE_TYPE_PROPERTY: persistence}
+ try:
+ result = check_database_name_property(upgrade=True)
+ except FatalException:
+ self.fail("Setup should be successful")
+ self.assertTrue(write_property_mock.called)
@patch.object(OSCheck, "os_distribution", new = MagicMock(return_value = os_distro_value))
@patch("ambari_commons.firewall.run_os_command")