use of io.trino.spi.QueryId in project trino by trinodb.
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);
}
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueuesDb method testBasic.
@Test(timeOut = 60_000)
public void testBasic() throws Exception {
// submit first "dashboard" query
QueryId firstDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
// wait for the first "dashboard" query to start
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
waitForRunningQueryCount(queryRunner, 1);
// submit second "dashboard" query
QueryId secondDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
MILLISECONDS.sleep(2000);
// 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);
waitForRunningQueryCount(queryRunner, 1);
// Update db to allow for 1 more running query in dashboard resource group
dao.updateResourceGroup(3, "user-${USER}", "1MB", 3, 4, 4, null, null, null, null, null, 1L, TEST_ENVIRONMENT);
dao.updateResourceGroup(5, "dashboard-${USER}", "1MB", 1, 2, 2, null, null, null, null, null, 3L, TEST_ENVIRONMENT);
waitForQueryState(queryRunner, secondDashboardQuery, RUNNING);
QueryId thirdDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, thirdDashboardQuery, QUEUED);
waitForRunningQueryCount(queryRunner, 2);
// submit first non "dashboard" query
QueryId firstNonDashboardQuery = createQuery(queryRunner, adhocSession(), LONG_LASTING_QUERY);
// wait for the first non "dashboard" query to start
waitForQueryState(queryRunner, firstNonDashboardQuery, RUNNING);
waitForRunningQueryCount(queryRunner, 3);
// submit second non "dashboard" query
QueryId secondNonDashboardQuery = createQuery(queryRunner, adhocSession(), LONG_LASTING_QUERY);
// wait for the second non "dashboard" query to start
waitForQueryState(queryRunner, secondNonDashboardQuery, RUNNING);
waitForRunningQueryCount(queryRunner, 4);
// cancel first "dashboard" query, the second "dashboard" query and second non "dashboard" query should start running
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
waitForQueryState(queryRunner, thirdDashboardQuery, RUNNING);
waitForRunningQueryCount(queryRunner, 4);
waitForCompleteQueryCount(queryRunner, 1);
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueuesDb method testQuerySystemTableResourceGroup.
@Test(timeOut = 60_000)
public void testQuerySystemTableResourceGroup() throws Exception {
QueryId firstQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstQuery, RUNNING);
MaterializedResult result = queryRunner.execute("SELECT resource_group_id FROM system.runtime.queries WHERE source = 'dashboard'");
assertEquals(result.getOnlyValue(), ImmutableList.of("global", "user-user", "dashboard-user"));
}
use of io.trino.spi.QueryId in project trino by trinodb.
the class TestQueuesDb method assertResourceGroupWithClientTags.
private void assertResourceGroupWithClientTags(Set<String> clientTags, ResourceGroupId expectedResourceGroup) throws InterruptedException {
Session session = testSessionBuilder().setCatalog("tpch").setSchema("sf100000").setSource("client_tags").setClientTags(clientTags).build();
QueryId queryId = createQuery(queryRunner, session, LONG_LASTING_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 TestQueuesDb method testTwoQueriesAtSameTime.
@Test(timeOut = 60_000)
public void testTwoQueriesAtSameTime() throws Exception {
QueryId firstDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
QueryId secondDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_LASTING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
}
Aggregations