use of io.trino.testing.DistributedQueryRunner in project trino by trinodb.
the class TestQueues method testQueryTypeBasedSelection.
@Test(timeOut = 240_000)
public void testQueryTypeBasedSelection() throws Exception {
try (DistributedQueryRunner queryRunner = TpchQueryRunnerBuilder.builder().build()) {
queryRunner.installPlugin(new ResourceGroupManagerPlugin());
queryRunner.getCoordinator().getResourceGroupManager().get().setConfigurationManager("file", ImmutableMap.of("resource-groups.config-file", getResourceFilePath("resource_groups_query_type_based_config.json")));
assertResourceGroup(queryRunner, newAdhocSession(), LONG_LASTING_QUERY, createResourceGroupId("global", "select"));
assertResourceGroup(queryRunner, newAdhocSession(), "SHOW TABLES", createResourceGroupId("global", "describe"));
assertResourceGroup(queryRunner, newAdhocSession(), "EXPLAIN " + LONG_LASTING_QUERY, createResourceGroupId("global", "explain"));
assertResourceGroup(queryRunner, newAdhocSession(), "DESCRIBE lineitem", createResourceGroupId("global", "describe"));
assertResourceGroup(queryRunner, newAdhocSession(), "RESET SESSION " + HASH_PARTITION_COUNT, createResourceGroupId("global", "data_definition"));
}
}
use of io.trino.testing.DistributedQueryRunner in project trino by trinodb.
the class TestQueues method testExceedSoftLimits.
@Test(timeOut = 240_000)
public void testExceedSoftLimits() 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_soft_limits.json")));
QueryId scheduled1 = createScheduledQuery(queryRunner);
waitForQueryState(queryRunner, scheduled1, RUNNING);
QueryId scheduled2 = createScheduledQuery(queryRunner);
waitForQueryState(queryRunner, scheduled2, RUNNING);
QueryId scheduled3 = createScheduledQuery(queryRunner);
waitForQueryState(queryRunner, scheduled3, RUNNING);
// cluster is now 'at capacity' - scheduled is running 3 (i.e. over soft limit)
QueryId backfill1 = createBackfill(queryRunner);
QueryId scheduled4 = createScheduledQuery(queryRunner);
cancelQuery(queryRunner, scheduled1);
// backfill should be chosen to run next
waitForQueryState(queryRunner, backfill1, RUNNING);
cancelQuery(queryRunner, scheduled2);
cancelQuery(queryRunner, scheduled3);
cancelQuery(queryRunner, scheduled4);
QueryId backfill2 = createBackfill(queryRunner);
waitForQueryState(queryRunner, backfill2, RUNNING);
QueryId backfill3 = createBackfill(queryRunner);
waitForQueryState(queryRunner, backfill3, RUNNING);
// cluster is now 'at capacity' - backfills is running 3 (i.e. over soft limit)
QueryId backfill4 = createBackfill(queryRunner);
QueryId scheduled5 = createScheduledQuery(queryRunner);
cancelQuery(queryRunner, backfill1);
// scheduled should be chosen to run next
waitForQueryState(queryRunner, scheduled5, RUNNING);
cancelQuery(queryRunner, backfill2);
cancelQuery(queryRunner, backfill3);
cancelQuery(queryRunner, backfill4);
cancelQuery(queryRunner, scheduled5);
waitForQueryState(queryRunner, scheduled5, FAILED);
}
}
use of io.trino.testing.DistributedQueryRunner in project trino by trinodb.
the class TestQueues method testSelectorResourceEstimateBasedSelection.
@Test(timeOut = 240_000)
public void testSelectorResourceEstimateBasedSelection() 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_resource_estimate_based_config.json")));
assertResourceGroup(queryRunner, newSessionWithResourceEstimates(new ResourceEstimates(Optional.of(java.time.Duration.ofMinutes(4)), Optional.empty(), Optional.of(DataSize.of(400, MEGABYTE).toBytes()))), LONG_LASTING_QUERY, createResourceGroupId("global", "small"));
assertResourceGroup(queryRunner, newSessionWithResourceEstimates(new ResourceEstimates(Optional.of(java.time.Duration.ofMinutes(4)), Optional.empty(), Optional.of(DataSize.of(600, MEGABYTE).toBytes()))), LONG_LASTING_QUERY, createResourceGroupId("global", "other"));
assertResourceGroup(queryRunner, newSessionWithResourceEstimates(new ResourceEstimates(Optional.of(java.time.Duration.ofMinutes(4)), Optional.empty(), Optional.empty())), LONG_LASTING_QUERY, createResourceGroupId("global", "other"));
assertResourceGroup(queryRunner, newSessionWithResourceEstimates(new ResourceEstimates(Optional.of(java.time.Duration.ofSeconds(1)), Optional.of(java.time.Duration.ofSeconds(1)), Optional.of(DataSize.of(6, TERABYTE).toBytes()))), LONG_LASTING_QUERY, createResourceGroupId("global", "huge_memory"));
assertResourceGroup(queryRunner, newSessionWithResourceEstimates(new ResourceEstimates(Optional.of(java.time.Duration.ofHours(100)), Optional.empty(), Optional.of(DataSize.of(4, TERABYTE).toBytes()))), LONG_LASTING_QUERY, createResourceGroupId("global", "other"));
}
}
use of io.trino.testing.DistributedQueryRunner in project trino by trinodb.
the class TestQueues method testResourceGroupManagerWithTooManyQueriesScheduled.
@Test(timeOut = 240_000)
public void testResourceGroupManagerWithTooManyQueriesScheduled() 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);
waitForQueryState(queryRunner, firstDashboardQuery, RUNNING);
QueryId secondDashboardQuery = createDashboardQuery(queryRunner);
waitForQueryState(queryRunner, secondDashboardQuery, QUEUED);
QueryId thirdDashboardQuery = createDashboardQuery(queryRunner);
waitForQueryState(queryRunner, thirdDashboardQuery, FAILED);
}
}
use of io.trino.testing.DistributedQueryRunner in project trino by trinodb.
the class KafkaQueryRunner method main.
public static void main(String[] args) throws Exception {
Logging.initialize();
DistributedQueryRunner queryRunner = builder(TestingKafka.create()).setTables(TpchTable.getTables()).build();
Logger log = Logger.get(KafkaQueryRunner.class);
log.info("======== SERVER STARTED ========");
log.info("\n====\n%s\n====", queryRunner.getCoordinator().getBaseUrl());
}
Aggregations