Search in sources :

Example 91 with LogListener

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());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 92 with LogListener

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());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 93 with LogListener

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());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) AbstractContinuousQuery(org.apache.ignite.cache.query.AbstractContinuousQuery) IgniteBiPredicate(org.apache.ignite.lang.IgniteBiPredicate) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) CacheEntryEventSerializableFilter(org.apache.ignite.cache.CacheEntryEventSerializableFilter) IgniteEx(org.apache.ignite.internal.IgniteEx) TOPIC_CLASSLOAD(org.apache.ignite.internal.GridTopic.TOPIC_CLASSLOAD) GridKernalContext(org.apache.ignite.internal.GridKernalContext) GridDeploymentManager(org.apache.ignite.internal.managers.deployment.GridDeploymentManager) AbstractFailureHandler(org.apache.ignite.failure.AbstractFailureHandler) CacheEntryEventFilter(javax.cache.event.CacheEntryEventFilter) FailureContext(org.apache.ignite.failure.FailureContext) IgniteClosure(org.apache.ignite.lang.IgniteClosure) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) CacheException(javax.cache.CacheException) GridMessageListener(org.apache.ignite.internal.managers.communication.GridMessageListener) Factory(javax.cache.configuration.Factory) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) EventType(org.apache.ignite.events.EventType) IgniteException(org.apache.ignite.IgniteException) Event(org.apache.ignite.events.Event) Test(org.junit.Test) UUID(java.util.UUID) Ignite(org.apache.ignite.Ignite) ContinuousQuery(org.apache.ignite.cache.query.ContinuousQuery) IgniteCache(org.apache.ignite.IgniteCache) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheEntryEvent(javax.cache.event.CacheEntryEvent) ContinuousQueryWithTransformer(org.apache.ignite.cache.query.ContinuousQueryWithTransformer) LogListener(org.apache.ignite.testframework.LogListener) IgnitePredicate(org.apache.ignite.lang.IgnitePredicate) Event(org.apache.ignite.events.Event) CacheEntryEvent(javax.cache.event.CacheEntryEvent) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 94 with LogListener

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());
}
Also used : Path(java.nio.file.Path) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) Arrays(java.util.Arrays) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Files(java.nio.file.Files) IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP(org.apache.ignite.IgniteSystemProperties.IGNITE_LOG_CLASSPATH_CONTENT_ON_STARTUP) Test(org.junit.Test) File(java.io.File) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IGNITE_QUIET(org.apache.ignite.IgniteSystemProperties.IGNITE_QUIET) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Paths(java.nio.file.Paths) Path(java.nio.file.Path) LogListener(org.apache.ignite.testframework.LogListener) File(java.io.File) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 95 with LogListener

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);
}
Also used : Pattern(java.util.regex.Pattern) LogListener(org.apache.ignite.testframework.LogListener) Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Aggregations

LogListener (org.apache.ignite.testframework.LogListener)144 Test (org.junit.Test)116 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)93 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)68 IgniteEx (org.apache.ignite.internal.IgniteEx)65 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)35 Ignite (org.apache.ignite.Ignite)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)31 IgniteCache (org.apache.ignite.IgniteCache)24 WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)23 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)18 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)16 List (java.util.List)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 Pattern (java.util.regex.Pattern)15 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)13 UUID (java.util.UUID)12 Collections (java.util.Collections)11