Search in sources :

Example 1 with Status

use of org.rocksdb.Status in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldThrowRecoverableExceptionInTransactionCommit.

@Test(expected = ZeebeDbException.class)
public void shouldThrowRecoverableExceptionInTransactionCommit() throws Exception {
    // given
    final Status status = new Status(Code.IOError, SubCode.None, "");
    final ZeebeTransaction currentTransaction = spy((ZeebeTransaction) transactionContext.getCurrentTransaction());
    doThrow(new RocksDBException("expected", status)).when(currentTransaction).commitInternal();
    // when
    currentTransaction.commit();
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) Test(org.junit.Test)

Example 2 with Status

use of org.rocksdb.Status in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldReThrowExceptionFromTransactionRun.

@Test(expected = RocksDBException.class)
public void shouldReThrowExceptionFromTransactionRun() throws Exception {
    // given
    final Status status = new Status(Code.NotSupported, SubCode.None, "");
    // when
    final ZeebeDbTransaction currentTransaction = transactionContext.getCurrentTransaction();
    currentTransaction.run(() -> {
        throw new RocksDBException("expected", status);
    });
}
Also used : Status(org.rocksdb.Status) ZeebeDbTransaction(io.camunda.zeebe.db.ZeebeDbTransaction) RocksDBException(org.rocksdb.RocksDBException) Test(org.junit.Test)

Example 3 with Status

use of org.rocksdb.Status in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldThrowRecoverableExceptionOnCommit.

@Test(expected = ZeebeDbException.class)
public void shouldThrowRecoverableExceptionOnCommit() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.IOError, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).commitInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 4 with Status

use of org.rocksdb.Status in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldWrapExceptionInRuntimeExceptionOnCommit.

@Test(expected = RuntimeException.class)
public void shouldWrapExceptionInRuntimeExceptionOnCommit() throws Exception {
    // given
    final ZeebeTransaction transaction = mock(ZeebeTransaction.class);
    final TransactionContext newContext = new DefaultTransactionContext(transaction);
    final Status status = new Status(Code.NotSupported, SubCode.None, "");
    doThrow(new RocksDBException("expected", status)).when(transaction).commitInternal();
    // when
    newContext.runInTransaction(() -> {
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) TransactionContext(io.camunda.zeebe.db.TransactionContext) Test(org.junit.Test)

Example 5 with Status

use of org.rocksdb.Status in project zeebe by camunda.

the class ZeebeRocksDbTransactionTest method shouldWrapExceptionInRuntimeException.

@Test(expected = RuntimeException.class)
public void shouldWrapExceptionInRuntimeException() {
    // given
    final Status status = new Status(Code.NotSupported, SubCode.None, "");
    // when
    transactionContext.runInTransaction(() -> {
        throw new RocksDBException("expected", status);
    });
}
Also used : Status(org.rocksdb.Status) RocksDBException(org.rocksdb.RocksDBException) Test(org.junit.Test)

Aggregations

RocksDBException (org.rocksdb.RocksDBException)44 Status (org.rocksdb.Status)44 Test (org.junit.Test)42 TransactionContext (io.camunda.zeebe.db.TransactionContext)12 ZeebeDbTransaction (io.camunda.zeebe.db.ZeebeDbTransaction)9 RecoverableException (io.camunda.zeebe.util.exception.RecoverableException)6 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 DatabaseStorageException (tech.pegasys.teku.storage.server.DatabaseStorageException)2 Test (org.junit.jupiter.api.Test)1 MethodSource (org.junit.jupiter.params.provider.MethodSource)1