use of org.neo4j.kernel.availability.DatabaseAvailabilityGuard in project neo4j by neo4j.
the class KernelTransactionsTest method setUp.
@BeforeEach
void setUp() throws Exception {
databaseAvailabilityGuard = new DatabaseAvailabilityGuard(DEFAULT_DATABASE_ID, clock, NullLog.getInstance(), 0, mock(CompositeDatabaseAvailabilityGuard.class));
databaseAvailabilityGuard.init();
t2.init("T2-" + getClass().getName());
}
use of org.neo4j.kernel.availability.DatabaseAvailabilityGuard in project neo4j by neo4j.
the class DatabaseServiceBookmarkTest method throwsWhenTxAwaitDurationExpires.
@Test
void throwsWhenTxAwaitDurationExpires() {
long lastClosedTransactionId = 100;
TransactionIdStore txIdStore = fixedTxIdStore(lastClosedTransactionId);
var txAwaitDuration = Duration.ofSeconds(42);
var clock = new FakeClock();
var guard = new DatabaseAvailabilityGuard(DATABASE_ID, clock, NullLog.getInstance(), 0, mock(CompositeDatabaseAvailabilityGuard.class));
var databaseAvailabilityGuard = spy(guard);
when(databaseAvailabilityGuard.isAvailable()).then(invocation -> {
// move clock forward on avery availability check
// this check is executed on every tx id polling iteration
clock.forward(1, SECONDS);
return true;
});
var dbSpi = createDbSpi(txIdStore, txAwaitDuration, databaseAvailabilityGuard, clock);
var resultFuture = executor.submit(() -> {
begin(dbSpi, List.of(new BookmarkWithPrefix(lastClosedTransactionId + 42)));
return null;
});
var e = assertThrows(ExecutionException.class, () -> resultFuture.get(20, SECONDS));
assertThat(e.getCause()).isInstanceOf(TransactionIdTrackerException.class);
}
Aggregations