use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method assertRouting.
private void assertRouting(String path, RouteDestination destination) {
for (HttpMethod method : ImmutableList.of(HttpMethod.GET, HttpMethod.POST, HttpMethod.DELETE)) {
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, method, path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(destination, result);
}
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testMetricsPath.
@Test
public void testMetricsPath() throws Exception {
// Following URIs might not give actual results but we want to test resilience of Router Path Lookup
String flowPath = "/v3///metrics/system/apps/InvalidApp//";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), flowPath);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, flowPath, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
flowPath = "/v3/metrics";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("DELETE"), flowPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, flowPath, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
flowPath = "/v3/metrics//";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("POST"), flowPath);
result = pathLookup.getRoutingService(FALLBACKSERVICE, flowPath, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
testMetricsPath("/v3/metrics/search?target=tag&tag=namespace:user");
testMetricsPath("/v3/metrics/search?target=tag&tag=app:PurchaeHistory&tag=flow:PurchaseFlow");
testMetricsPath("/v3/metrics/search?target=metric&tag=app:PurchaeHistory&tag=flow:PurchaseFlow");
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testRouterWebAppPathLookUp.
@Test
public void testRouterWebAppPathLookUp() throws Exception {
// Calls to webapp service with appName in the first split of URI will be routed to webappService
// But if it has v2 then use the regular router lookup logic to find the appropriate service
final String webAppService = "webapp$HOST";
String path = "/sentiApp/abcd/efgh///";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
RouteDestination result = pathLookup.getRoutingService(webAppService, path, httpRequest);
Assert.assertEquals(new RouteDestination(webAppService), result);
path = "/v3//metrics///";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(webAppService, path, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testRouterExploreStatusPathLookUp.
@Test
public void testRouterExploreStatusPathLookUp() throws Exception {
String explorePath = "/v3/explore/status";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), explorePath);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, explorePath, httpRequest);
Assert.assertEquals(RouterPathLookup.EXPLORE_HTTP_USER_SERVICE, result);
}
use of io.netty.handler.codec.http.DefaultHttpRequest in project cdap by caskdata.
the class RouterPathTest method testSystemServicePath.
@Test
public void testSystemServicePath() {
String path = "/v3/system/services/foo/logs";
HttpRequest httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
RouteDestination result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
path = "/v3/system/services/foo/live-info";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
// this clashes with a rule for stream handler and fails if the rules are evaluated in wrong order [CDAP-2159]
path = "/v3/system/services/streams/logs";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.METRICS, result);
// this clashes with a rule for stream handler and fails if the rules are evaluated in wrong order [CDAP-2159]
path = "/v3/system/services/streams/live-info";
httpRequest = new DefaultHttpRequest(VERSION, new HttpMethod("GET"), path);
result = pathLookup.getRoutingService(FALLBACKSERVICE, path, httpRequest);
Assert.assertEquals(RouterPathLookup.APP_FABRIC_HTTP, result);
}
Aggregations