Search in sources :

Example 11 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TestQueues method testTwoQueriesAtSameTime.

@Test(timeOut = 240_000)
public void testTwoQueriesAtSameTime() throws Exception {
    String dbConfigUrl = getDbConfigUrl();
    H2ResourceGroupsDao dao = getDao(dbConfigUrl);
    try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
        QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
        ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING);
        waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
        waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) QueryState(com.facebook.presto.execution.QueryState) Test(org.testng.annotations.Test)

Example 12 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TpchQueryRunner method main.

public static void main(String[] args) throws Exception {
    Logging.initialize();
    DistributedQueryRunner queryRunner = createQueryRunner(ImmutableMap.of("http-server.http.port", "8080"));
    Thread.sleep(10);
    Logger log = Logger.get(TpchQueryRunner.class);
    log.info("======== SERVER STARTED ========");
    log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Logger(com.facebook.airlift.log.Logger)

Example 13 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class TpchQueryRunner method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Map<String, String> extraProperties, int coordinatorCount) throws Exception {
    DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().setExtraProperties(extraProperties).setResourceManagerEnabled(true).setCoordinatorCount(coordinatorCount).build();
    queryRunner.waitForClusterToGetReady();
    return queryRunner;
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner)

Example 14 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.

the class OracleQueryRunner method createOracleQueryRunner.

public static DistributedQueryRunner createOracleQueryRunner(TestingOracleServer server, Iterable<TpchTable<?>> tables) throws Exception {
    DistributedQueryRunner queryRunner = null;
    try {
        queryRunner = DistributedQueryRunner.builder(createSession()).build();
        queryRunner.installPlugin(new TpchPlugin());
        queryRunner.createCatalog("tpch", "tpch");
        Map<String, String> connectorProperties = new HashMap<>();
        connectorProperties.putIfAbsent("connection-url", server.getJdbcUrl());
        connectorProperties.putIfAbsent("connection-user", TestingOracleServer.TEST_USER);
        connectorProperties.putIfAbsent("connection-password", TestingOracleServer.TEST_PASS);
        connectorProperties.putIfAbsent("allow-drop-table", "true");
        queryRunner.installPlugin(new OraclePlugin());
        queryRunner.createCatalog("oracle", "oracle", connectorProperties);
        copyTpchTables(queryRunner, "tpch", TINY_SCHEMA_NAME, createSession(), tables);
        return queryRunner;
    } catch (Throwable e) {
        closeAllSuppress(e, queryRunner, server);
        throw e;
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) HashMap(java.util.HashMap) TpchPlugin(com.facebook.presto.tpch.TpchPlugin)

Example 15 with DistributedQueryRunner

use of com.facebook.presto.tests.DistributedQueryRunner 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)

Aggregations

DistributedQueryRunner (com.facebook.presto.tests.DistributedQueryRunner)111 Test (org.testng.annotations.Test)36 TpchPlugin (com.facebook.presto.tpch.TpchPlugin)33 Session (com.facebook.presto.Session)26 QueryId (com.facebook.presto.spi.QueryId)19 Logger (com.facebook.airlift.log.Logger)15 TestingPrestoServer (com.facebook.presto.server.testing.TestingPrestoServer)14 MaterializedResult (com.facebook.presto.testing.MaterializedResult)13 QueryRunner (com.facebook.presto.testing.QueryRunner)13 ImmutableMap (com.google.common.collect.ImmutableMap)10 ResourceGroupManagerPlugin (com.facebook.presto.resourceGroups.ResourceGroupManagerPlugin)9 ArrayList (java.util.ArrayList)8 File (java.io.File)7 BeforeClass (org.testng.annotations.BeforeClass)7 JettyHttpClient (com.facebook.airlift.http.client.jetty.JettyHttpClient)6 FileResourceGroupConfigurationManagerFactory (com.facebook.presto.resourceGroups.FileResourceGroupConfigurationManagerFactory)6 H2ResourceGroupsDao (com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao)6 Path (java.nio.file.Path)6 Future (java.util.concurrent.Future)6 MetastoreContext (com.facebook.presto.hive.metastore.MetastoreContext)5