Repository: knox Updated Branches: refs/heads/master 35b65a267 -> 2717b1574
KNOX-1374 - Ranger service discovery should use ranger.externalurl property Project: http://git-wip-us.apache.org/repos/asf/knox/repo Commit: http://git-wip-us.apache.org/repos/asf/knox/commit/2717b157 Tree: http://git-wip-us.apache.org/repos/asf/knox/tree/2717b157 Diff: http://git-wip-us.apache.org/repos/asf/knox/diff/2717b157 Branch: refs/heads/master Commit: 2717b15749ad01f0c3a1120c66825ffffd9d3832 Parents: 35b65a2 Author: Phil Zampino <[email protected]> Authored: Tue Jul 3 15:30:57 2018 -0400 Committer: Phil Zampino <[email protected]> Committed: Tue Jul 3 15:46:29 2018 -0400 ---------------------------------------------------------------------- .../ambari-service-discovery-url-mappings.xml | 72 +++----------------- .../AmbariDynamicServiceURLCreatorTest.java | 13 +++- 2 files changed, 18 insertions(+), 67 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/knox/blob/2717b157/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml ---------------------------------------------------------------------- diff --git a/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml b/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml index 1ad7fc5..8165b79 100644 --- a/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml +++ b/gateway-discovery-ambari/src/main/resources/ambari-service-discovery-url-mappings.xml @@ -386,77 +386,21 @@ </service> <service name="RANGER"> - <url-pattern>{SCHEME}://{HOST}:{PORT}</url-pattern> + <url-pattern>{RANGER_EXTERNAL_URL}</url-pattern> <properties> - <property name="HOST"> - <component>RANGER_ADMIN</component> - <hostname/> - </property> - <property name="SSL"> - <component>RANGER_ADMIN</component> - <config-property>ranger.service.https.attrib.ssl.enabled</config-property> - </property> - <property name="HTTPS_PORT"> - <component>RANGER_ADMIN</component> - <config-property>ranger.service.https.port</config-property> - </property> - <property name="HTTP_PORT"> - <component>RANGER_ADMIN</component> - <config-property>ranger.service.http.port</config-property> - </property> - <property name="SCHEME"> - <config-property> - <if property="SSL" value="true"> - <then>https</then> - <else>http</else> - </if> - </config-property> - </property> - <property name="PORT"> - <config-property> - <if property="SSL" value="true"> - <then>HTTPS_PORT</then> - <else>HTTP_PORT</else> - </if> - </config-property> - </property> + <property name="RANGER_EXTERNAL_URL"> + <component>RANGER_ADMIN</component> + <config-property>ranger.externalurl</config-property> + </property> </properties> </service> <service name="RANGERUI"> - <url-pattern>{SCHEME}://{HOST}:{PORT}</url-pattern> + <url-pattern>{RANGER_EXTERNAL_URL}</url-pattern> <properties> - <property name="HOST"> - <component>RANGER_ADMIN</component> - <hostname/> - </property> - <property name="SSL"> + <property name="RANGER_EXTERNAL_URL"> <component>RANGER_ADMIN</component> - <config-property>ranger.service.https.attrib.ssl.enabled</config-property> - </property> - <property name="HTTPS_PORT"> - <component>RANGER_ADMIN</component> - <config-property>ranger.service.https.port</config-property> - </property> - <property name="HTTP_PORT"> - <component>RANGER_ADMIN</component> - <config-property>ranger.service.http.port</config-property> - </property> - <property name="SCHEME"> - <config-property> - <if property="SSL" value="true"> - <then>https</then> - <else>http</else> - </if> - </config-property> - </property> - <property name="PORT"> - <config-property> - <if property="SSL" value="true"> - <then>HTTPS_PORT</then> - <else>HTTP_PORT</else> - </if> - </config-property> + <config-property>ranger.externalurl</config-property> </property> </properties> </service> http://git-wip-us.apache.org/repos/asf/knox/blob/2717b157/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java ---------------------------------------------------------------------- diff --git a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java index 2a63535..554fe88 100644 --- a/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java +++ b/gateway-discovery-ambari/src/test/java/org/apache/knox/gateway/topology/discovery/ambari/AmbariDynamicServiceURLCreatorTest.java @@ -902,6 +902,7 @@ public class AmbariDynamicServiceURLCreatorTest { private void doTestRangerURLs(String serviceName) throws Exception { final String HTTP_PORT = "6080"; final String HTTPS_PORT = "6182"; + final String EXT_URL = "http://host2:" + HTTP_PORT; final String[] HOSTNAMES = {"host1", "host3"}; final List<String> rangerServerHosts = Arrays.asList(HOSTNAMES); @@ -911,6 +912,7 @@ public class AmbariDynamicServiceURLCreatorTest { EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.attrib.ssl.enabled")).andReturn("false").anyTimes(); EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.http.port")).andReturn(HTTP_PORT).anyTimes(); EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.port")).andReturn(HTTPS_PORT).anyTimes(); + EasyMock.expect(rangerAdmin.getConfigProperty("ranger.externalurl")).andReturn(EXT_URL).anyTimes(); EasyMock.replay(rangerAdmin); AmbariCluster cluster = EasyMock.createNiceMock(AmbariCluster.class); @@ -920,17 +922,22 @@ public class AmbariDynamicServiceURLCreatorTest { AmbariDynamicServiceURLCreator builder = newURLCreator(cluster, null); // Run the test - validateServiceURLs(builder.create(serviceName, null), HOSTNAMES, "http", HTTP_PORT, null); + List<String> urls = builder.create(serviceName, null); + assertEquals(1, urls.size()); + assertEquals(EXT_URL, urls.get(0)); EasyMock.reset(rangerAdmin); EasyMock.expect(rangerAdmin.getHostNames()).andReturn(rangerServerHosts).anyTimes(); EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.attrib.ssl.enabled")).andReturn("true").anyTimes(); EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.http.port")).andReturn(HTTP_PORT).anyTimes(); EasyMock.expect(rangerAdmin.getConfigProperty("ranger.service.https.port")).andReturn(HTTPS_PORT).anyTimes(); + EasyMock.expect(rangerAdmin.getConfigProperty("ranger.externalurl")).andReturn(EXT_URL).anyTimes(); EasyMock.replay(rangerAdmin); - // Run the test - validateServiceURLs(builder.create(serviceName, null), HOSTNAMES, "https", HTTPS_PORT, null); + // Run the test, making sure that the external URL is the result + urls = builder.create(serviceName, null); + assertEquals(1, urls.size()); + assertEquals(EXT_URL, urls.get(0)); }
