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();
}
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");
}
}
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());
}
}
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;
}
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;
}
Aggregations