Search in sources :

Example 1 with TestingPrestoServer

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

the class DistributedQueryRunner method isConnectionVisibleToAllNodes.

private boolean isConnectionVisibleToAllNodes(ConnectorId connectorId) {
    for (TestingPrestoServer server : servers) {
        server.refreshNodes();
        Set<Node> activeNodesWithConnector = server.getActiveNodesWithConnector(connectorId);
        if (activeNodesWithConnector.size() != servers.size()) {
            return false;
        }
    }
    return true;
}
Also used : Node(com.facebook.presto.spi.Node) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer)

Example 2 with TestingPrestoServer

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

the class TestServerInfoResource method testServerShutdown.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdown() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        Response response = serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
        assertEquals(response.getStatus(), 200);
        NodeState nodeState = serverInfoResource.getServerState();
        assertTrue(nodeState == NodeState.SHUTTING_DOWN);
    }
}
Also used : Response(javax.ws.rs.core.Response) NodeState(com.facebook.presto.spi.NodeState) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 3 with TestingPrestoServer

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

the class TestServerInfoResource method testServerShutdownFollowedByActive.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testServerShutdownFollowedByActive() throws Exception {
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, ImmutableMap.of())) {
        TestingPrestoServer coordinator = queryRunner.getServers().stream().filter(TestingPrestoServer::isCoordinator).findFirst().get();
        ServerInfoResource serverInfoResource = coordinator.getServerInfoResource();
        serverInfoResource.updateState(NodeState.SHUTTING_DOWN);
        Response response = serverInfoResource.updateState(NodeState.ACTIVE);
        assertEquals(response.getStatus(), BAD_REQUEST.getStatusCode());
        assertEquals(response.getEntity(), "Cluster is shutting down");
    }
}
Also used : Response(javax.ws.rs.core.Response) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ServerInfoResource(com.facebook.presto.server.ServerInfoResource) Test(org.testng.annotations.Test)

Example 4 with TestingPrestoServer

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

the class TestMemoryWorkerCrash method closeWorker.

private void closeWorker() throws Exception {
    int nodeCount = getNodeCount();
    DistributedQueryRunner queryRunner = (DistributedQueryRunner) getQueryRunner();
    TestingPrestoServer worker = queryRunner.getServers().stream().filter(server -> !server.isCoordinator()).findAny().orElseThrow(() -> new IllegalStateException("No worker nodes"));
    worker.close();
    waitForNodes(nodeCount - 1);
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer)

Example 5 with TestingPrestoServer

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

the class TestMemoryManager method testReservedPoolDisabledMultiCoordinator.

@Test(timeOut = 240_000, expectedExceptions = ExecutionException.class, expectedExceptionsMessageRegExp = ".*Query killed because the cluster is out of memory. Please try again in a few minutes.")
public void testReservedPoolDisabledMultiCoordinator() throws Exception {
    Map<String, String> rmProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").put("resource-manager.memory-pool-fetch-interval", "10ms").put("resource-manager.query-heartbeat-interval", "10ms").build();
    Map<String, String> coordinatorProperties = ImmutableMap.<String, String>builder().put("query.low-memory-killer.delay", "5s").put("query.low-memory-killer.policy", "total-reservation").build();
    Map<String, String> extraProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(rmProperties, coordinatorProperties, extraProperties, 2)) {
        // Reserve all the memory
        QueryId fakeQueryId = new QueryId("fake");
        for (TestingPrestoServer server : queryRunner.getServers()) {
            List<MemoryPool> memoryPools = server.getLocalMemoryManager().getPools();
            assertEquals(memoryPools.size(), 1, "Only general pool should exist");
            assertTrue(memoryPools.get(0).tryReserve(fakeQueryId, "test", memoryPools.get(0).getMaxBytes()));
        }
        List<Future<?>> queryFutures = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            int coordinator = i;
            Thread.sleep(500);
            queryFutures.add(executor.submit(() -> queryRunner.execute(coordinator, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
        }
        // Wait for one of the queries to die
        waitForQueryToBeKilled(queryRunner);
        // Reserved pool shouldn't exist on the workers and allocation should have been done in the general pool
        for (TestingPrestoServer server : queryRunner.getServers()) {
            Optional<MemoryPool> reserved = server.getLocalMemoryManager().getReservedPool();
            MemoryPool general = server.getLocalMemoryManager().getGeneralPool();
            assertFalse(reserved.isPresent());
            assertTrue(general.getReservedBytes() > 0);
            // Free up the entire pool
            general.free(fakeQueryId, "test", general.getMaxBytes());
            assertTrue(general.getFreeBytes() > 0);
        }
        for (Future<?> query : queryFutures) {
            query.get();
        }
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Test(org.testng.annotations.Test)

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