Search in sources :

Example 6 with BookmarkWithDatabaseId

use of org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId in project neo4j by neo4j.

the class BoltV4TransportIT method shouldReturnUpdatedBookmarkAfterExplicitTransaction.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterExplicitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    negotiateBoltV4();
    // bookmark is expected to advance once the auto-commit transaction is committed
    var lastClosedTransactionId = getLastClosedTransactionId();
    var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
    connection.send(util.chunk(new BeginMessage()));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
    connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).doesNotContainEntry("bookmark", expectedBookmark))));
    connection.send(util.chunk(CommitMessage.COMMIT_MESSAGE));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
Also used : BeginMessage(org.neo4j.bolt.v4.messaging.BeginMessage) BookmarkWithDatabaseId(org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId) PullMessage(org.neo4j.bolt.v4.messaging.PullMessage) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 7 with BookmarkWithDatabaseId

use of org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId in project neo4j by neo4j.

the class TransactionStateMachineV4SPITest method shouldCheckDatabaseIdInBookmark.

@Test
void shouldCheckDatabaseIdInBookmark() {
    // Given
    var dbSpi = mock(BoltGraphDatabaseServiceSPI.class);
    var databaseId = databaseIdRepository.getRaw("molly");
    when(dbSpi.getNamedDatabaseId()).thenReturn(databaseId);
    var spi = new TransactionStateMachineV4SPI(dbSpi, mock(BoltChannel.class), mock(SystemNanoClock.class), mock(StatementProcessorReleaseManager.class));
    var bookmarks = List.<Bookmark>of(new BookmarkWithDatabaseId(42, databaseId));
    // When
    spi.beginTransaction(null, bookmarks, null, null, null, null);
    // Then
    verify(dbSpi).beginTransaction(any(), any(), any(), eq(bookmarks), any(), any(), any(), any());
}
Also used : StatementProcessorReleaseManager(org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager) SystemNanoClock(org.neo4j.time.SystemNanoClock) Bookmark(org.neo4j.bolt.runtime.Bookmark) BoltChannel(org.neo4j.bolt.BoltChannel) BookmarkWithDatabaseId(org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId) Test(org.junit.jupiter.api.Test)

Example 8 with BookmarkWithDatabaseId

use of org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId in project neo4j by neo4j.

the class BoltV43TransportIT method shouldReturnUpdatedBookmarkAfterExplicitTransaction.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterExplicitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    assumeFalse(FabricDatabaseManager.fabricByDefault(Config.defaults()));
    negotiateBoltV43();
    // bookmark is expected to advance once the auto-commit transaction is committed
    var lastClosedTransactionId = getLastClosedTransactionId();
    var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
    connection.send(util.chunk(new BeginMessage()));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
    connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(message -> assertThat(message).doesNotContainEntry("bookmark", expectedBookmark))));
    connection.send(util.chunk(CommitMessage.COMMIT_MESSAGE));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(message -> assertThat(message).containsEntry("bookmark", expectedBookmark))));
}
Also used : BeginMessage(org.neo4j.bolt.v4.messaging.BeginMessage) BookmarkWithDatabaseId(org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId) PullMessage(org.neo4j.bolt.v4.messaging.PullMessage) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 9 with BookmarkWithDatabaseId

use of org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId in project neo4j by neo4j.

the class BoltV4TransportIT method shouldReturnUpdatedBookmarkAfterAutoCommitTransaction.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldReturnUpdatedBookmarkAfterAutoCommitTransaction(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    negotiateBoltV4();
    // bookmark is expected to advance once the auto-commit transaction is committed
    var lastClosedTransactionId = getLastClosedTransactionId();
    var expectedBookmark = new BookmarkWithDatabaseId(lastClosedTransactionId + 1, getDatabaseId()).toString();
    connection.send(util.chunk(new RunMessage("CREATE ()"), new PullMessage(asMapValue(map("n", -1L)))));
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(responseMessage -> assertThat(responseMessage).containsEntry("bookmark", expectedBookmark))));
}
Also used : BookmarkWithDatabaseId(org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId) PullMessage(org.neo4j.bolt.v4.messaging.PullMessage) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

BookmarkWithDatabaseId (org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId)9 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)8 MethodSource (org.junit.jupiter.params.provider.MethodSource)8 PullMessage (org.neo4j.bolt.v4.messaging.PullMessage)8 RunMessage (org.neo4j.bolt.v4.messaging.RunMessage)8 BeginMessage (org.neo4j.bolt.v4.messaging.BeginMessage)4 Test (org.junit.jupiter.api.Test)1 BoltChannel (org.neo4j.bolt.BoltChannel)1 Bookmark (org.neo4j.bolt.runtime.Bookmark)1 StatementProcessorReleaseManager (org.neo4j.bolt.runtime.statemachine.StatementProcessorReleaseManager)1 SystemNanoClock (org.neo4j.time.SystemNanoClock)1