use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.
the class TestQueues method testTwoQueriesAtSameTime.
private void testTwoQueriesAtSameTime(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
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, queuedOrRunning);
waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning);
}
}
use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.
the class TestQueues method testTooManyQueries.
private void testTooManyQueries(boolean resourceGroups) throws Exception {
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
if (resourceGroups) {
builder.put("experimental.resource-groups-enabled", "true");
} else {
builder.put("query.queue-config-file", getResourceFilePath("queue_config_dashboard.json"));
}
Map<String, String> properties = builder.build();
try (DistributedQueryRunner queryRunner = createQueryRunner(properties)) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
QueryId thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, FAILED);
}
}
use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.
the class TestQueues method testTooManyQueries.
@Test(timeOut = 240_000)
public void testTooManyQueries() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
QueryId firstDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
QueryId secondDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
QueryId thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, FAILED);
// Allow one more query to run and resubmit third query
dao.updateResourceGroup(3, "user-${USER}", "1MB", 3, 4, null, null, null, null, null, 1L);
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, 2, null, null, null, null, null, 3L);
waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
thirdDashboardQuery = createQuery(queryRunner, newDashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, QUEUED);
// Lower running queries in dashboard resource groups and wait until groups are reconfigured
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, 1, null, null, null, null, null, 3L);
ResourceGroupManager manager = queryRunner.getCoordinator().getResourceGroupManager().get();
do {
MILLISECONDS.sleep(500);
} while (manager.getResourceGroupInfo(new ResourceGroupId(new ResourceGroupId(new ResourceGroupId("global"), "user-user"), "dashboard-user")).getMaxRunningQueries() != 1);
// Cancel query and verify that third query is still queued
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
MILLISECONDS.sleep(2000);
waitForQueryState(queryRunner, thirdDashboardQuery, QUEUED);
}
}
use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.
the class TestQueues method testRejection.
@Test(timeOut = 240_000)
public void testRejection() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
try (DistributedQueryRunner queryRunner = createQueryRunner(dbConfigUrl, dao)) {
// Verify the query cannot be submitted
QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
assertEquals(queryManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
int selectorCount = getSelectors(queryRunner).size();
dao.insertSelector(4, "user.*", "(?i).*reject.*");
assertEquals(dao.getSelectors().size(), selectorCount + 1);
//MILLISECONDS.sleep(2000);
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() == selectorCount);
// Verify the query can be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, RUNNING);
dao.deleteSelector(4, "user.*", "(?i).*reject.*");
do {
MILLISECONDS.sleep(500);
} while (getSelectors(queryRunner).size() != selectorCount);
// Verify the query cannot be submitted
queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
}
}
use of com.facebook.presto.tests.DistributedQueryRunner in project presto by prestodb.
the class TestQueues method getSimpleQueryRunner.
static DistributedQueryRunner getSimpleQueryRunner() throws Exception {
String dbConfigUrl = getDbConfigUrl();
H2ResourceGroupsDao dao = getDao(dbConfigUrl);
ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
builder.put("experimental.resource-groups-enabled", "true");
Map<String, String> properties = builder.build();
DistributedQueryRunner queryRunner = TpchQueryRunner.createQueryRunner(properties);
Plugin h2ResourceGroupManagerPlugin = new H2ResourceGroupManagerPlugin();
queryRunner.installPlugin(h2ResourceGroupManagerPlugin);
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager(NAME, ImmutableMap.of("resource-groups.config-db-url", dbConfigUrl));
setup(queryRunner, dao);
return queryRunner;
}
Aggregations