Search in sources :

Example 11 with RunMessage

use of org.neo4j.bolt.v4.messaging.RunMessage in project neo4j by neo4j.

the class BoltRequestMessageReaderV41Test method shouldDecodeBoltV3RunAndBeginMessageAsBoltV41Message.

@Test
void shouldDecodeBoltV3RunAndBeginMessageAsBoltV41Message() throws Exception {
    org.neo4j.bolt.v3.messaging.request.RunMessage runMessageV3 = new org.neo4j.bolt.v3.messaging.request.RunMessage("RETURN 1", EMPTY_MAP);
    org.neo4j.bolt.v3.messaging.request.BeginMessage beginMessageV3 = new org.neo4j.bolt.v3.messaging.request.BeginMessage();
    RunMessage runMessageV4 = new RunMessage("RETURN 1", EMPTY_MAP);
    BeginMessage beginMessageV4 = new BeginMessage();
    verifyBoltV3MessageIsReadAsBoltV4Message(runMessageV3, runMessageV4);
    verifyBoltV3MessageIsReadAsBoltV4Message(beginMessageV3, beginMessageV4);
}
Also used : BeginMessage(org.neo4j.bolt.v4.messaging.BeginMessage) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 12 with RunMessage

use of org.neo4j.bolt.v4.messaging.RunMessage in project neo4j by neo4j.

the class MultipleBoltServerPortsStressTest method workload.

private static Runnable workload(AtomicBoolean failureFlag, SocketConnection connection, long finishTimeMillis) {
    return () -> {
        while (!failureFlag.get() && System.currentTimeMillis() < finishTimeMillis) {
            try {
                connection.send(util.chunk(new RunMessage("RETURN 1"), new PullMessage(asMapValue(map("n", -1L)))));
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
                assertThat(connection).satisfies(util.eventuallyReceives(msgRecord(eqRecord(longValueCondition(1L)))));
                assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess()));
            } catch (AssertionError e) {
                e.printStackTrace();
                failureFlag.set(true);
            }
        }
    };
}
Also used : PullMessage(org.neo4j.bolt.v4.messaging.PullMessage) IOException(java.io.IOException) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage)

Example 13 with RunMessage

use of org.neo4j.bolt.v4.messaging.RunMessage in project neo4j by neo4j.

the class TransportErrorIT method shouldHandleIncorrectFraming.

@ParameterizedTest(name = "{displayName} {2}")
@MethodSource("argumentsProvider")
public void shouldHandleIncorrectFraming(Class<? extends TransportConnection> connectionClass, Neo4jPack neo4jPack, String name) throws Exception {
    initParameters(connectionClass, neo4jPack, name);
    // Given I have a message that gets truncated in the chunking, so part of it is missing
    byte[] truncated = serialize(util.getNeo4jPack(), new RunMessage("UNWIND [1,2,3] AS a RETURN a, a * a AS a_squared"));
    truncated = Arrays.copyOf(truncated, truncated.length - 12);
    // When
    connection.connect(address).send(util.defaultAcceptedVersions()).send(util.chunk(32, truncated));
    // Then
    assertThat(connection).satisfies(util.eventuallyReceivesSelectedProtocolVersion());
    assertThat(connection).satisfies(eventuallyDisconnects());
}
Also used : RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with RunMessage

use of org.neo4j.bolt.v4.messaging.RunMessage in project neo4j by neo4j.

the class BoltRequestMessageReaderV43Test method shouldDecodeBoltV3RunAndBeginMessageAsBoltv43Message.

@Test
void shouldDecodeBoltV3RunAndBeginMessageAsBoltv43Message() throws Exception {
    org.neo4j.bolt.v3.messaging.request.RunMessage runMessageV3 = new org.neo4j.bolt.v3.messaging.request.RunMessage("RETURN 1", EMPTY_MAP);
    org.neo4j.bolt.v3.messaging.request.BeginMessage beginMessageV3 = new org.neo4j.bolt.v3.messaging.request.BeginMessage();
    RunMessage runMessageV4 = new RunMessage("RETURN 1", EMPTY_MAP);
    BeginMessage beginMessageV4 = new BeginMessage();
    verifyBoltV3MessageIsReadAsBoltV4Message(runMessageV3, runMessageV4);
    verifyBoltV3MessageIsReadAsBoltV4Message(beginMessageV3, beginMessageV4);
}
Also used : BeginMessage(org.neo4j.bolt.v4.messaging.BeginMessage) RunMessage(org.neo4j.bolt.v4.messaging.RunMessage) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 15 with RunMessage

use of org.neo4j.bolt.v4.messaging.RunMessage 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)

Aggregations

RunMessage (org.neo4j.bolt.v4.messaging.RunMessage)22 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)15 MethodSource (org.junit.jupiter.params.provider.MethodSource)9 BoltStateMachineV4 (org.neo4j.bolt.v4.BoltStateMachineV4)9 PullMessage (org.neo4j.bolt.v4.messaging.PullMessage)9 BeginMessage (org.neo4j.bolt.v4.messaging.BeginMessage)8 BookmarkWithDatabaseId (org.neo4j.bolt.v4.runtime.bookmarking.BookmarkWithDatabaseId)8 BoltResponseRecorder (org.neo4j.bolt.testing.BoltResponseRecorder)7 Test (org.junit.jupiter.api.Test)6 RecordedBoltResponse (org.neo4j.bolt.testing.RecordedBoltResponse)2 ByteBuf (io.netty.buffer.ByteBuf)1 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 IOException (java.io.IOException)1 BoltChannel (org.neo4j.bolt.BoltChannel)1 BoltProtocol (org.neo4j.bolt.BoltProtocol)1 RequestMessage (org.neo4j.bolt.messaging.RequestMessage)1 BoltResponseHandler (org.neo4j.bolt.runtime.BoltResponseHandler)1 SynchronousBoltConnection (org.neo4j.bolt.runtime.SynchronousBoltConnection)1 BoltStateMachine (org.neo4j.bolt.runtime.statemachine.BoltStateMachine)1 BoltTestUtil.newTestBoltChannel (org.neo4j.bolt.testing.BoltTestUtil.newTestBoltChannel)1