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");
}
Aggregations