Search in sources :

Example 21 with DistributedQueryRunner

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

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, ImmutableMap.of(), 1)) {
        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(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) Test(org.testng.annotations.Test)

Example 22 with DistributedQueryRunner

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

the class TestEnvironments method testEnvironment1.

@Test(timeOut = 240_000)
public void testEnvironment1() throws Exception {
    String dbConfigUrl = getDbConfigUrl();
    H2ResourceGroupsDao dao = getDao(dbConfigUrl);
    try (DistributedQueryRunner runner = createQueryRunner(dbConfigUrl, dao, TEST_ENVIRONMENT, ImmutableMap.of(), 1)) {
        QueryId firstQuery = createQuery(runner, adhocSession(), LONG_LASTING_QUERY);
        waitForQueryState(runner, firstQuery, RUNNING);
        QueryId secondQuery = createQuery(runner, adhocSession(), LONG_LASTING_QUERY);
        waitForQueryState(runner, secondQuery, RUNNING);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) H2ResourceGroupsDao(com.facebook.presto.resourceGroups.db.H2ResourceGroupsDao) Test(org.testng.annotations.Test)

Example 23 with DistributedQueryRunner

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

the class TestResourceGroupDbIntegration method testMemoryFraction.

@Test
public void testMemoryFraction() throws Exception {
    try (DistributedQueryRunner queryRunner = getSimpleQueryRunner()) {
        queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
        waitForGlobalResourceGroup(queryRunner);
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Test(org.testng.annotations.Test)

Example 24 with DistributedQueryRunner

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

the class TestMemoryManager method testReservedPoolDisabledMultiCoordinator.

@Test(timeOut = 240_000, expectedExceptions = ExecutionException.class, expectedExceptionsMessageRegExp = ".*Query killed because the cluster is out of memory. Please try again in a few minutes.")
public void testReservedPoolDisabledMultiCoordinator() throws Exception {
    Map<String, String> rmProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").put("resource-manager.memory-pool-fetch-interval", "10ms").put("resource-manager.query-heartbeat-interval", "10ms").build();
    Map<String, String> coordinatorProperties = ImmutableMap.<String, String>builder().put("query.low-memory-killer.delay", "5s").put("query.low-memory-killer.policy", "total-reservation").build();
    Map<String, String> extraProperties = ImmutableMap.<String, String>builder().put("experimental.reserved-pool-enabled", "false").build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(rmProperties, coordinatorProperties, extraProperties, 2)) {
        // Reserve all the memory
        QueryId fakeQueryId = new QueryId("fake");
        for (TestingPrestoServer server : queryRunner.getServers()) {
            List<MemoryPool> memoryPools = server.getLocalMemoryManager().getPools();
            assertEquals(memoryPools.size(), 1, "Only general pool should exist");
            assertTrue(memoryPools.get(0).tryReserve(fakeQueryId, "test", memoryPools.get(0).getMaxBytes()));
        }
        List<Future<?>> queryFutures = new ArrayList<>();
        for (int i = 0; i < 2; i++) {
            int coordinator = i;
            Thread.sleep(500);
            queryFutures.add(executor.submit(() -> queryRunner.execute(coordinator, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk")));
        }
        // Wait for one of the queries to die
        waitForQueryToBeKilled(queryRunner);
        // Reserved pool shouldn't exist on the workers and allocation should have been done in the general pool
        for (TestingPrestoServer server : queryRunner.getServers()) {
            Optional<MemoryPool> reserved = server.getLocalMemoryManager().getReservedPool();
            MemoryPool general = server.getLocalMemoryManager().getGeneralPool();
            assertFalse(reserved.isPresent());
            assertTrue(general.getReservedBytes() > 0);
            // Free up the entire pool
            general.free(fakeQueryId, "test", general.getMaxBytes());
            assertTrue(general.getFreeBytes() > 0);
        }
        for (Future<?> query : queryFutures) {
            query.get();
        }
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) QueryId(com.facebook.presto.spi.QueryId) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Test(org.testng.annotations.Test)

Example 25 with DistributedQueryRunner

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

the class TestMemoryManager method testResourceOverCommit.

@Test(timeOut = 240_000)
public void testResourceOverCommit() throws Exception {
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("query.max-memory-per-node", "1kB").put("query.max-total-memory-per-node", "1kB").put("query.max-memory", "1kB").build();
    try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
        try {
            queryRunner.execute("SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
            fail();
        } catch (RuntimeException e) {
        // expected
        }
        Session session = testSessionBuilder().setCatalog("tpch").setSchema("tiny").setSystemProperty(RESOURCE_OVERCOMMIT, "true").build();
        queryRunner.execute(session, "SELECT COUNT(*), clerk FROM orders GROUP BY clerk");
    }
}
Also used : DistributedQueryRunner(com.facebook.presto.tests.DistributedQueryRunner) Session(com.facebook.presto.Session) Test(org.testng.annotations.Test)

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