use of io.aeron.test.SlowTest in project Aeron by real-logic.
the class PongTest method playPingPongWithRestart.
@SlowTest
@Test
void playPingPongWithRestart() {
buffer.putInt(0, 1);
while (pingPublication.offer(buffer, 0, BitUtil.SIZE_OF_INT) < 0L) {
Tests.yield();
}
final MutableInteger fragmentsRead = new MutableInteger();
Tests.executeUntil(() -> fragmentsRead.get() > 0, (i) -> {
fragmentsRead.value += pingSubscription.poll(this::echoPingHandler, 1);
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(5900));
fragmentsRead.set(0);
Tests.executeUntil(() -> fragmentsRead.get() > 0, (i) -> {
fragmentsRead.value += pongSubscription.poll(pongHandler, 1);
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(5900));
// close Pong side
pongPublication.close();
pingSubscription.close();
// wait for disconnect to ensure we stay in lock step
while (pingPublication.isConnected()) {
Tests.sleep(10);
}
// restart Pong side
pingSubscription = pingClient.addSubscription(PING_URI, PING_STREAM_ID);
pongPublication = pongClient.addPublication(PONG_URI, PONG_STREAM_ID);
fragmentsRead.set(0);
while (pingPublication.offer(buffer, 0, BitUtil.SIZE_OF_INT) < 0L) {
Tests.yield();
}
Tests.executeUntil(() -> fragmentsRead.get() > 0, (i) -> {
fragmentsRead.value += pingSubscription.poll(this::echoPingHandler, 10);
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(5900));
fragmentsRead.set(0);
Tests.executeUntil(() -> fragmentsRead.get() > 0, (i) -> {
fragmentsRead.value += pongSubscription.poll(pongHandler, 10);
Thread.yield();
}, Integer.MAX_VALUE, TimeUnit.MILLISECONDS.toNanos(5900));
verify(pongHandler, times(2)).onFragment(any(DirectBuffer.class), eq(DataHeaderFlyweight.HEADER_LENGTH), eq(BitUtil.SIZE_OF_INT), any(Header.class));
}
use of io.aeron.test.SlowTest in project Aeron by real-logic.
the class AsyncResourceTest method shouldDetectUnknownHost.
@Test
@SlowTest
@Timeout(60)
void shouldDetectUnknownHost() {
final ErrorHandler mockClientErrorHandler = mock(ErrorHandler.class);
final Aeron.Context clientCtx = new Aeron.Context().errorHandler(mockClientErrorHandler);
final MediaDriver.Context driverCtx = new MediaDriver.Context().dirDeleteOnStart(true).threadingMode(ThreadingMode.SHARED);
try (TestMediaDriver ignore = TestMediaDriver.launch(driverCtx, testWatcher);
Aeron aeron = Aeron.connect(clientCtx)) {
final long registrationId = aeron.asyncAddPublication("aeron:udp?endpoint=wibble:1234", STREAM_ID);
verify(mockClientErrorHandler, timeout(55_000)).onError(any(RegistrationException.class));
assertFalse(aeron.isCommandActive(registrationId));
assertFalse(aeron.hasActiveCommands());
} finally {
driverCtx.deleteDirectory();
}
}
Aggregations