MAPREDUCE-6789. Fix TestAMWebApp failure. Contributed by Daniel Templeton.
(cherry picked from commit 272a21747e
)
This commit is contained in:
parent
a868cf4046
commit
5f1432d98e
|
@ -247,9 +247,11 @@ public class TestAMWebApp {
|
||||||
HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection();
|
HttpURLConnection conn = (HttpURLConnection) httpUrl.openConnection();
|
||||||
conn.setInstanceFollowRedirects(false);
|
conn.setInstanceFollowRedirects(false);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
String expectedURL =
|
|
||||||
scheme + conf.get(YarnConfiguration.PROXY_ADDRESS)
|
// Because we're not calling from the proxy's address, we'll be redirected
|
||||||
+ ProxyUriUtils.getPath(app.getAppID(), "/mapreduce");
|
String expectedURL = scheme + conf.get(YarnConfiguration.PROXY_ADDRESS)
|
||||||
|
+ ProxyUriUtils.getPath(app.getAppID(), "/mapreduce", true);
|
||||||
|
|
||||||
Assert.assertEquals(expectedURL,
|
Assert.assertEquals(expectedURL,
|
||||||
conn.getHeaderField(HttpHeaders.LOCATION));
|
conn.getHeaderField(HttpHeaders.LOCATION));
|
||||||
Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY,
|
Assert.assertEquals(HttpStatus.SC_MOVED_TEMPORARILY,
|
||||||
|
|
|
@ -40,6 +40,8 @@ public class ProxyUriUtils {
|
||||||
public static final String PROXY_SERVLET_NAME = "proxy";
|
public static final String PROXY_SERVLET_NAME = "proxy";
|
||||||
/**Base path where the proxy servlet will handle requests.*/
|
/**Base path where the proxy servlet will handle requests.*/
|
||||||
public static final String PROXY_BASE = "/proxy/";
|
public static final String PROXY_BASE = "/proxy/";
|
||||||
|
/**Path component added when the proxy redirects the connection.*/
|
||||||
|
public static final String REDIRECT = "redirect/";
|
||||||
/**Path Specification for the proxy servlet.*/
|
/**Path Specification for the proxy servlet.*/
|
||||||
public static final String PROXY_PATH_SPEC = PROXY_BASE+"*";
|
public static final String PROXY_PATH_SPEC = PROXY_BASE+"*";
|
||||||
/**Query Parameter indicating that the URI was approved.*/
|
/**Query Parameter indicating that the URI was approved.*/
|
||||||
|
@ -57,27 +59,58 @@ public class ProxyUriUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the proxied path for an application.
|
* Get the proxied path for an application.
|
||||||
* @param id the application id to use.
|
*
|
||||||
* @return the base path to that application through the proxy.
|
* @param id the application id to use
|
||||||
|
* @return the base path to that application through the proxy
|
||||||
*/
|
*/
|
||||||
public static String getPath(ApplicationId id) {
|
public static String getPath(ApplicationId id) {
|
||||||
if(id == null) {
|
return getPath(id, false);
|
||||||
throw new IllegalArgumentException("Application id cannot be null ");
|
|
||||||
}
|
|
||||||
return ujoin(PROXY_BASE, uriEncode(id));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the proxied path for an application.
|
* Get the proxied path for an application.
|
||||||
* @param id the application id to use.
|
*
|
||||||
* @param path the rest of the path to the application.
|
* @param id the application id to use
|
||||||
* @return the base path to that application through the proxy.
|
* @param redirected whether the path should contain the redirect component
|
||||||
|
* @return the base path to that application through the proxy
|
||||||
|
*/
|
||||||
|
public static String getPath(ApplicationId id, boolean redirected) {
|
||||||
|
if (id == null) {
|
||||||
|
throw new IllegalArgumentException("Application id cannot be null ");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (redirected) {
|
||||||
|
return ujoin(PROXY_BASE, REDIRECT, uriEncode(id));
|
||||||
|
} else {
|
||||||
|
return ujoin(PROXY_BASE, uriEncode(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the proxied path for an application.
|
||||||
|
*
|
||||||
|
* @param id the application id to use
|
||||||
|
* @param path the rest of the path to the application
|
||||||
|
* @return the base path to that application through the proxy
|
||||||
*/
|
*/
|
||||||
public static String getPath(ApplicationId id, String path) {
|
public static String getPath(ApplicationId id, String path) {
|
||||||
if(path == null) {
|
return getPath(id, path, false);
|
||||||
return getPath(id);
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the proxied path for an application.
|
||||||
|
*
|
||||||
|
* @param id the application id to use
|
||||||
|
* @param path the rest of the path to the application
|
||||||
|
* @param redirected whether the path should contain the redirect component
|
||||||
|
* @return the base path to that application through the proxy
|
||||||
|
*/
|
||||||
|
public static String getPath(ApplicationId id, String path,
|
||||||
|
boolean redirected) {
|
||||||
|
if (path == null) {
|
||||||
|
return getPath(id, redirected);
|
||||||
} else {
|
} else {
|
||||||
return ujoin(getPath(id), path);
|
return ujoin(getPath(id, redirected), path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue