use of org.neo4j.causalclustering.messaging.TestNetwork in project neo4j by neo4j.
the class ElectionPerformanceIT method electionPerformance_NormalConditions.
@Test
public void electionPerformance_NormalConditions() throws Throwable {
/* This test runs with with few iterations. Hence it does not have the power to catch
* regressions efficiently. Its purpose is mainly to run elections using real-world
* parameters and catch very obvious regressions while not contributing overly much to the
* regression test suites total runtime. */
// given parameters
final long networkLatency = 15L;
final long electionTimeout = 500L;
final long heartbeatInterval = 250L;
final int iterations = 10;
TestNetwork net = new TestNetwork<>((i, o) -> networkLatency);
Set<MemberId> members = asSet(member(0), member(1), member(2));
Fixture fixture = new Fixture(members, net, electionTimeout, heartbeatInterval);
DisconnectLeaderScenario scenario = new DisconnectLeaderScenario(fixture, electionTimeout);
try {
// when running scenario
fixture.boot();
scenario.run(iterations, 10 * electionTimeout);
} finally {
fixture.tearDown();
}
DisconnectLeaderScenario.Result result = scenario.result();
/* These bounds have been experimentally established and should have a very low
* likelihood for false positives without an actual major regression. If this test fails
* then the recommended action is to run the test manually and interpret the results
* to guide further action. Perhaps the power of the test has to be improved, but
* the intention here is not to catch anything but the most major of regressions. */
assertThat(result.nonCollidingAverage, lessThan(2.0 * electionTimeout));
if (result.collisionCount > 3) {
assertThat(result.collidingAverage, lessThan(6.0 * electionTimeout));
}
assertThat(result.timeoutCount, is(0L));
}
use of org.neo4j.causalclustering.messaging.TestNetwork in project neo4j by neo4j.
the class ElectionPerformanceIT method electionPerformance_RapidConditions.
@Test
public void electionPerformance_RapidConditions() throws Throwable {
// given parameters
final long networkLatency = 1L;
final long electionTimeout = 30L;
final long heartbeatInterval = 15L;
final int iterations = 100;
TestNetwork net = new TestNetwork<>((i, o) -> networkLatency);
Set<MemberId> members = asSet(member(0), member(1), member(2));
Fixture fixture = new Fixture(members, net, electionTimeout, heartbeatInterval);
DisconnectLeaderScenario scenario = new DisconnectLeaderScenario(fixture, electionTimeout);
try {
// when running scenario
fixture.boot();
scenario.run(iterations, 10 * electionTimeout);
} finally {
fixture.tearDown();
}
DisconnectLeaderScenario.Result result = scenario.result();
/* These bounds have been experimentally established and should have a very low
* likelihood for false positives without an actual major regression. If this test fails
* then the recommended action is to run the test manually and interpret the results
* to guide further action. Perhaps the power of the test has to be improved, but
* the intention here is not to catch anything but the most major of regressions. */
assertThat(result.nonCollidingAverage, lessThan(2.0 * electionTimeout));
// because of the high number of iterations, it is possible to assert on the collision rate
assertThat(result.collisionRate, lessThan(0.50d));
if (result.collisionCount > 10) {
assertThat(result.collidingAverage, lessThan(5.0 * electionTimeout));
}
// for GC or whatever reason
assertThat(result.timeoutCount, lessThanOrEqualTo(1L));
}
Aggregations