use of org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix in project neo4j by neo4j.
the class TransactionStateMachineV3SPITest method shouldNotCheckDatabaseIdInBookmark.
@Test
void shouldNotCheckDatabaseIdInBookmark() {
// Given
var dbSpi = mock(BoltGraphDatabaseServiceSPI.class);
var spi = new TestAbstractTransactionStateMachineSPI(dbSpi, mock(BoltChannel.class), mock(SystemNanoClock.class), mock(StatementProcessorReleaseManager.class));
var bookmarks = List.<Bookmark>of(new BookmarkWithPrefix(42L));
// When
spi.beginTransaction(null, bookmarks, null, null, null, null);
// Then
verify(dbSpi).beginTransaction(any(), any(), any(), eq(bookmarks), any(), any(), any(), any());
}
use of org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix in project neo4j by neo4j.
the class BoltV3TransportIT method shouldReturnUpdatedBookmarkAfterAutoCommitTransaction.
@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterAutoCommitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
init(connectionClass);
negotiateBoltV3();
// bookmark is expected to advance once the auto-commit transaction is committed
long lastClosedTransactionId = getLastClosedTransactionId();
String expectedBookmark = new BookmarkWithPrefix(lastClosedTransactionId + 1).toString();
connection.send(util.chunk(new RunMessage("CREATE ()"), PullAllMessage.INSTANCE));
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
use of org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix in project neo4j by neo4j.
the class TransactionStateMachineV3SPITest method shouldFailWhenGivenMultipleBookmarks.
@Test
void shouldFailWhenGivenMultipleBookmarks() {
var dbSpi = mock(BoltGraphDatabaseServiceSPI.class);
var spi = new TestAbstractTransactionStateMachineSPI(dbSpi, mock(BoltChannel.class), mock(SystemNanoClock.class), mock(StatementProcessorReleaseManager.class));
var bookmarks = List.<Bookmark>of(new BookmarkWithPrefix(42L), new BookmarkWithPrefix(4242L));
assertThrows(IllegalArgumentException.class, () -> spi.beginTransaction(null, bookmarks, null, null, null, null));
}
use of org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix 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);
}
use of org.neo4j.bolt.v3.runtime.bookmarking.BookmarkWithPrefix in project neo4j by neo4j.
the class DatabaseServiceBookmarkTest method doesNotWaitWhenTxIdUpToDate.
@Test
void doesNotWaitWhenTxIdUpToDate() throws Exception {
long lastClosedTransactionId = 100;
TransactionIdStore txIdStore = fixedTxIdStore(lastClosedTransactionId);
var dbSpi = createDbSpi(txIdStore, Duration.ofSeconds(1), Clocks.fakeClock());
var resultFuture = executor.submit(() -> {
begin(dbSpi, List.of(new BookmarkWithPrefix(lastClosedTransactionId - 42)));
return null;
});
assertNull(resultFuture.get(20, SECONDS));
}
Aggregations