use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestFileBasedSystemAccessControl method testViewOperations.
@Test
public void testViewOperations() {
TransactionManager transactionManager = createTestTransactionManager();
AccessControlManager accessControlManager = newAccessControlManager(transactionManager, "catalog.json");
transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanCreateView(transactionId, alice, aliceView);
accessControlManager.checkCanDropView(transactionId, alice, aliceView);
accessControlManager.checkCanSelectFromColumns(transactionId, alice, aliceView, ImmutableSet.of());
accessControlManager.checkCanCreateViewWithSelectFromColumns(transactionId, alice, aliceTable, ImmutableSet.of());
accessControlManager.checkCanCreateViewWithSelectFromColumns(transactionId, alice, aliceView, ImmutableSet.of());
accessControlManager.checkCanSetCatalogSessionProperty(transactionId, alice, "alice-catalog", "property");
accessControlManager.checkCanGrantTablePrivilege(transactionId, alice, SELECT, aliceTable, new PrestoPrincipal(USER, "grantee"), true);
accessControlManager.checkCanRevokeTablePrivilege(transactionId, alice, SELECT, aliceTable, new PrestoPrincipal(USER, "revokee"), true);
});
assertThrows(AccessDeniedException.class, () -> transaction(transactionManager, accessControlManager).execute(transactionId -> {
accessControlManager.checkCanCreateView(transactionId, bob, aliceView);
}));
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
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, transactionManager);
assertTrue(stateMachine.getSession().getTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
getFutureValue(new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestCommitTask method testNoTransactionCommit.
@Test
public void testNoTransactionCommit() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().build();
QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager);
assertPrestoExceptionThrownBy(() -> getFutureValue(new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_IN_TRANSACTION);
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
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, transactionManager);
Future<?> future = new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
assertPrestoExceptionThrownBy(() -> getFutureValue(future)).hasErrorCode(UNKNOWN_TRANSACTION);
// Still issue clear signal
assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of io.prestosql.transaction.TransactionManager in project hetu-core by openlookeng.
the class TestRollbackTask method testNoTransactionRollback.
@Test
public void testNoTransactionRollback() {
TransactionManager transactionManager = createTestTransactionManager();
Session session = sessionBuilder().build();
QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager);
assertPrestoExceptionThrownBy(() -> getFutureValue((Future<?>) new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_IN_TRANSACTION);
assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Aggregations