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