Search in sources :

Example 61 with HttpMethod

use of io.netty.handler.codec.http.HttpMethod 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);
    }
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpMethod(io.netty.handler.codec.http.HttpMethod)

Example 62 with HttpMethod

use of io.netty.handler.codec.http.HttpMethod 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");
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpMethod(io.netty.handler.codec.http.HttpMethod) Test(org.junit.Test)

Example 63 with HttpMethod

use of io.netty.handler.codec.http.HttpMethod 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);
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpMethod(io.netty.handler.codec.http.HttpMethod) Test(org.junit.Test)

Example 64 with HttpMethod

use of io.netty.handler.codec.http.HttpMethod 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);
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpMethod(io.netty.handler.codec.http.HttpMethod) Test(org.junit.Test)

Example 65 with HttpMethod

use of io.netty.handler.codec.http.HttpMethod 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);
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpMethod(io.netty.handler.codec.http.HttpMethod) Test(org.junit.Test)

Aggregations

HttpMethod (io.netty.handler.codec.http.HttpMethod)95 Test (org.junit.Test)51 HttpRequest (io.netty.handler.codec.http.HttpRequest)28 DefaultHttpRequest (io.netty.handler.codec.http.DefaultHttpRequest)25 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)21 URI (java.net.URI)15 IOException (java.io.IOException)13 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)11 HttpVersion (io.netty.handler.codec.http.HttpVersion)11 DefaultHttpClient (org.jocean.http.client.impl.DefaultHttpClient)11 TestChannelCreator (org.jocean.http.client.impl.TestChannelCreator)11 TestChannelPool (org.jocean.http.client.impl.TestChannelPool)11 DefaultSignalClient (org.jocean.http.rosa.impl.DefaultSignalClient)11 HttpTrade (org.jocean.http.server.HttpServerBuilder.HttpTrade)11 Subscription (rx.Subscription)11 Action2 (rx.functions.Action2)11 ByteBuf (io.netty.buffer.ByteBuf)10 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)10 Map (java.util.Map)9