Search in sources :

Example 11 with ResourceGroupManagerPlugin

use of io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin 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"));
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Test(org.testng.annotations.Test)

Example 12 with ResourceGroupManagerPlugin

use of io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin 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);
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) QueryId(io.trino.spi.QueryId) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Test(org.testng.annotations.Test)

Example 13 with ResourceGroupManagerPlugin

use of io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin 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"));
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) ResourceEstimates(io.trino.spi.session.ResourceEstimates) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Test(org.testng.annotations.Test)

Example 14 with ResourceGroupManagerPlugin

use of io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin 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);
    }
}
Also used : DistributedQueryRunner(io.trino.testing.DistributedQueryRunner) QueryId(io.trino.spi.QueryId) ResourceGroupManagerPlugin(io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin) Test(org.testng.annotations.Test)

Aggregations

ResourceGroupManagerPlugin (io.trino.plugin.resourcegroups.ResourceGroupManagerPlugin)14 DistributedQueryRunner (io.trino.testing.DistributedQueryRunner)14 Test (org.testng.annotations.Test)13 QueryId (io.trino.spi.QueryId)7 ImmutableList (com.google.common.collect.ImmutableList)3 ImmutableMap (com.google.common.collect.ImmutableMap)3 Session (io.trino.Session)3 MockConnectorFactory (io.trino.connector.MockConnectorFactory)3 TpchPlugin (io.trino.plugin.tpch.TpchPlugin)3 Plugin (io.trino.spi.Plugin)3 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)3 SchemaTableName (io.trino.spi.connector.SchemaTableName)3 AbstractTestQueryFramework (io.trino.testing.AbstractTestQueryFramework)3 TestingSession.testSessionBuilder (io.trino.testing.TestingSession.testSessionBuilder)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Iterables.getOnlyElement (com.google.common.collect.Iterables.getOnlyElement)2 MockConnectorTableHandle (io.trino.connector.MockConnectorTableHandle)2 TestingEventListenerPlugin (io.trino.execution.TestEventListenerPlugin.TestingEventListenerPlugin)2 TestQueues.createResourceGroupId (io.trino.execution.TestQueues.createResourceGroupId)2 ColumnMetadata (io.trino.spi.connector.ColumnMetadata)2