use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class ConnectionTrackingIT method killConnectionViaBolt.
private void killConnectionViaBolt(TrackedNetworkConnection trackedConnection) throws Exception {
String id = trackedConnection.id();
String user = trackedConnection.username();
TransportConnection connection = connectSocketTo(neo4j.boltURI());
try {
connection.send(util.defaultAcceptedVersions()).send(auth("neo4j", NEO4J_USER_PWD)).send(util.defaultRunAutoCommitTx("CALL dbms.killConnection('" + id + "')"));
assertThat(connection).satisfies(util.eventuallyReceivesSelectedProtocolVersion());
assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(), msgRecord(eqRecord(new Condition<>(anyValue -> true, "any value"), new Condition<>(v -> v.equals(stringOrNoValue(user)), "user value"), new Condition<>(v -> v.equals(stringValue("Connection found")), "connection"))), msgSuccess()));
} finally {
connection.disconnect();
}
}
use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class ConnectionTrackingIT method testKillingOfConnections.
private void testKillingOfConnections(URI uri, TestConnector connector, int count) throws Exception {
List<TransportConnection> socketConnections = new ArrayList<>();
for (int i = 0; i < count; i++) {
socketConnections.add(connectSocketTo(uri));
}
awaitNumberOfAcceptedConnectionsToBe(count);
verifyConnectionCount(connector, null, count);
killAcceptedConnectionViaBolt();
verifyConnectionCount(connector, null, 0);
for (TransportConnection socketConnection : socketConnections) {
assertConnectionBreaks(socketConnection);
}
}
use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class ConnectionTrackingIT method afterEach.
@AfterEach
void afterEach() {
for (TransportConnection connection : connections) {
try {
connection.disconnect();
} catch (Exception ignore) {
}
}
httpClients.clear();
IOUtils.closeAllSilently(acceptedConnectionsFromConnectionTracker());
terminateAllTransactions();
awaitNumberOfAcceptedConnectionsToBe(0);
}
use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class BoltSchedulerBusyIT method enterStreaming.
private TransportConnection enterStreaming() throws Throwable {
TransportConnection connection = null;
Throwable error = null;
// retry couple times because worker threads might seem busy
for (int i = 1; i <= 7; i++) {
try {
connection = newConnection();
enterStreaming(connection, i);
error = null;
return connection;
} catch (Throwable t) {
// failed to enter the streaming state, record the error and retry
if (error == null) {
error = t;
} else {
error.addSuppressed(t);
}
close(connection);
SECONDS.sleep(i);
}
}
if (error != null) {
throw error;
}
throw new IllegalStateException("Unable to enter the streaming state");
}
use of org.neo4j.bolt.testing.client.TransportConnection in project neo4j by neo4j.
the class AuthenticationIT method collectAuthFailureOnFailedAuth.
private FailureMessage collectAuthFailureOnFailedAuth() {
FailureMsgMatcher failureRecorder = new FailureMsgMatcher();
TransportConnection connection = null;
try {
connection = newConnection();
connection.connect(address).send(util.defaultAcceptedVersions()).send(util.defaultAuth(map("principal", "neo4j", "credentials", "WHAT_WAS_THE_PASSWORD_AGAIN", "scheme", "basic")));
assertThat(connection).satisfies(util.eventuallyReceivesSelectedProtocolVersion());
assertThat(connection).satisfies(util.eventuallyReceives(failureRecorder));
assertThat(connection).satisfies(eventuallyDisconnects());
} catch (Exception ex) {
throw new RuntimeException(ex);
} finally {
if (connection != null) {
try {
connection.disconnect();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
}
}
return failureRecorder.specialMessage;
}
Aggregations