You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by tb...@apache.org on 2015/05/20 15:27:55 UTC
ambari git commit: AMBARI-11251 - serverUtils.py is not using
customized client.api.port in ambari.properties (tbeerbower)
Repository: ambari
Updated Branches:
refs/heads/trunk 44b6e7b97 -> 444faa1e9
AMBARI-11251 - serverUtils.py is not using customized client.api.port in ambari.properties (tbeerbower)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/444faa1e
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/444faa1e
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/444faa1e
Branch: refs/heads/trunk
Commit: 444faa1e9bf5005ac26b1deccb727ac0a55bf5da
Parents: 44b6e7b
Author: tbeerbower <tb...@hortonworks.com>
Authored: Wed May 20 09:27:33 2015 -0400
Committer: tbeerbower <tb...@hortonworks.com>
Committed: Wed May 20 09:27:46 2015 -0400
----------------------------------------------------------------------
.../src/main/python/ambari_server/serverUtils.py | 5 ++++-
ambari-server/src/test/python/TestAmbariServer.py | 3 ++-
ambari-server/src/test/python/TestServerUpgrade.py | 7 +++++--
ambari-server/src/test/python/TestServerUtils.py | 16 +++++++++++++---
4 files changed, 24 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/444faa1e/ambari-server/src/main/python/ambari_server/serverUtils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/python/ambari_server/serverUtils.py b/ambari-server/src/main/python/ambari_server/serverUtils.py
index 6466524..069e24d 100644
--- a/ambari-server/src/main/python/ambari_server/serverUtils.py
+++ b/ambari-server/src/main/python/ambari_server/serverUtils.py
@@ -26,7 +26,7 @@ from ambari_commons.os_check import OSConst
from ambari_commons.os_utils import run_os_command
from ambari_server.resourceFilesKeeper import ResourceFilesKeeper, KeeperException
from ambari_server.serverConfiguration import configDefaults, PID_NAME, get_resources_location, get_stack_location, \
- CLIENT_API_PORT, SSL_API, DEFAULT_SSL_API_PORT, SSL_API_PORT
+ CLIENT_API_PORT, CLIENT_API_PORT_PROPERTY, SSL_API, DEFAULT_SSL_API_PORT, SSL_API_PORT
# Ambari server API properties
@@ -106,6 +106,9 @@ def refresh_stack_hash(properties):
def get_ambari_server_api_base(properties):
api_protocol = SERVER_API_PROTOCOL
api_port = CLIENT_API_PORT
+ api_port_prop = properties.get_property(CLIENT_API_PORT_PROPERTY)
+ if api_port_prop is not None and api_port_prop != '':
+ api_port = api_port_prop
api_ssl = False
api_ssl_prop = properties.get_property(SSL_API)
http://git-wip-us.apache.org/repos/asf/ambari/blob/444faa1e/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 8f90e59..38a4367 100644
--- a/ambari-server/src/test/python/TestAmbariServer.py
+++ b/ambari-server/src/test/python/TestAmbariServer.py
@@ -69,7 +69,7 @@ with patch("platform.linux_distribution", return_value = os_distro_value):
PERSISTENCE_TYPE_PROPERTY, JDBC_URL_PROPERTY, get_conf_dir, JDBC_USER_NAME_PROPERTY, JDBC_PASSWORD_PROPERTY, \
JDBC_DATABASE_NAME_PROPERTY, OS_TYPE_PROPERTY, validate_jdk, JDBC_POSTGRES_SCHEMA_PROPERTY, \
RESOURCES_DIR_PROPERTY, JDBC_RCA_PASSWORD_ALIAS, JDBC_RCA_SCHEMA_PROPERTY, IS_LDAP_CONFIGURED, \
- SSL_API, SSL_API_PORT, \
+ SSL_API, SSL_API_PORT, CLIENT_API_PORT_PROPERTY,\
LDAP_MGR_PASSWORD_PROPERTY, LDAP_MGR_PASSWORD_ALIAS, JDBC_PASSWORD_FILENAME, NR_USER_PROPERTY, SECURITY_KEY_IS_PERSISTED, \
SSL_TRUSTSTORE_PASSWORD_PROPERTY, SECURITY_IS_ENCRYPTION_ENABLED, SSL_TRUSTSTORE_PASSWORD_ALIAS, \
SECURITY_MASTER_KEY_LOCATION, SECURITY_KEYS_DIR, LDAP_PRIMARY_URL_PROPERTY, store_password_file, \
@@ -5758,6 +5758,7 @@ MIIFHjCCAwYCCQDpHKOBI+Lt0zANBgkqhkiG9w0BAQUFADBRMQswCQYDVQQGEwJV
is_server_runing_mock.return_value = (True, 0)
properties = Properties()
properties.process_pair(IS_LDAP_CONFIGURED, 'true')
+ properties.process_pair(CLIENT_API_PORT_PROPERTY, '8080')
get_ambari_properties_mock.return_value = properties
get_validated_string_input_mock.side_effect = ['admin', 'admin']
http://git-wip-us.apache.org/repos/asf/ambari/blob/444faa1e/ambari-server/src/test/python/TestServerUpgrade.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestServerUpgrade.py b/ambari-server/src/test/python/TestServerUpgrade.py
index 05b48fa..7ef74b2 100644
--- a/ambari-server/src/test/python/TestServerUpgrade.py
+++ b/ambari-server/src/test/python/TestServerUpgrade.py
@@ -63,7 +63,10 @@ class TestServerUpgrade(TestCase):
# Test normal flow
get_validated_string_input_mock.return_value = 'dummy_string'
- get_ambari_properties_mock.return_value = MagicMock()
+
+ p = get_ambari_properties_mock.return_value
+ p.get_property.side_effect = ["8080", "false"]
+
get_ambari_server_api_base_mock.return_value = 'http://127.0.0.1:8080/api/v1/'
get_verbose_mock.retun_value = False
@@ -97,4 +100,4 @@ class TestServerUpgrade(TestCase):
options.cluster_name = 'cc'
options.desired_repo_version = 'HDP-2.2.2.0-2561'
cvo = SetCurrentVersionOptions(options)
- self.assertFalse(cvo.no_finalize_options_set())
\ No newline at end of file
+ self.assertFalse(cvo.no_finalize_options_set())
http://git-wip-us.apache.org/repos/asf/ambari/blob/444faa1e/ambari-server/src/test/python/TestServerUtils.py
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/python/TestServerUtils.py b/ambari-server/src/test/python/TestServerUtils.py
index a1a9ef3..474a83d 100644
--- a/ambari-server/src/test/python/TestServerUtils.py
+++ b/ambari-server/src/test/python/TestServerUtils.py
@@ -18,7 +18,7 @@ limitations under the License.
from unittest import TestCase
from ambari_server.serverUtils import get_ambari_server_api_base
-from ambari_server.serverConfiguration import CLIENT_API_PORT, SSL_API, DEFAULT_SSL_API_PORT, SSL_API_PORT
+from ambari_server.serverConfiguration import CLIENT_API_PORT, CLIENT_API_PORT_PROPERTY, SSL_API, DEFAULT_SSL_API_PORT, SSL_API_PORT
class TestServerUtils(TestCase):
@@ -27,14 +27,24 @@ class TestServerUtils(TestCase):
# Test case of using http protocol
properties = FakeProperties({
SSL_API: "false",
+ CLIENT_API_PORT_PROPERTY: None
})
result = get_ambari_server_api_base(properties)
self.assertEquals(result, 'http://127.0.0.1:8080/api/v1/')
+ # Test case of using http protocol and custom port
+ properties = FakeProperties({
+ SSL_API: "false",
+ CLIENT_API_PORT_PROPERTY: "8033"
+ })
+ result = get_ambari_server_api_base(properties)
+ self.assertEquals(result, 'http://127.0.0.1:8033/api/v1/')
+
# Test case of using https protocol (and ssl port)
properties = FakeProperties({
SSL_API: "true",
- SSL_API_PORT : "8443"
+ SSL_API_PORT : "8443",
+ CLIENT_API_PORT_PROPERTY: None
})
result = get_ambari_server_api_base(properties)
self.assertEquals(result, 'https://127.0.0.1:8443/api/v1/')
@@ -46,4 +56,4 @@ class FakeProperties(object):
self.prop_map = prop_map
def get_property(self, prop_name):
- return self.prop_map[prop_name]
\ No newline at end of file
+ return self.prop_map[prop_name]