Search in sources :

Example 76 with ListeningTestLogger

use of org.apache.ignite.testframework.ListeningTestLogger 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)

Example 77 with ListeningTestLogger

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

the class IgniteTopologyPrintFormatSelfTest method doServerLogTest.

/**
 * @throws Exception If failed.
 */
private void doServerLogTest() throws Exception {
    String nodeId8;
    testLog = new ListeningTestLogger(log);
    Pattern ptrn = Pattern.compile(String.format(ALIVE_NODES_MSG, 1, 2));
    LogListener aliveNodesLsnr = LogListener.matches(ptrn).times(log.isDebugEnabled() ? 0 : 4).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, 2, nodeId8, 2, 0)).build();
        lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 0))).build();
        testLog.registerAllListeners(lsnr, lsnr2);
        Ignite srv1 = startGrid("server1");
        waitForDiscovery(srv, srv1);
    } 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)

Example 78 with ListeningTestLogger

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

the class GridStopWithCollisionSpiTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    FifoQueueCollisionSpi collision = new FifoQueueCollisionSpi();
    collision.setParallelJobsNumber(1);
    cfg.setCollisionSpi(collision);
    lsnr = LogListener.matches(logStr -> logStr.contains("UnsupportedOperationException") && logStr.contains("ConcurrentLinkedHashMap.clear")).build();
    ListeningTestLogger listener = new ListeningTestLogger(log, lsnr);
    cfg.setGridLogger(listener);
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) FifoQueueCollisionSpi(org.apache.ignite.spi.collision.fifoqueue.FifoQueueCollisionSpi) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Example 79 with ListeningTestLogger

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

the class RestorePartitionStateTest method testLogTopPartitions.

/**
 * Check that the progress of restoring partitions with the top partitions is displayed in the log.
 *
 * @throws Exception If fail.
 */
@Test
public void testLogTopPartitions() throws Exception {
    IgniteEx n = startGrid(0);
    n.cluster().state(ClusterState.ACTIVE);
    awaitPartitionMapExchange();
    ((GridCacheDatabaseSharedManager) n.context().cache().context().database()).enableCheckpoints(false).get(getTestTimeout());
    for (IgniteInternalCache cache : n.context().cache().caches()) {
        for (int i = 0; i < 1_000; i++) cache.put(i, cache.name() + i);
    }
    stopAllGrids();
    awaitPartitionMapExchange();
    LogListener startPartRestore = LogListener.matches(logStr -> {
        if (logStr.startsWith("Started restoring partition state [grp=")) {
            try {
                U.sleep(15);
            } catch (IgniteInterruptedCheckedException e) {
                throw new IgniteException(e);
            }
            return true;
        }
        return false;
    }).build();
    LogListener progressPartRestore = LogListener.matches("Restore partitions state progress").andMatches("topProcessedPartitions").build();
    LogListener finishPartRestore = LogListener.matches("Finished restoring partition state for local groups").andMatches("topProcessedPartitions").build();
    TIMEOUT_OUTPUT_RESTORE_PARTITION_STATE_PROGRESS = 150L;
    setRootLoggerDebugLevel();
    startGrid(0, (UnaryOperator<IgniteConfiguration>) cfg -> {
        cfg.setGridLogger(new ListeningTestLogger(log, startPartRestore, progressPartRestore, finishPartRestore));
        return cfg;
    });
    assertTrue(startPartRestore.check());
    assertTrue(progressPartRestore.check());
    assertTrue(finishPartRestore.check());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) UnaryOperator(java.util.function.UnaryOperator) IgniteEx(org.apache.ignite.internal.IgniteEx) TreeSet(java.util.TreeSet) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) F(org.apache.ignite.internal.util.typedef.F) LongStream(java.util.stream.LongStream) GroupPartitionId(org.apache.ignite.internal.processors.cache.persistence.partstate.GroupPartitionId) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteException(org.apache.ignite.IgniteException) TIMEOUT_OUTPUT_RESTORE_PARTITION_STATE_PROGRESS(org.apache.ignite.internal.processors.cache.GridCacheProcessor.TIMEOUT_OUTPUT_RESTORE_PARTITION_STATE_PROGRESS) Test(org.junit.Test) T3(org.apache.ignite.internal.util.typedef.T3) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCacheProcessor.processedPartitionComparator(org.apache.ignite.internal.processors.cache.GridCacheProcessor.processedPartitionComparator) GridCacheProcessor.trimToSize(org.apache.ignite.internal.processors.cache.GridCacheProcessor.trimToSize) GridCacheProcessor.toStringTopProcessingPartitions(org.apache.ignite.internal.processors.cache.GridCacheProcessor.toStringTopProcessingPartitions) Collections(java.util.Collections) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteInterruptedCheckedException(org.apache.ignite.internal.IgniteInterruptedCheckedException) LogListener(org.apache.ignite.testframework.LogListener) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteException(org.apache.ignite.IgniteException) 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 80 with ListeningTestLogger

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

the class WalArchiveSizeConfigurationTest method getPersistentWalLogWarning.

/**
 * Starts up a node in persistent or non-persistent mode and retrieves log messages.
 */
private String getPersistentWalLogWarning(boolean isPersistenceEnabled) throws Exception {
    List<String> msgReceived = Collections.synchronizedList(new ArrayList<>());
    ListeningTestLogger listeningLog = new ListeningTestLogger();
    listeningLog.registerListener(logMsg -> {
        if (logMsg.contains("walHistorySize property is deprecated"))
            msgReceived.add(logMsg);
    });
    DataStorageConfiguration dataStorageConfiguration = new DataStorageConfiguration().setWalHistorySize(123).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(isPersistenceEnabled));
    startGrid(0, (IgniteConfiguration cfg) -> cfg.setDataStorageConfiguration(dataStorageConfiguration).setGridLogger(listeningLog));
    assertTrue("Received more messages than expected: " + msgReceived, msgReceived.size() <= 1);
    return msgReceived.isEmpty() ? "" : msgReceived.get(0);
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

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