knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject git commit: KNOX-453: HDFS HA not working for secure clusters
Date Wed, 22 Oct 2014 19:03:55 GMT
Repository: knox
Updated Branches:
  refs/heads/v0.5.0 2154d2d8c -> e5cd68d18


KNOX-453: HDFS HA not working for secure clusters

(cherry picked from commit 13682b6c0af047b9186d47758c21e2e4a62412bb)


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

Branch: refs/heads/v0.5.0
Commit: e5cd68d18f1dff66cfa503b1367982ae66222d48
Parents: 2154d2d
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Wed Oct 22 14:59:03 2014 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Wed Oct 22 14:59:43 2014 -0400

----------------------------------------------------------------------
 .../dispatch/WebHdfsHaHttpClientDispatch.java   |  1 +
 .../WebHdfsHaHttpClientDispatchTest.java        | 37 ++++++++++++++++++++
 2 files changed, 38 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/knox/blob/e5cd68d1/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
index cfa5081..a0aa014 100644
--- a/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
+++ b/gateway-service-webhdfs/src/main/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatch.java
@@ -68,6 +68,7 @@ public class WebHdfsHaHttpClientDispatch extends HdfsDispatch {
 
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
+      super.init(filterConfig);
       resourceRole = filterConfig.getInitParameter(RESOURCE_ROLE_ATTRIBUTE);
       LOG.initializingForResourceRole(resourceRole);
       haProvider = HaServletContextListener.getHaProvider(filterConfig.getServletContext());

http://git-wip-us.apache.org/repos/asf/knox/blob/e5cd68d1/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
----------------------------------------------------------------------
diff --git a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
b/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
index e64f7c7..ae861a9 100644
--- a/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
+++ b/gateway-service-webhdfs/src/test/java/org/apache/hadoop/gateway/hdfs/dispatch/WebHdfsHaHttpClientDispatchTest.java
@@ -17,10 +17,13 @@
  */
 package org.apache.hadoop.gateway.hdfs.dispatch;
 
+import org.apache.hadoop.gateway.dispatch.AppCookieManager;
 import org.apache.hadoop.gateway.ha.provider.HaDescriptor;
 import org.apache.hadoop.gateway.ha.provider.HaProvider;
 import org.apache.hadoop.gateway.ha.provider.HaServletContextListener;
+import org.apache.hadoop.gateway.ha.provider.impl.DefaultHaDescriptor;
 import org.apache.hadoop.gateway.ha.provider.impl.DefaultHaProvider;
+import org.apache.hadoop.gateway.ha.provider.impl.DefaultHaServiceConfig;
 import org.apache.hadoop.gateway.ha.provider.impl.HaDescriptorFactory;
 import org.apache.http.client.methods.HttpRequestBase;
 import org.apache.http.client.methods.HttpUriRequest;
@@ -32,6 +35,7 @@ import org.junit.Test;
 
 import javax.servlet.FilterConfig;
 import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
 import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -40,8 +44,41 @@ import java.net.URI;
 import java.util.ArrayList;
 import java.util.concurrent.atomic.AtomicInteger;
 
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+
 public class WebHdfsHaHttpClientDispatchTest {
 
+  private class InstrumentedWebHdfsHaHttpClientDispatch extends WebHdfsHaHttpClientDispatch
{
+
+    public InstrumentedWebHdfsHaHttpClientDispatch() throws ServletException {
+    }
+
+    public AppCookieManager getAppCookieManager() {
+      return appCookieManager;
+    }
+
+  }
+
+   @Test
+   public void testInitCallsSuperInit() throws Exception {
+     DefaultHaDescriptor haDescriptor = new DefaultHaDescriptor();
+     haDescriptor.addServiceConfig( new DefaultHaServiceConfig( "test-role" ) );
+     HaProvider haProvider = new DefaultHaProvider( haDescriptor );
+     ServletContext context = EasyMock.createNiceMock(ServletContext.class);
+     EasyMock.expect(context.getAttribute(HaServletContextListener.PROVIDER_ATTRIBUTE_NAME)).andReturn(haProvider).anyTimes();
+     FilterConfig config = EasyMock.createNiceMock( FilterConfig.class );
+     EasyMock.expect(config.getServletContext()).andReturn(context).anyTimes();
+     EasyMock.expect(config.getInitParameter( WebHdfsHaHttpClientDispatch.RESOURCE_ROLE_ATTRIBUTE
)).andReturn("test-role").anyTimes();
+     EasyMock.expect(config.getInitParameter(EasyMock.anyObject(String.class))).andReturn(null).anyTimes();
+     InstrumentedWebHdfsHaHttpClientDispatch dispatch = new InstrumentedWebHdfsHaHttpClientDispatch();
+     EasyMock.replay(context,config);
+
+     dispatch.init(config);
+
+     assertThat( dispatch.getAppCookieManager(), notNullValue() );
+   }
+
    @Test
    public void testConnectivityFailover() throws Exception {
       String serviceName = "WEBHDFS";


Mime
View raw message