Search in sources :

Example 1 with RestServer

use of com.github.ambry.rest.RestServer in project ambry by linkedin.

the class FrontendIntegrationTest method setup.

/**
 * Sets up an Ambry frontend server.
 * @throws Exception
 */
@BeforeClass
public static void setup() throws Exception {
    ambryRestServer = new RestServer(FRONTEND_VERIFIABLE_PROPS, CLUSTER_MAP, new LoggingNotificationSystem(), SSLFactory.getNewInstance(new SSLConfig(FRONTEND_VERIFIABLE_PROPS)));
    ambryRestServer.start();
    plaintextNettyClient = new NettyClient("localhost", PLAINTEXT_SERVER_PORT, null);
    sslNettyClient = new NettyClient("localhost", SSL_SERVER_PORT, SSLFactory.getNewInstance(new SSLConfig(SSL_CLIENT_VERIFIABLE_PROPS)));
}
Also used : RestServer(com.github.ambry.rest.RestServer) SSLConfig(com.github.ambry.config.SSLConfig) NettyClient(com.github.ambry.rest.NettyClient) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) BeforeClass(org.junit.BeforeClass)

Example 2 with RestServer

use of com.github.ambry.rest.RestServer in project ambry by linkedin.

the class FrontendIntegrationTest method disableUndeleteTest.

/**
 * Test when the undelete is disabled.
 */
@Test
public void disableUndeleteTest() throws Exception {
    assumeTrue(!enableUndeleteTested);
    enableUndeleteTested = true;
    File trustStoreFile = File.createTempFile("truststore", ".jks");
    trustStoreFile.deleteOnExit();
    VerifiableProperties vprop = buildFrontendVProps(trustStoreFile, false, PLAINTEXT_SERVER_PORT + 100, SSL_SERVER_PORT + 100);
    RestServer ambryRestServer = new RestServer(vprop, CLUSTER_MAP, new LoggingNotificationSystem(), SSLFactory.getNewInstance(new SSLConfig(vprop)));
    ambryRestServer.start();
    NettyClient plaintextNettyClient = new NettyClient("localhost", PLAINTEXT_SERVER_PORT + 100, null);
    NettyClient sslNettyClient = new NettyClient("localhost", SSL_SERVER_PORT + 100, SSLFactory.getNewInstance(new SSLConfig(SSL_CLIENT_VERIFIABLE_PROPS)));
    NettyClient nettyClient = useSSL ? sslNettyClient : plaintextNettyClient;
    String blobId = "randomblobid";
    HttpHeaders headers = new DefaultHttpHeaders();
    headers.set(RestUtils.Headers.BLOB_ID, addClusterPrefix ? "/" + CLUSTER_NAME + blobId : blobId);
    headers.set(RestUtils.Headers.SERVICE_ID, "updateBlobTtlAndVerify");
    FullHttpRequest httpRequest = buildRequest(HttpMethod.PUT, "/" + Operations.UNDELETE, headers, null);
    ResponseParts responseParts = nettyClient.sendRequest(httpRequest, null, null).get();
    HttpResponse response = getHttpResponse(responseParts);
    assertEquals("Unexpected response status", HttpResponseStatus.BAD_REQUEST, response.status());
    plaintextNettyClient.close();
    sslNettyClient.close();
    ambryRestServer.shutdown();
}
Also used : RestServer(com.github.ambry.rest.RestServer) SSLConfig(com.github.ambry.config.SSLConfig) NettyClient(com.github.ambry.rest.NettyClient) HttpHeaders(io.netty.handler.codec.http.HttpHeaders) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) DefaultFullHttpRequest(io.netty.handler.codec.http.DefaultFullHttpRequest) FullHttpRequest(io.netty.handler.codec.http.FullHttpRequest) VerifiableProperties(com.github.ambry.config.VerifiableProperties) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) DefaultHttpHeaders(io.netty.handler.codec.http.DefaultHttpHeaders) HttpResponse(io.netty.handler.codec.http.HttpResponse) ResponseParts(com.github.ambry.rest.NettyClient.ResponseParts) File(java.io.File) Test(org.junit.Test)

Example 3 with RestServer

use of com.github.ambry.rest.RestServer in project ambry by linkedin.

the class FrontendQuotaIntegrationTest method setup.

/**
 * Sets up an Ambry frontend server.
 * @throws Exception
 */
@Before
public void setup() throws Exception {
    ACCOUNT = ACCOUNT_SERVICE.createAndAddRandomAccount(QuotaResourceType.ACCOUNT);
    CONTAINER = ACCOUNT.getContainerById(Container.DEFAULT_PUBLIC_CONTAINER_ID);
    VerifiableProperties quotaProps = buildFrontendVPropsForQuota(TRUST_STORE_FILE, true, quotaMode, ACCOUNT, throttleRequest);
    ambryRestServer = new RestServer(quotaProps, CLUSTER_MAP, new LoggingNotificationSystem(), SSLFactory.getNewInstance(new SSLConfig(FRONTEND_VERIFIABLE_PROPS)));
    ambryRestServer.start();
    this.frontendConfig = FRONTEND_CONFIG;
    this.nettyClient = new NettyClient("localhost", PLAINTEXT_SERVER_PORT, null);
}
Also used : RestServer(com.github.ambry.rest.RestServer) SSLConfig(com.github.ambry.config.SSLConfig) NettyClient(com.github.ambry.rest.NettyClient) VerifiableProperties(com.github.ambry.config.VerifiableProperties) LoggingNotificationSystem(com.github.ambry.commons.LoggingNotificationSystem) Before(org.junit.Before)

Aggregations

LoggingNotificationSystem (com.github.ambry.commons.LoggingNotificationSystem)3 SSLConfig (com.github.ambry.config.SSLConfig)3 NettyClient (com.github.ambry.rest.NettyClient)3 RestServer (com.github.ambry.rest.RestServer)3 VerifiableProperties (com.github.ambry.config.VerifiableProperties)2 ResponseParts (com.github.ambry.rest.NettyClient.ResponseParts)1 DefaultFullHttpRequest (io.netty.handler.codec.http.DefaultFullHttpRequest)1 DefaultHttpHeaders (io.netty.handler.codec.http.DefaultHttpHeaders)1 FullHttpRequest (io.netty.handler.codec.http.FullHttpRequest)1 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)1 HttpResponse (io.netty.handler.codec.http.HttpResponse)1 File (java.io.File)1 Before (org.junit.Before)1 BeforeClass (org.junit.BeforeClass)1 Test (org.junit.Test)1