Search in sources :

Example 11 with TestingPrestoServer

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

the class TestProxyServer method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
    sharedSecretFile = Files.createTempFile("secret", "txt");
    Files.write(sharedSecretFile, sharedSecret);
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    server.refreshNodes();
    Bootstrap app = new Bootstrap(new TestingNodeModule("test"), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), new TestingJmxModule(), new ProxyModule());
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperty("proxy.uri", server.getBaseUrl().toString()).setRequiredConfigurationProperty("proxy.shared-secret-file", sharedSecretFile.toString()).quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    httpServerInfo = injector.getInstance(HttpServerInfo.class);
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
    setupTestTable();
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) HttpServerInfo(com.facebook.airlift.http.server.HttpServerInfo) BeforeClass(org.testng.annotations.BeforeClass)

Example 12 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 resourceManager, boolean resourceManagerEnabled, boolean coordinator, Map<String, String> extraProperties, SqlParserOptions parserOptions, String environment, Optional<Path> baseDataDir, List<Module> extraModules) throws Exception {
    long start = nanoTime();
    ImmutableMap.Builder<String, String> propertiesBuilder = ImmutableMap.<String, String>builder().put("query.client.timeout", "10m").put("exchange.http-client.idle-timeout", "1h").put("task.max-index-memory", // causes index joins to fault load
    "16kB").put("datasources", "system").put("distributed-index-joins-enabled", "true").put("exchange.checksum-enabled", "true");
    if (coordinator) {
        propertiesBuilder.put("node-scheduler.include-coordinator", "true");
        propertiesBuilder.put("join-distribution-type", "PARTITIONED");
    }
    HashMap<String, String> properties = new HashMap<>(propertiesBuilder.build());
    properties.putAll(extraProperties);
    TestingPrestoServer server = new TestingPrestoServer(resourceManager, resourceManagerEnabled, coordinator, properties, environment, discoveryUri, parserOptions, extraModules, baseDataDir);
    String nodeRole = coordinator ? "coordinator" : resourceManager ? "resourceManager" : "worker";
    log.info("Created %s TestingPrestoServer in %s: %s", nodeRole, nanosSince(start).convertToMostSuccinctTimeUnit(), server.getBaseUrl());
    return server;
}
Also used : HashMap(java.util.HashMap) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ImmutableMap(com.google.common.collect.ImmutableMap)

Example 13 with TestingPrestoServer

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

the class TestGenerateTokenFilter method setup.

@BeforeClass
public void setup() throws Exception {
    server = new TestingPrestoServer(ImmutableList.of(new TestGenerateTokenFilterModule()));
    httpClient = (JettyHttpClient) server.getInstance(Key.get(HttpClient.class, GenerateTokenFilterTest.class));
    // extract the filter
    List<HttpRequestFilter> filters = httpClient.getRequestFilters();
    assertEquals(filters.size(), 2);
    assertInstanceOf(filters.get(1), GenerateTraceTokenRequestFilter.class);
    filter = (GenerateTraceTokenRequestFilter) filters.get(1);
}
Also used : HttpRequestFilter(com.facebook.airlift.http.client.HttpRequestFilter) JettyHttpClient(com.facebook.airlift.http.client.jetty.JettyHttpClient) HttpClient(com.facebook.airlift.http.client.HttpClient) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) BeforeClass(org.testng.annotations.BeforeClass)

Example 14 with TestingPrestoServer

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

the class TestNodeResource method setup.

@BeforeMethod
public void setup() throws Exception {
    server = new TestingPrestoServer();
    client = new JettyHttpClient();
}
Also used : JettyHttpClient(com.facebook.airlift.http.client.jetty.JettyHttpClient) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) BeforeMethod(org.testng.annotations.BeforeMethod)

Example 15 with TestingPrestoServer

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

the class TestJdbcWarnings method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    server = new TestingPrestoServer(true, ImmutableMap.<String, String>builder().put("testing-warning-collector.add-warnings", "true").put("testing-warning-collector.preloaded-warnings", String.valueOf(PRELOADED_WARNINGS)).build(), null, null, new SqlParserOptions(), ImmutableList.of());
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    waitForNodeRefresh(server);
}
Also used : SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) BeforeClass(org.testng.annotations.BeforeClass)

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