Search in sources :

Example 96 with ListeningTestLogger

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

the class LongRunningQueryTest method checkBigResultSet.

/**
 */
private void checkBigResultSet() throws Exception {
    ListeningTestLogger testLog = testLog();
    LogListener lsnr = LogListener.matches("Query produced big result set").build();
    testLog.registerListener(lsnr);
    try (FieldsQueryCursor cur = sql("SELECT T0.id FROM test AS T0, test AS T1")) {
        Iterator it = cur.iterator();
        while (it.hasNext()) it.next();
    }
    assertTrue(lsnr.check(1_000));
}
Also used : FieldsQueryCursor(org.apache.ignite.cache.query.FieldsQueryCursor) LogListener(org.apache.ignite.testframework.LogListener) Iterator(java.util.Iterator) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Example 97 with ListeningTestLogger

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

the class LongRunningQueryTest method checkFastQueries.

/**
 * Do several fast queries.
 * Log messages must not contain info about long query.
 */
private void checkFastQueries() {
    ListeningTestLogger testLog = testLog();
    LogListener lsnr = LogListener.matches(Pattern.compile(LONG_QUERY_EXEC_MSG)).build();
    testLog.registerListener(lsnr);
    // Several fast queries.
    for (int i = 0; i < 10; ++i) sql("SELECT * FROM test").getAll();
    assertFalse(lsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Example 98 with ListeningTestLogger

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

the class LongRunningQueryTest method checkLongRunning.

/**
 * Do long running query canceled by timeout and check log output.
 * Log messages must contain info about long query.
 */
private void checkLongRunning() {
    ListeningTestLogger testLog = testLog();
    LogListener lsnr = LogListener.matches(LONG_QUERY_EXEC_MSG).build();
    testLog.registerListener(lsnr);
    sqlCheckLongRunning();
    assertTrue(lsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Example 99 with ListeningTestLogger

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

the class TcpDiscoverySelfTest method testCheckRingLatency.

/**
 * @throws Exception If failed.
 */
@Test
public void testCheckRingLatency() throws Exception {
    int hops = 1;
    ListeningTestLogger testLog = new ListeningTestLogger(false, log);
    // We should discard ring check latency on server node.
    LogListener lsnr = LogListener.matches("Latency check has been discarded").times(hops).build();
    testLog.registerListener(lsnr);
    try {
        IgniteEx node = startGrid(getConfiguration("server").setGridLogger(testLog));
        startGrid(getConfiguration("client").setClientMode(true));
        TcpDiscoverySpi discoverySpi = (TcpDiscoverySpi) node.context().discovery().getInjectedDiscoverySpi();
        discoverySpi.impl.checkRingLatency(hops);
        assertTrue("Check ring latency message wasn't discarded", lsnr.check(1000));
    } finally {
        stopAllGrids();
    }
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 100 with ListeningTestLogger

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

the class ListeningTestLoggerTest method testEchoLogger.

/**
 * Check "echo" logger.
 */
@Test
public void testEchoLogger() {
    IgniteLogger echo = new StringLogger();
    ListeningTestLogger log = new ListeningTestLogger(true, echo);
    log.error("1");
    log.warning("2");
    log.info("3");
    log.debug("4");
    log.trace("5");
    assertEquals("12345", echo.toString());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) IgniteLogger(org.apache.ignite.IgniteLogger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Aggregations

ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)101 Test (org.junit.Test)51 LogListener (org.apache.ignite.testframework.LogListener)48 IgniteEx (org.apache.ignite.internal.IgniteEx)36 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)30 Ignite (org.apache.ignite.Ignite)21 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)21 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)17 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)14 CountDownLatch (java.util.concurrent.CountDownLatch)9 IgniteCache (org.apache.ignite.IgniteCache)9 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 List (java.util.List)8 Pattern (java.util.regex.Pattern)8 ClusterState (org.apache.ignite.cluster.ClusterState)7 GridQueryProcessor (org.apache.ignite.internal.processors.query.GridQueryProcessor)7 Collections (java.util.Collections)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6