Search in sources :

Example 1 with RUNNING

use of io.trino.execution.QueryState.RUNNING in project trino by trinodb.

the class AbstractDistributedEngineOnlyQueries method testQueryTransitionsToRunningState.

@Test(timeOut = 10_000)
public void testQueryTransitionsToRunningState() {
    String query = format(// use random marker in query for unique matching below
    "SELECT count(*) c_%s FROM lineitem CROSS JOIN lineitem CROSS JOIN lineitem", randomTableSuffix());
    DistributedQueryRunner queryRunner = getDistributedQueryRunner();
    ListenableFuture<?> queryFuture = Futures.submit(() -> queryRunner.execute(getSession(), query), executorService);
    QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
    assertEventually(() -> {
        List<BasicQueryInfo> queryInfos = queryManager.getQueries().stream().filter(q -> q.getQuery().equals(query)).collect(toImmutableList());
        assertThat(queryInfos).hasSize(1);
        assertThat(queryInfos.get(0).getState()).isEqualTo(RUNNING);
        // we are good. Let's kill the query
        queryManager.cancelQuery(queryInfos.get(0).getQueryId());
    });
    assertThatThrownBy(queryFuture::get).hasMessageContaining("Query was canceled");
}
Also used : AfterClass(org.testng.annotations.AfterClass) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) Language(org.intellij.lang.annotations.Language) QueryManager(io.trino.execution.QueryManager) BasicQueryInfo(io.trino.server.BasicQueryInfo) BeforeClass(org.testng.annotations.BeforeClass) ZonedDateTime(java.time.ZonedDateTime) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) RUNNING(io.trino.execution.QueryState.RUNNING) Test(org.testng.annotations.Test) String.format(java.lang.String.format) BROADCAST(io.trino.sql.planner.OptimizerConfig.JoinDistributionType.BROADCAST) ENABLE_DYNAMIC_FILTERING(io.trino.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING) Futures(com.google.common.util.concurrent.Futures) List(java.util.List) Assert.assertEventually(io.trino.testing.assertions.Assert.assertEventually) Assertions.assertThatThrownBy(org.assertj.core.api.Assertions.assertThatThrownBy) Executors.newCachedThreadPool(java.util.concurrent.Executors.newCachedThreadPool) Pattern(java.util.regex.Pattern) ExecutorService(java.util.concurrent.ExecutorService) TestTable.randomTableSuffix(io.trino.testing.sql.TestTable.randomTableSuffix) Session(io.trino.Session) BasicQueryInfo(io.trino.server.BasicQueryInfo) QueryManager(io.trino.execution.QueryManager) Test(org.testng.annotations.Test)

Aggregations

ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 Futures (com.google.common.util.concurrent.Futures)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 Session (io.trino.Session)1 ENABLE_DYNAMIC_FILTERING (io.trino.SystemSessionProperties.ENABLE_DYNAMIC_FILTERING)1 QueryManager (io.trino.execution.QueryManager)1 RUNNING (io.trino.execution.QueryState.RUNNING)1 BasicQueryInfo (io.trino.server.BasicQueryInfo)1 BROADCAST (io.trino.sql.planner.OptimizerConfig.JoinDistributionType.BROADCAST)1 Assert.assertEventually (io.trino.testing.assertions.Assert.assertEventually)1 TestTable.randomTableSuffix (io.trino.testing.sql.TestTable.randomTableSuffix)1 String.format (java.lang.String.format)1 ZonedDateTime (java.time.ZonedDateTime)1 List (java.util.List)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors.newCachedThreadPool (java.util.concurrent.Executors.newCachedThreadPool)1 Pattern (java.util.regex.Pattern)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 Assertions.assertThatThrownBy (org.assertj.core.api.Assertions.assertThatThrownBy)1 Language (org.intellij.lang.annotations.Language)1