Search in sources :

Example 26 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class ListeningTestLoggerTest method testEmptyLine.

/**
 * Checks blank lines matching.
 */
@Test
public void testEmptyLine() {
    LogListener emptyLineLsnr = LogListener.matches("").build();
    log.registerListener(emptyLineLsnr);
    log.info("");
    assertTrue(emptyLineLsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 27 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class ListeningTestLoggerTest method testMultiRange.

/**
 * Checks that only last value is taken into account.
 */
@Test
public void testMultiRange() {
    String msg = "multi range";
    LogListener atMost3 = LogListener.matches(msg).times(1).times(2).atMost(3).build();
    log.registerListener(atMost3);
    for (int i = 0; i < 6; i++) {
        if (i < 4)
            assertTrue(atMost3.check());
        else
            assertFalse(atMost3.check());
        log.info(msg);
    }
    LogListener lsnr4 = LogListener.matches(msg).atLeast(2).atMost(3).times(4).build();
    log.registerListener(lsnr4);
    for (int i = 1; i < 6; i++) {
        log.info(msg);
        if (i == 4)
            assertTrue(lsnr4.check());
        else
            assertFalse(lsnr4.check());
    }
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 28 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class ListeningTestLoggerTest method testRegister.

/**
 * Ensures that listener will be re-registered only once.
 */
@Test
public void testRegister() {
    AtomicInteger cntr = new AtomicInteger();
    LogListener lsnr3 = LogListener.matches(m -> cntr.incrementAndGet() > 0).build();
    log.registerListener(lsnr3);
    log.registerListener(lsnr3);
    log.info("1");
    assertEquals(1, cntr.get());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) GridTestUtils.assertThrowsWithCause(org.apache.ignite.testframework.GridTestUtils.assertThrowsWithCause) Callable(java.util.concurrent.Callable) IgniteLogger(org.apache.ignite.IgniteLogger) Test(org.junit.Test) GridTestUtils(org.apache.ignite.testframework.GridTestUtils) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) NullLogger(org.apache.ignite.logger.NullLogger) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) IgniteVersionUtils(org.apache.ignite.internal.IgniteVersionUtils) Pattern(java.util.regex.Pattern) LogListener(org.apache.ignite.testframework.LogListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 29 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class ListeningTestLoggerTest method testNotPresent.

/**
 * Checks that substring was not found in the log messages.
 */
@Test
public void testNotPresent() {
    String msg = "vacuum";
    LogListener notPresent = LogListener.matches(msg).times(0).build();
    log.registerListener(notPresent);
    log.info("1");
    assertTrue(notPresent.check());
    log.info(msg);
    assertFalse(notPresent.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 30 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class CheckpointStartLoggingTest method testCheckpointLogging.

/**
 * @throws Exception if failed.
 */
@Test
public void testCheckpointLogging() throws Exception {
    LogListener lsnr = LogListener.matches(Pattern.compile(CHECKPOINT_STARTED_LOG_FORMAT)).build();
    testLogger.registerListener(lsnr);
    Ignite ignite = startGrid();
    ignite.cluster().active(true);
    IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(DEFAULT_CACHE_NAME);
    for (int i = 0; i < 1000; i++) cache.put(i, i);
    forceCheckpoint();
    assertTrue(lsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

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