use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doForceServerAndClientTest.
/**
* @throws Exception If failed.
*/
private void doForceServerAndClientTest() throws Exception {
String nodeId8;
testLog = new ListeningTestLogger(log);
Pattern ptrn = Pattern.compile(String.format(ALIVE_NODES_MSG, 1, 4));
LogListener aliveNodesLsnr = LogListener.matches(ptrn).times(log.isDebugEnabled() ? 0 : 25).build();
testLog.registerListener(aliveNodesLsnr);
LogListener lsnr;
LogListener lsnr2;
try {
Ignite srv = startGrid("server");
nodeId8 = U.id8(srv.cluster().localNode().id());
lsnr = LogListener.matches(String.format(TOPOLOGY_MSG, 5, nodeId8, 2, 3)).build();
lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 3))).build();
testLog.registerAllListeners(lsnr, lsnr2);
Ignite srv1 = startGrid("server1");
Ignite client1 = startClientGrid("first client");
Ignite client2 = startClientGrid("second client");
Ignite forceServClnt3 = startClientGrid("third client_force_server");
waitForDiscovery(srv, srv1, client1, client2, forceServClnt3);
} finally {
stopAllGrids();
}
checkLogMessages(aliveNodesLsnr, lsnr, lsnr2);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doServerLogTest.
/**
* @throws Exception If failed.
*/
private void doServerLogTest() throws Exception {
String nodeId8;
testLog = new ListeningTestLogger(log);
Pattern ptrn = Pattern.compile(String.format(ALIVE_NODES_MSG, 1, 2));
LogListener aliveNodesLsnr = LogListener.matches(ptrn).times(log.isDebugEnabled() ? 0 : 4).build();
testLog.registerListener(aliveNodesLsnr);
LogListener lsnr;
LogListener lsnr2;
try {
Ignite srv = startGrid("server");
nodeId8 = U.id8(srv.cluster().localNode().id());
lsnr = LogListener.matches(String.format(TOPOLOGY_MSG, 2, nodeId8, 2, 0)).build();
lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 0))).build();
testLog.registerAllListeners(lsnr, lsnr2);
Ignite srv1 = startGrid("server1");
waitForDiscovery(srv, srv1);
} finally {
stopAllGrids();
}
checkLogMessages(aliveNodesLsnr, lsnr, lsnr2);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridStopWithCollisionSpiTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
FifoQueueCollisionSpi collision = new FifoQueueCollisionSpi();
collision.setParallelJobsNumber(1);
cfg.setCollisionSpi(collision);
lsnr = LogListener.matches(logStr -> logStr.contains("UnsupportedOperationException") && logStr.contains("ConcurrentLinkedHashMap.clear")).build();
ListeningTestLogger listener = new ListeningTestLogger(log, lsnr);
cfg.setGridLogger(listener);
return cfg;
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class RestorePartitionStateTest method testLogTopPartitions.
/**
* Check that the progress of restoring partitions with the top partitions is displayed in the log.
*
* @throws Exception If fail.
*/
@Test
public void testLogTopPartitions() throws Exception {
IgniteEx n = startGrid(0);
n.cluster().state(ClusterState.ACTIVE);
awaitPartitionMapExchange();
((GridCacheDatabaseSharedManager) n.context().cache().context().database()).enableCheckpoints(false).get(getTestTimeout());
for (IgniteInternalCache cache : n.context().cache().caches()) {
for (int i = 0; i < 1_000; i++) cache.put(i, cache.name() + i);
}
stopAllGrids();
awaitPartitionMapExchange();
LogListener startPartRestore = LogListener.matches(logStr -> {
if (logStr.startsWith("Started restoring partition state [grp=")) {
try {
U.sleep(15);
} catch (IgniteInterruptedCheckedException e) {
throw new IgniteException(e);
}
return true;
}
return false;
}).build();
LogListener progressPartRestore = LogListener.matches("Restore partitions state progress").andMatches("topProcessedPartitions").build();
LogListener finishPartRestore = LogListener.matches("Finished restoring partition state for local groups").andMatches("topProcessedPartitions").build();
TIMEOUT_OUTPUT_RESTORE_PARTITION_STATE_PROGRESS = 150L;
setRootLoggerDebugLevel();
startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
cfg.setGridLogger(new ListeningTestLogger(log, startPartRestore, progressPartRestore, finishPartRestore));
return cfg;
});
assertTrue(startPartRestore.check());
assertTrue(progressPartRestore.check());
assertTrue(finishPartRestore.check());
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class WalArchiveSizeConfigurationTest method getPersistentWalLogWarning.
/**
* Starts up a node in persistent or non-persistent mode and retrieves log messages.
*/
private String getPersistentWalLogWarning(boolean isPersistenceEnabled) throws Exception {
List<String> msgReceived = Collections.synchronizedList(new ArrayList<>());
ListeningTestLogger listeningLog = new ListeningTestLogger();
listeningLog.registerListener(logMsg -> {
if (logMsg.contains("walHistorySize property is deprecated"))
msgReceived.add(logMsg);
});
DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration().setWalHistorySize(123).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(isPersistenceEnabled));
startGrid(0, (IgniteConfiguration cfg) -> cfg.setDataStorageConfiguration(dataStorageConfiguration).setGridLogger(listeningLog));
assertTrue("Received more messages than expected: " + msgReceived, msgReceived.size() <= 1);
return msgReceived.isEmpty() ? "" : msgReceived.get(0);
}
Aggregations