Search in sources :

Example 11 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

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(io.prestosql.tests.DistributedQueryRunner) TestingPrestoServer(io.prestosql.server.testing.TestingPrestoServer)

Example 12 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class TestMemoryWorkerCrash method waitForNodes.

private void waitForNodes(int numberOfNodes) throws InterruptedException {
    DistributedQueryRunner queryRunner = (DistributedQueryRunner) getQueryRunner();
    long start = System.nanoTime();
    while (queryRunner.getCoordinator().refreshNodes().getActiveNodes().size() < numberOfNodes) {
        assertLessThan(nanosSince(start), new Duration(10, SECONDS));
        MILLISECONDS.sleep(10);
    }
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) Duration(io.airlift.units.Duration)

Example 13 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class MemoryQueryRunner method main.

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

Example 14 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class TestDataCenterHTTPClientV1 method createQueryRunner.

public static DistributedQueryRunner createQueryRunner(Session session) throws Exception {
    DistributedQueryRunner distributedQueryRunner = DistributedQueryRunner.builder(session).setNodeCount(2).build();
    try {
        distributedQueryRunner.installPlugin(new TpchPlugin());
        distributedQueryRunner.createCatalog("tpch", "tpch");
        return distributedQueryRunner;
    } catch (Exception e) {
        distributedQueryRunner.close();
        throw e;
    }
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) TpchPlugin(io.prestosql.plugin.tpch.TpchPlugin)

Example 15 with DistributedQueryRunner

use of io.prestosql.tests.DistributedQueryRunner in project hetu-core by openlookeng.

the class TestEnvironments method testEnvironment2.

@Test(timeOut = 240_000)
public void testEnvironment2() throws Exception {
    String dbConfigUrl = getDbConfigUrl();
    H2ResourceGroupsDao dao = getDao(dbConfigUrl);
    try (DistributedQueryRunner runner = createQueryRunner(dbConfigUrl, dao, TEST_ENVIRONMENT_2)) {
        QueryId firstQuery = createQuery(runner, adhocSession(), LONG_LASTING_QUERY);
        waitForQueryState(runner, firstQuery, RUNNING);
        QueryId secondQuery = createQuery(runner, adhocSession(), LONG_LASTING_QUERY);
        // there is no queueing in TEST_ENVIRONMENT_2, so the second query should fail right away
        waitForQueryState(runner, secondQuery, FAILED);
    }
}
Also used : DistributedQueryRunner(io.prestosql.tests.DistributedQueryRunner) QueryId(io.prestosql.spi.QueryId) H2ResourceGroupsDao(io.prestosql.plugin.resourcegroups.db.H2ResourceGroupsDao) Test(org.testng.annotations.Test)

Aggregations

DistributedQueryRunner (io.prestosql.tests.DistributedQueryRunner)75 Test (org.testng.annotations.Test)28 TpchPlugin (io.prestosql.plugin.tpch.TpchPlugin)22 Session (io.prestosql.Session)16 QueryId (io.prestosql.spi.QueryId)13 MaterializedResult (io.prestosql.testing.MaterializedResult)13 ResourceGroupManagerPlugin (io.prestosql.plugin.resourcegroups.ResourceGroupManagerPlugin)11 Logger (io.airlift.log.Logger)10 HashMap (java.util.HashMap)8 ResultWithQueryId (io.prestosql.tests.ResultWithQueryId)7 List (java.util.List)7 Assert.assertTrue (org.testng.Assert.assertTrue)7 ImmutableSet (com.google.common.collect.ImmutableSet)6 ENABLE_DYNAMIC_FILTERING (io.prestosql.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING)6 JOIN_DISTRIBUTION_TYPE (io.prestosql.SystemSessionProperties.JOIN_DISTRIBUTION_TYPE)6 OperatorStats (io.prestosql.operator.OperatorStats)6 TestingPrestoServer (io.prestosql.server.testing.TestingPrestoServer)6 FeaturesConfig (io.prestosql.sql.analyzer.FeaturesConfig)6 TestingConnectorSession (io.prestosql.testing.TestingConnectorSession)6 AbstractTestQueryFramework (io.prestosql.tests.AbstractTestQueryFramework)6