use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class TransactionsMXBeanImplTest method beforeTestsStarted.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTestsStarted() throws Exception {
super.beforeTestsStarted();
testLog = new ListeningTestLogger(false, log);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doServerAndClientTest.
/**
* @throws Exception If failed.
*/
private void doServerAndClientTest() 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 : 16).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, 4, nodeId8, 2, 2)).build();
lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 2))).build();
testLog.registerAllListeners(lsnr, lsnr2);
Ignite srv1 = startGrid("server1");
Ignite client1 = startClientGrid("first client");
Ignite client2 = startClientGrid("second client");
waitForDiscovery(srv, srv1, client1, client2);
} finally {
stopAllGrids();
}
checkLogMessages(aliveNodesLsnr, lsnr, lsnr2);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCommandHandlerDefragmentationTest method createCommandHandler.
/**
*/
private CommandHandler createCommandHandler(ListeningTestLogger testLog) {
Logger log = CommandHandler.initLogger(null);
log.addHandler(new StreamHandler(System.out, new Formatter() {
/**
* {@inheritDoc}
*/
@Override
public String format(LogRecord record) {
String msg = record.getMessage();
testLog.info(msg);
return msg + "\n";
}
}));
return new CommandHandler(log);
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridCommandHandlerDefragmentationTest method testDefragmentationCancelInProgress.
/**
* @throws Exception If failed.
*/
@Test
public void testDefragmentationCancelInProgress() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().state(ClusterState.ACTIVE);
IgniteCache<Object, Object> cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 1024; i++) cache.put(i, i);
forceCheckpoint(ig);
String grid0ConsId = ig.configuration().getConsistentId().toString();
ListeningTestLogger testLog = new ListeningTestLogger();
CommandHandler cmd = createCommandHandler(testLog);
assertEquals(EXIT_CODE_OK, execute(cmd, "--defragmentation", "schedule", "--nodes", grid0ConsId));
String port = grid(0).localNode().attribute(IgniteNodeAttributes.ATTR_REST_TCP_PORT).toString();
stopGrid(0);
blockCdl = new CountDownLatch(128);
UnaryOperator<IgniteConfiguration> cfgOp = cfg -> {
DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration();
FileIOFactory delegate = dsCfg.getFileIOFactory();
dsCfg.setFileIOFactory((file, modes) -> {
if (file.getName().contains("dfrg")) {
if (blockCdl.getCount() == 0) {
try {
// Slow down defragmentation process.
// This'll be enough for the test since we have, like, 900 partitions left.
Thread.sleep(100);
} catch (InterruptedException ignore) {
// No-op.
}
} else
blockCdl.countDown();
}
return delegate.create(file, modes);
});
return cfg;
};
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> {
try {
startGrid(0, cfgOp);
} catch (Exception e) {
// No-op.
throw new RuntimeException(e);
}
});
blockCdl.await();
LogListener logLsnr = LogListener.matches("Defragmentation cancelled successfully.").build();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--port", port, "--defragmentation", "cancel"));
assertTrue(logLsnr.check());
fut.get();
testLog.clearListeners();
logLsnr = LogListener.matches("Defragmentation is already completed or has been cancelled previously.").build();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--port", port, "--defragmentation", "cancel"));
assertTrue(logLsnr.check());
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class AutoActivationPropertyTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
ListeningTestLogger testLog = new ListeningTestLogger(false, log);
LogListener lsnr = LogListener.matches("Property autoActivation deprecated. Use clusterStateOnStart instead.").build();
testLog.registerListener(lsnr);
logListeners.put(igniteInstanceName, lsnr);
return super.getConfiguration(igniteInstanceName).setGridLogger(testLog).setAutoActivationEnabled(autoActivation).setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
}
Aggregations