Search in sources :

Example 16 with TestingPrestoServer

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

the class TestPrestoDatabaseMetaData method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    Logging.initialize();
    server = new TestingPrestoServer();
}
Also used : TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) BeforeClass(org.testng.annotations.BeforeClass)

Example 17 with TestingPrestoServer

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

the class TestJdbcPreparedStatement method setup.

@BeforeClass
public void setup() throws Exception {
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    waitForNodeRefresh(server);
    try (Connection connection = createConnection();
        Statement statement = connection.createStatement()) {
        statement.executeUpdate("CREATE SCHEMA blackhole.blackhole");
    }
}
Also used : BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) Connection(java.sql.Connection) BeforeClass(org.testng.annotations.BeforeClass)

Example 18 with TestingPrestoServer

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

the class TestGracefulShutdown method testShutdown.

@Test(timeOut = SHUTDOWN_TIMEOUT_MILLIS)
public void testShutdown() throws Exception {
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("node-scheduler.include-coordinator", "false").put("shutdown.grace-period", "10s").build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(TINY_SESSION, properties)) {
        List<ListenableFuture<?>> queryFutures = new ArrayList<>();
        for (int i = 0; i < 5; i++) {
            queryFutures.add(executor.submit(() -> queryRunner.execute("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(500);
        }
        worker.getGracefulShutdownHandler().requestShutdown();
        Futures.allAsList(queryFutures).get();
        List<QueryInfo> queryInfos = queryRunner.getCoordinator().getQueryManager().getAllQueryInfo();
        for (QueryInfo info : queryInfos) {
            assertEquals(info.getState(), FINISHED);
        }
        TestShutdownAction shutdownAction = (TestShutdownAction) worker.getShutdownAction();
        shutdownAction.waitForShutdownComplete(SHUTDOWN_TIMEOUT_MILLIS);
        assertTrue(shutdownAction.isWorkerShutdown());
    }
}
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) TestShutdownAction(com.facebook.presto.server.testing.TestingPrestoServer.TestShutdownAction) QueryInfo(com.facebook.presto.execution.QueryInfo) Test(org.testng.annotations.Test)

Example 19 with TestingPrestoServer

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

the class DistributedQueryRunner method createTestingPrestoServer.

private static TestingPrestoServer createTestingPrestoServer(URI discoveryUri, boolean coordinator, Map<String, String> extraProperties, SqlParserOptions parserOptions) throws Exception {
    long start = System.nanoTime();
    ImmutableMap.Builder<String, String> propertiesBuilder = ImmutableMap.<String, String>builder().put("query.client.timeout", "10m").put("exchange.http-client.idle-timeout", "1h").put("compiler.interpreter-enabled", "false").put("task.max-index-memory", // causes index joins to fault load
    "16kB").put("datasources", "system").put("distributed-index-joins-enabled", "true").put("optimizer.optimize-mixed-distinct-aggregations", "true");
    if (coordinator) {
        propertiesBuilder.put("node-scheduler.include-coordinator", "true");
        propertiesBuilder.put("distributed-joins-enabled", "true");
    }
    HashMap<String, String> properties = new HashMap<>(propertiesBuilder.build());
    properties.putAll(extraProperties);
    TestingPrestoServer server = new TestingPrestoServer(coordinator, properties, ENVIRONMENT, discoveryUri, parserOptions, ImmutableList.of());
    log.info("Created TestingPrestoServer in %s", nanosSince(start).convertToMostSuccinctTimeUnit());
    return server;
}
Also used : HashMap(java.util.HashMap) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 20 with TestingPrestoServer

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

the class HiveFunctionsTestUtils method createTestingPrestoServer.

public static TestingPrestoServer createTestingPrestoServer() throws Exception {
    TestingPrestoServer server = new TestingPrestoServer();
    server.installPlugin(new MemoryPlugin());
    server.installPlugin(new HiveFunctionNamespacePlugin());
    server.createCatalog("memory", "memory");
    FunctionAndTypeManager functionAndTypeManager = server.getInstance(Key.get(FunctionAndTypeManager.class));
    functionAndTypeManager.loadFunctionNamespaceManager("hive-functions", "hive", getNamespaceManagerCreationProperties());
    server.refreshNodes();
    return server;
}
Also used : FunctionAndTypeManager(com.facebook.presto.metadata.FunctionAndTypeManager) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) MemoryPlugin(com.facebook.presto.plugin.memory.MemoryPlugin)

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