use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestCommitTask method testUnknownTransactionCommit.
@Test
public void testUnknownTransactionCommit() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().setTransactionId(// Use a random transaction ID that is unknown to the system
TransactionId.create()).build();
QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, true, transactionManager, executor, metadata);
try {
CommitTask commitTask = new CommitTask();
getFutureValue(commitTask.execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), UNKNOWN_TRANSACTION.toErrorCode());
}
// Still issue clear signal
assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestCommitTask method testNoTransactionCommit.
@Test
public void testNoTransactionCommit() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().build();
QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, true, transactionManager, executor, metadata);
try {
CommitTask commitTask = new CommitTask();
getFutureValue(commitTask.execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_IN_TRANSACTION.toErrorCode());
}
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestCommitTask method testCommit.
@Test
public void testCommit() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).build();
QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, true, transactionManager, executor, metadata);
assertTrue(stateMachine.getSession().getTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
CommitTask commitTask = new CommitTask();
getFutureValue(commitTask.execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestCreateTableTask method testCreateTableNotExistsFalse.
@Test
public void testCreateTableNotExistsFalse() {
CreateTable statement = new CreateTable(QualifiedName.of("test_table"), ImmutableList.of(new ColumnDefinition(identifier("a"), "BIGINT", true, emptyList(), Optional.empty())), false, ImmutableList.of(), Optional.empty());
try {
getFutureValue(new CreateTableTask().internalExecute(statement, metadata, new AllowAllAccessControl(), testSession, emptyList()));
fail("expected exception");
} catch (RuntimeException e) {
// Expected
assertTrue(e instanceof PrestoException);
PrestoException prestoException = (PrestoException) e;
assertEquals(prestoException.getErrorCode(), ALREADY_EXISTS.toErrorCode());
}
assertEquals(metadata.getCreateTableCallCount(), 1);
}
use of com.facebook.presto.security.AllowAllAccessControl in project urban-eureka by errir503.
the class TestDeallocateTask method executeDeallocate.
private Set<String> executeDeallocate(String statementName, String sqlString, Session session) {
TransactionManager transactionManager = createTestTransactionManager();
QueryStateMachine stateMachine = createQueryStateMachine(sqlString, session, false, transactionManager, executor, metadata);
Deallocate deallocate = new Deallocate(new Identifier(statementName));
DeallocateTask deallocateTask = new DeallocateTask();
deallocateTask.execute(deallocate, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList());
return stateMachine.getDeallocatedPreparedStatements();
}
Aggregations