Search in sources :

Example 46 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestServerInfoResource method testGetServerStateWithRequiredResourceManagerCoordinators.

@Test(timeOut = 30_000, groups = { "createQueryRunner" })
public void testGetServerStateWithRequiredResourceManagerCoordinators() {
    TestingPrestoServer server = queryRunner.getCoordinator(0);
    URI uri = uriBuilderFrom(server.getBaseUrl().resolve("/v1/info/state")).build();
    Request request = prepareGet().setHeader(PRESTO_USER, "user").setUri(uri).build();
    NodeState state = client.execute(request, createJsonResponseHandler(jsonCodec(NodeState.class)));
    assertEquals(state, NodeState.ACTIVE);
}
Also used : NodeState(com.facebook.presto.spi.NodeState) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Request(com.facebook.airlift.http.client.Request) URI(java.net.URI) Test(org.testng.annotations.Test)

Example 47 with TestingPrestoServer

use of com.facebook.presto.server.testing.TestingPrestoServer in project presto by prestodb.

the class TestBrutalShutdown method queryRetryOnShutdown.

private static void queryRetryOnShutdown(Session session, DistributedQueryRunner queryRunner, ListeningExecutorService executor, int totalQueries) throws Exception {
    List<ListenableFuture<?>> queryFutures = new ArrayList<>();
    for (int i = 0; i < totalQueries; i++) {
        queryFutures.add(executor.submit(() -> queryRunner.execute(session, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
    }
    TestingPrestoServer worker = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).findFirst().get();
    TaskManager taskManager = worker.getTaskManager();
    // wait until tasks show up on the worker
    while (taskManager.getAllTaskInfo().isEmpty()) {
        MILLISECONDS.sleep(100);
    }
    // kill a worker
    worker.stopResponding();
    for (ListenableFuture<?> future : queryFutures) {
        try {
            future.get();
        } catch (Exception e) {
        // it is ok to fail
        }
    }
}
Also used : TaskManager(com.facebook.presto.execution.TaskManager) ArrayList(java.util.ArrayList) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ListenableFuture(com.google.common.util.concurrent.ListenableFuture)

Aggregations

TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)47 Test (org.testng.annotations.Test)19 BeforeClass (org.testng.annotations.BeforeClass)16 DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)13 ArrayList (java.util.ArrayList)9 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)7 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)6 NodeState (com.facebook.presto.spi.NodeState)6 QueryId (com.facebook.presto.spi.QueryId)6 Future (java.util.concurrent.Future)6 ServerInfoResource (com.facebook.presto.server.ServerInfoResource)5 BasicQueryInfo (com.facebook.presto.server.BasicQueryInfo)4 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)4 ImmutableMap (com.google.common.collect.ImmutableMap)4 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)4 Response (javax.ws.rs.core.Response)4 Request (com.facebook.airlift.http.client.Request)3 TaskManager (com.facebook.presto.execution.TaskManager)3 BlackHolePlugin (com.facebook.presto.plugin.blackhole.BlackHolePlugin)3 TestShutdownAction (com.facebook.presto.server.testing.TestingPrestoServer.TestShutdownAction)3