use of io.trino.server.PrefixObjectNameGeneratorModule in project trino by trinodb.
the class TestExecutionJmxMetrics method testQueryStats.
@Test(timeOut = 30_000)
public void testQueryStats() throws Exception {
try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().setAdditionalModule(new PrefixObjectNameGeneratorModule("io.trino")).build()) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
InternalResourceGroupManager<?> resourceGroupManager = queryRunner.getCoordinator().getResourceGroupManager().orElseThrow(() -> new IllegalStateException("Resource manager not configured"));
resourceGroupManager.setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getClass().getClassLoader().getResource("resource_groups_single_query.json").getPath()));
MBeanServer mbeanServer = queryRunner.getCoordinator().getMbeanServer();
QueryId firstDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_RUNNING_QUERY);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
assertEquals(getMbeanAttribute(mbeanServer, "RunningQueries"), 1);
assertEquals(getMbeanAttribute(mbeanServer, "QueuedQueries"), 0);
// the second "dashboard" query can't run right away because the resource group has a hardConcurrencyLimit of 1
QueryId secondDashboardQuery = createQuery(queryRunner, dashboardSession(), LONG_RUNNING_QUERY);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
assertEquals(getMbeanAttribute(mbeanServer, "RunningQueries"), 1);
assertEquals(getMbeanAttribute(mbeanServer, "QueuedQueries"), 1);
cancelQuery(queryRunner, secondDashboardQuery);
waitForQueryState(queryRunner, secondDashboardQuery, FAILED);
assertEquals(getMbeanAttribute(mbeanServer, "RunningQueries"), 1);
assertEquals(getMbeanAttribute(mbeanServer, "QueuedQueries"), 0);
// cancel the running query to avoid polluting the logs with meaningless stack traces
try {
cancelQuery(queryRunner, firstDashboardQuery);
waitForQueryState(queryRunner, firstDashboardQuery, FAILED);
} catch (Exception ignore) {
}
}
}
Aggregations