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