use of org.apache.ignite.testframework.ListeningTestLogger 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.ListeningTestLogger 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.ListeningTestLogger 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();
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridTcpCommunicationSpiLogTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
super.beforeTest();
setRootLoggerDebugLevel();
srvTestLog = new ListeningTestLogger(true, log);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class BasicIndexTest method testCorrectFieldsSequenceInPk.
/**
* Checks index usage with correct pk fields enumeration.
*/
@Test
public void testCorrectFieldsSequenceInPk() throws Exception {
inlineSize = 10;
srvLog = new ListeningTestLogger(false, log);
IgniteEx ig0 = startGrid(0);
GridQueryProcessor qryProc = ig0.context().query();
populateTable(qryProc, TEST_TBL_NAME, -2, "FIRST_NAME", "LAST_NAME", "ADDRESS", "LANG");
assertFalse(checkIdxAlreadyExistLog(qryProc, "idx1", TEST_TBL_NAME, "FIRST_NAME", "LAST_NAME"));
assertTrue(checkIdxAlreadyExistLog(qryProc, "idx2", TEST_TBL_NAME, "LAST_NAME", "FIRST_NAME"));
}
Aggregations