use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueues method testResourceGroupManagerWithTwoDashboardQueriesRequestedAtTheSameTime.
@Test(timeOut = 240_000)
public void testResourceGroupManagerWithTwoDashboardQueriesRequestedAtTheSameTime() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner()) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
QueryId firstDashboardQuery = createDashboardQuery(queryRunner);
QueryId secondDashboardQuery = createDashboardQuery(queryRunner);
ImmutableSet<QueryState> queuedOrRunning = ImmutableSet.of(QUEUED, RUNNING);
waitForQueryState(queryRunner, firstDashboardQuery, queuedOrRunning);
waitForQueryState(queryRunner, secondDashboardQuery, queuedOrRunning);
}
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueues method testResourceGroupManager.
@Test(timeOut = 240_000)
public void testResourceGroupManager() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner()) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
// submit first "dashboard" query
QueryId firstDashboardQuery = createDashboardQuery(queryRunner);
// wait for the first "dashboard" query to start
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
// submit second "dashboard" query
QueryId secondDashboardQuery = createDashboardQuery(queryRunner);
// wait for the second "dashboard" query to be queued ("dashboard.${USER}" queue strategy only allows one "dashboard" query to be accepted for execution)
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
// submit first non "dashboard" query
QueryId firstNonDashboardQuery = createAdHocQuery(queryRunner);
// wait for the first non "dashboard" query to start
waitForQueryState(queryRunner, firstNonDashboardQuery, RUNNING);
// submit second non "dashboard" query
QueryId secondNonDashboardQuery = createAdHocQuery(queryRunner);
// wait for the second non "dashboard" query to start
waitForQueryState(queryRunner, secondNonDashboardQuery, RUNNING);
// cancel first "dashboard" query, second "dashboard" query and second non "dashboard" query should start running
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
}
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueues method assertResourceGroup.
private void assertResourceGroup(DistributedQueryRunner queryRunner, Session session, String query, ResourceGroupId expectedResourceGroup) throws InterruptedException {
QueryId queryId = createQuery(queryRunner, session, query);
waitForQueryState(queryRunner, queryId, ImmutableSet.of(RUNNING, FINISHED));
Optional<ResourceGroupId> resourceGroupId = queryRunner.getCoordinator().getQueryManager().getFullQueryInfo(queryId).getResourceGroupId();
assertTrue(resourceGroupId.isPresent(), "Query should have a resource group");
assertEquals(resourceGroupId.get(), expectedResourceGroup, format("Expected: '%s' resource group, found: %s", expectedResourceGroup, resourceGroupId.get()));
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueues method testRejection.
private void testRejection() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner()) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_config_dashboard.json")));
QueryId queryId = createQuery(queryRunner, newRejectionSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, queryId, FAILED);
DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
assertEquals(dispatchManager.getQueryInfo(queryId).getErrorCode(), QUERY_REJECTED.toErrorCode());
}
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestFinalQueryInfo method testFinalQueryInfoSetOnAbort.
@Test(timeOut = 240_000)
public void testFinalQueryInfoSetOnAbort() throws Exception {
try (DistributedQueryRunner queryRunner = createQueryRunner(TEST_SESSION)) {
QueryId queryId = startQuery("SELECT COUNT(*) FROM tpch.sf1000.lineitem", queryRunner);
SettableFuture<QueryInfo> finalQueryInfoFuture = SettableFuture.create();
queryRunner.getCoordinator().addFinalQueryInfoListener(queryId, finalQueryInfoFuture::set);
// wait 1s then kill query
Thread.sleep(1_000);
queryRunner.getCoordinator().getQueryManager().cancelQuery(queryId);
// wait for final query info
QueryInfo finalQueryInfo = tryGetFutureValue(finalQueryInfoFuture, 10, SECONDS).orElseThrow(() -> new AssertionError("Final query info never set"));
assertTrue(finalQueryInfo.isFinalQueryInfo());
}
}
Aggregations