use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class CheckpointReadLockFailureTest method testPrintCpRLockHolder.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_PDS_LOG_CP_READ_LOCK_HOLDERS, value = "true")
public void testPrintCpRLockHolder() throws Exception {
CountDownLatch canRelease = new CountDownLatch(1);
testLog = new ListeningTestLogger(log);
LogListener lsnr = LogListener.matches(LOCK_HOLD_MESSAGE).build();
testLog.registerListener(lsnr);
IgniteEx ig = startGrid(0);
ig.cluster().state(ClusterState.ACTIVE);
GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
CheckpointReadWriteLock checkpointReadWriteLock = U.field(db.checkpointManager.checkpointTimeoutLock(), "checkpointReadWriteLock");
ReentrantReadWriteLockWithTracking tracker = U.field(checkpointReadWriteLock, "checkpointLock");
GridTestUtils.runAsync(() -> {
checkpointReadWriteLock.readLock();
try {
canRelease.await(tracker.lockWaitThreshold() + 500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
checkpointReadWriteLock.readUnlock();
}
}, "async-runnable-runner-1");
assertTrue(GridTestUtils.waitForCondition(lsnr::check, tracker.lockWaitThreshold() + 1000));
stopGrid(0);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class IgnitePdsBinaryMetadataAsyncWritingTest method testPutRequestFromClientIsBlockedIfBinaryMetaWriteIsHanging.
/**
* Verifies that put(key) method called from client on cache in FULL_SYNC mode returns only when
* all affinity nodes for this key finished writing binary metadata.
*
* @throws Exception If failed.
*/
@Test
public void testPutRequestFromClientIsBlockedIfBinaryMetaWriteIsHanging() throws Exception {
String cacheName = "testCache";
CacheConfiguration testCacheCfg = new CacheConfiguration(cacheName).setBackups(2).setAtomicityMode(CacheAtomicityMode.ATOMIC).setCacheMode(CacheMode.PARTITIONED).setWriteSynchronizationMode(FULL_SYNC);
IgniteEx ig0 = startGrid(0);
IgniteEx cl0 = startGrid("client0");
CountDownLatch fileWriteLatch = new CountDownLatch(1);
IgniteEx ig1 = startGrid(1);
ig1.context().discovery().setCustomEventListener(MetadataUpdateAcceptedMessage.class, (topVer, snd, msg) -> suppressException(fileWriteLatch::await));
ListeningTestLogger listeningLog = new ListeningTestLogger(log);
setRootLoggerDebugLevel();
LogListener waitingForWriteLsnr = LogListener.matches("Waiting for write completion of").build();
listeningLog.registerListener(waitingForWriteLsnr);
startGrid(2);
ig0.cluster().active(true);
IgniteCache cache0 = cl0.createCache(testCacheCfg);
int key0 = findAffinityKeyForNode(ig0.affinity(cacheName), ig0.localNode());
AtomicBoolean putFinished = new AtomicBoolean(false);
GridTestUtils.runAsync(() -> {
cache0.put(key0, new TestAddress(key0, "Russia", "Saint-Petersburg"));
putFinished.set(true);
});
assertFalse(GridTestUtils.waitForCondition(() -> putFinished.get(), 5_000));
fileWriteLatch.countDown();
assertTrue(GridTestUtils.waitForCondition(() -> putFinished.get(), 5_000));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridTcpCommunicationInverseConnectionEstablishingTest method testClientSkipsInverseConnectionResponse.
/**
* No server threads hang even if client doesn't respond to inverse connection request.
*
* @throws Exception If failed.
*/
@Test
public void testClientSkipsInverseConnectionResponse() throws Exception {
UNREACHABLE_DESTINATION.set(UNRESOLVED_HOST);
RESPOND_TO_INVERSE_REQUEST.set(false);
startGrids(SRVS_NUM - 1);
LogListener lsnr = LogListener.matches("Failed to wait for establishing inverse communication connection").build();
startGrid(SRVS_NUM - 1, (UnaryOperator<IgniteConfiguration>) cfg -> {
ListeningTestLogger log = new ListeningTestLogger(false, cfg.getGridLogger());
log.registerListener(lsnr);
return cfg.setGridLogger(log);
});
forceClientToSrvConnections = false;
IgniteEx client = startClientGrid(SRVS_NUM);
ClusterNode clientNode = client.localNode();
IgniteEx srv = grid(SRVS_NUM - 1);
interruptCommWorkerThreads(client.name());
TcpCommunicationSpi spi = (TcpCommunicationSpi) srv.configuration().getCommunicationSpi();
GridTestUtils.invoke(spi, "onNodeLeft", clientNode.consistentId(), clientNode.id());
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> srv.context().io().sendIoTest(clientNode, new byte[10], false).get());
assertTrue(GridTestUtils.waitForCondition(fut::isDone, 30_000));
assertTrue(lsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridTcpCommunicationSpiSkipWaitHandshakeOnClientTest method startClientAndWaitCommunicationActivation.
/**
*/
private void startClientAndWaitCommunicationActivation() throws IgniteInterruptedCheckedException {
LogListener lsnr = LogListener.matches(msg -> {
boolean matched = msg.startsWith(TCP_COMM_START_MSG);
if (matched)
fetchedTcpPort = parsePort(msg);
return matched;
}).times(1).build();
log.registerListener(lsnr);
new Thread(() -> {
try {
startGrid(0);
} catch (Exception ignore) {
// Noop
}
}).start();
assertTrue(GridTestUtils.waitForCondition(lsnr::check, 20_000));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridTcpCommunicationSpiConfigSelfTest method testSendToNonInitializedTcpCommSpi.
/**
* Verifies that TcpCommunicationSpi starts messaging protocol only when fully initialized.
*
* @see <a href="https://issues.apache.org/jira/browse/IGNITE-12982">IGNITE-12982</a>
*
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = "IGNITE_SKIP_CONFIGURATION_CONSISTENCY_CHECK", value = "true")
public void testSendToNonInitializedTcpCommSpi() throws Exception {
ListeningTestLogger listeningLogger = new ListeningTestLogger(log);
LogListener npeLsnr = LogListener.matches("NullPointerException").andMatches("InboundConnectionHandler.onMessageSent").build();
listeningLogger.registerListener(npeLsnr);
GridTestNode sendingNode = new GridTestNode();
sendingNode.order(0);
GridSpiTestContext sendingCtx = initSpiContext();
TcpCommunicationSpi sendingSpi = initializeSpi(sendingCtx, sendingNode, listeningLogger, false);
spisToStop.add(sendingSpi);
sendingSpi.onContextInitialized(sendingCtx);
GridTestNode receiverNode = new GridTestNode();
receiverNode.order(1);
GridSpiTestContext receiverCtx = initSpiContext();
/*
* This is a dirty hack to intervene into TcpCommunicationSpi#onContextInitialized0 method
* and add a delay before injecting metrics listener into its clients (like InboundConnectionHandler).
* The purpose of the delay is to make race between sending a message and initializing TcpCommSpi visible.
*
* This solution heavily depends on current code structure of onContextInitialized0 method.
* If any modifications are made to it, this logic could break and the test starts failing.
*
* In that case try to rewrite the test or delete it as this race is really hard to test.
*/
receiverCtx.metricsRegistryProducer((name) -> {
try {
Thread.sleep(100);
} catch (Exception ignored) {
// No-op.
}
return new MetricRegistry(name, null, null, new NullLogger());
});
TcpCommunicationSpi receiverSpi = initializeSpi(receiverCtx, receiverNode, listeningLogger, true);
spisToStop.add(receiverSpi);
receiverCtx.remoteNodes().add(sendingNode);
sendingCtx.remoteNodes().add(receiverNode);
IgniteInternalFuture sendFut = GridTestUtils.runAsync(() -> {
Message msg = new GridTestMessage(sendingNode.id(), 0, 0);
sendingSpi.sendMessage(receiverNode, msg);
});
IgniteInternalFuture initFut = GridTestUtils.runAsync(() -> {
try {
receiverSpi.onContextInitialized(receiverCtx);
} catch (Exception ignored) {
// No-op.
}
});
assertFalse("Check test logs, NPE was found", GridTestUtils.waitForCondition(npeLsnr::check, 3_000));
initFut.get();
sendFut.get();
}
Aggregations