Search in sources :

Example 6 with SocketConnection

use of org.neo4j.bolt.testing.client.SocketConnection in project neo4j by neo4j.

the class MultipleBoltServerPortsStressTest method executeStressTest.

private static void executeStressTest(ExecutorService executorPool, HostnamePort external, HostnamePort internal) throws Exception {
    long finishTimeMillis = System.currentTimeMillis() + MINUTES.toMillis(MultipleBoltServerPortsStressTest.DURATION_IN_MINUTES);
    AtomicBoolean failureFlag = new AtomicBoolean(false);
    for (int i = 0; i < MultipleBoltServerPortsStressTest.NUMBER_OF_THREADS; i++) {
        SocketConnection connection = new SocketConnection();
        // split connections evenly between internal and external
        if (i % 2 == 0) {
            initializeConnection(connection, internal);
        } else {
            initializeConnection(connection, external);
        }
        executorPool.submit(workload(failureFlag, connection, finishTimeMillis));
    }
    executorPool.shutdown();
    executorPool.awaitTermination(DURATION_IN_MINUTES, MINUTES);
    assertThat(failureFlag).isFalse();
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) SocketConnection(org.neo4j.bolt.testing.client.SocketConnection)

Example 7 with SocketConnection

use of org.neo4j.bolt.testing.client.SocketConnection in project neo4j by neo4j.

the class BoltIT method assertEventuallyServerResponds.

private void assertEventuallyServerResponds(String host, int port) throws Exception {
    SocketConnection conn = new SocketConnection();
    conn.connect(new HostnamePort(host, port));
    conn.send(new byte[] { (byte) 0x60, (byte) 0x60, (byte) 0xB0, (byte) 0x17, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
    assertThat(conn.recv(4)).isEqualTo(new byte[] { 0, 0, 0, 4 });
}
Also used : SocketConnection(org.neo4j.bolt.testing.client.SocketConnection) HostnamePort(org.neo4j.internal.helpers.HostnamePort)

Aggregations

SocketConnection (org.neo4j.bolt.testing.client.SocketConnection)7 HostnamePort (org.neo4j.internal.helpers.HostnamePort)4 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2 TransportTestUtil (org.neo4j.bolt.testing.TransportTestUtil)2 URI (java.net.URI)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1