use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class FailureProcessorThreadDumpThrottlingTest method testThrottlingPerFailureType.
/**
* Tests that thread dumps will be throttled per failure type and will be generated again after timeout exceeded.
*/
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "true")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "3000")
public void testThrottlingPerFailureType() throws Exception {
LogListener dumpLsnr = LogListener.matches(THREAD_DUMP_MSG).times(4).build();
LogListener throttledLsnr = LogListener.matches("Thread dump is hidden").times(4).build();
testLog.registerListener(dumpLsnr);
testLog.registerListener(throttledLsnr);
IgniteEx ignite = ignite(0);
FailureContext workerBlockedFailureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
FailureContext opTimeoutFailureCtx = new FailureContext(SYSTEM_CRITICAL_OPERATION_TIMEOUT, new Throwable("Failure context error"));
for (int i = 0; i < 2; i++) {
ignite.context().failure().process(workerBlockedFailureCtx);
ignite.context().failure().process(opTimeoutFailureCtx);
}
U.sleep(3000);
for (int i = 0; i < 2; i++) {
ignite.context().failure().process(workerBlockedFailureCtx);
ignite.context().failure().process(opTimeoutFailureCtx);
}
assertTrue(dumpLsnr.check());
assertTrue(throttledLsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class FailureProcessorThreadDumpThrottlingTest method testNoThreadDumps.
/**
* Tests that thread dumps will not get if {@code IGNITE_DUMP_THREADS_ON_FAILURE == false}.
*/
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "false")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "0")
public void testNoThreadDumps() throws Exception {
LogListener lsnr = LogListener.matches(THREAD_DUMP_MSG).times(0).build();
testLog.registerListener(lsnr);
IgniteEx ignite = ignite(0);
FailureContext failureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
for (int i = 0; i < 2; i++) ignite.context().failure().process(failureCtx);
assertTrue(lsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridP2PContinuousDeploymentClientDisconnectTest method testEventRemoteFilter.
/**
* Test starts 1 server node and 1 client node. Class-loading request for the {@link #P2P_TEST_OBJ_RSRC_NAME}
* resource blocks on the client node. The client node tries to deploy remote event listener for
* the cache {@link #DEFAULT_CACHE_NAME}.
* Expected that exception with 'Failed to unmarshal deployable object.' error message will be thrown and
* the server node wouldn't be failed.
*
* @throws Exception If failed.
*/
@Test
public void testEventRemoteFilter() throws Exception {
final Class<IgnitePredicate<Event>> evtFilterCls = (Class<IgnitePredicate<Event>>) getExternalClassLoader().loadClass(EVT_REMOTE_FILTER_CLS_NAME);
LogListener lsnr = LogListener.matches("Failed to unmarshal deployable object.").build();
testLog.registerListener(lsnr);
assertThrowsWithCause(() -> grid(1).events().remoteListen((uuid, event) -> true, evtFilterCls.newInstance(), EventType.EVT_NODE_JOINED), IgniteException.class);
assertTrue(lsnr.check());
// Check that the failure handler was not called.
assertFalse(failure.get());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ClassPathContentLoggingTest method testClassPathContentLogging.
/**
* Checks the presence of class path content message in log when enabled.
*
* @throws Exception if failed.
*/
@Test
public void testClassPathContentLogging() throws Exception {
String javaClassPath = System.getProperty("java.class.path", ".");
LogListener lsnr = LogListener.matches("List of files containing in classpath").build();
LogListener clsPathValuelsnr = LogListener.matches("Classpath value").build();
LogListener errLsnr = LogListener.matches("Could not log class path entry").build();
LogListener.Builder contenLsnrBuilder = LogListener.builder();
String jarPath = new StringBuilder(javaHome).append(javaHome.endsWith(File.separator) ? "" : File.separator).append("lib").append(File.separator).toString();
Iterable<Path> jars = Files.newDirectoryStream(Paths.get(jarPath), "*.jar");
for (Path jar : jars) contenLsnrBuilder.andMatches(jar.getFileName().toString());
Arrays.stream(javaClassPath.split(File.separator)).filter(fileName -> new File(fileName).isDirectory()).forEach(contenLsnrBuilder::andMatches);
LogListener contentLsnr = contenLsnrBuilder.build();
listeningLog.registerListener(lsnr);
listeningLog.registerListener(clsPathValuelsnr);
listeningLog.registerListener(errLsnr);
listeningLog.registerListener(contentLsnr);
startGrid(0);
assertTrue(lsnr.check());
assertTrue(clsPathValuelsnr.check());
assertTrue(contentLsnr.check());
assertFalse(errLsnr.check());
}
use of org.apache.ignite.testframework.LogListener 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);
}
Aggregations