Search in sources :

Example 1 with TestingSessionContext

use of io.prestosql.execution.TestingSessionContext in project hetu-core by openlookeng.

the class TestQueryManager method testFailQuery.

@Test(timeOut = 60_000L)
public void testFailQuery() throws Exception {
    DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
    QueryId queryId = dispatchManager.createQueryId();
    dispatchManager.createQuery(queryId, "slug", new TestingSessionContext(TEST_SESSION), "SELECT * FROM lineitem").get();
    // wait until query starts running
    while (true) {
        QueryState state = dispatchManager.getQueryInfo(queryId).getState();
        if (state.isDone()) {
            fail("unexpected query state: " + state);
        }
        if (state == RUNNING) {
            break;
        }
        Thread.sleep(100);
    }
    // cancel query
    QueryManager queryManager = queryRunner.getCoordinator().getQueryManager();
    queryManager.failQuery(queryId, new PrestoException(GENERIC_INTERNAL_ERROR, "mock exception"));
    QueryInfo queryInfo = queryManager.getFullQueryInfo(queryId);
    assertEquals(queryInfo.getState(), FAILED);
    assertEquals(queryInfo.getErrorCode(), GENERIC_INTERNAL_ERROR.toErrorCode());
    assertNotNull(queryInfo.getFailureInfo());
    assertEquals(queryInfo.getFailureInfo().getMessage(), "mock exception");
}
Also used : DispatchManager(io.prestosql.dispatcher.DispatchManager) TestingSessionContext(io.prestosql.execution.TestingSessionContext) QueryId(io.prestosql.spi.QueryId) QueryManager(io.prestosql.execution.QueryManager) PrestoException(io.prestosql.spi.PrestoException) TestQueryRunnerUtil.waitForQueryState(io.prestosql.execution.TestQueryRunnerUtil.waitForQueryState) QueryState(io.prestosql.execution.QueryState) QueryInfo(io.prestosql.execution.QueryInfo) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Test(org.testng.annotations.Test)

Example 2 with TestingSessionContext

use of io.prestosql.execution.TestingSessionContext in project hetu-core by openlookeng.

the class TestMetadataManager method testMetadataIsClearedAfterQueryCanceled.

@Test
public void testMetadataIsClearedAfterQueryCanceled() throws Exception {
    DispatchManager dispatchManager = queryRunner.getCoordinator().getDispatchManager();
    QueryId queryId = dispatchManager.createQueryId();
    dispatchManager.createQuery(queryId, "slug", new TestingSessionContext(TEST_SESSION), "SELECT * FROM lineitem").get();
    // wait until query starts running
    while (true) {
        BasicQueryInfo queryInfo = dispatchManager.getQueryInfo(queryId);
        if (queryInfo.getState().isDone()) {
            assertEquals(queryInfo.getState(), FAILED);
            throw dispatchManager.getDispatchInfo(queryId).get().getFailureInfo().get().toException();
        }
        if (queryInfo.getState() == RUNNING) {
            break;
        }
        Thread.sleep(100);
    }
    // cancel query
    dispatchManager.cancelQuery(queryId);
    assertEquals(metadataManager.getActiveQueryIds().size(), 0);
}
Also used : DispatchManager(io.prestosql.dispatcher.DispatchManager) TestingSessionContext(io.prestosql.execution.TestingSessionContext) QueryId(io.prestosql.spi.QueryId) BasicQueryInfo(io.prestosql.server.BasicQueryInfo) Test(org.testng.annotations.Test)

Aggregations

DispatchManager (io.prestosql.dispatcher.DispatchManager)2 TestingSessionContext (io.prestosql.execution.TestingSessionContext)2 BasicQueryInfo (io.prestosql.server.BasicQueryInfo)2 QueryId (io.prestosql.spi.QueryId)2 Test (org.testng.annotations.Test)2 QueryInfo (io.prestosql.execution.QueryInfo)1 QueryManager (io.prestosql.execution.QueryManager)1 QueryState (io.prestosql.execution.QueryState)1 TestQueryRunnerUtil.waitForQueryState (io.prestosql.execution.TestQueryRunnerUtil.waitForQueryState)1 PrestoException (io.prestosql.spi.PrestoException)1