Search in sources :

Example 86 with LogListener

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

the class EagerTtlTest method testOneNodeRestartWithTtlCache.

/**
 * Checks of restart node with TTL cache.
 *
 * @throws Exception If failed.
 */
@Test
public void testOneNodeRestartWithTtlCache() throws Exception {
    eagerTtl = true;
    IgniteEx ignite = startGrid(0);
    ignite.cluster().state(ClusterState.ACTIVE);
    IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
    for (int i = 0; i < ENTRIES; i++) cache.put(i, i);
    ignite.close();
    LogListener assertListener = LogListener.matches(ASSERTION_ERR).build();
    listeningLog.registerListener(assertListener);
    ignite = startGrid(0);
    CountDownLatch exchangeHangLatch = new CountDownLatch(1);
    ignite.context().cache().context().exchange().registerExchangeAwareComponent(new PartitionsExchangeAware() {

        @Override
        public void onInitBeforeTopologyLock(GridDhtPartitionsExchangeFuture fut) {
            try {
                exchangeHangLatch.await();
            } catch (InterruptedException e) {
                log.error("Interrupted of waiting latch", e);
                fail(e.getMessage());
            }
        }
    });
    IgniteInternalFuture<?> activeFut = GridTestUtils.runAsync(() -> ignite(0).cluster().state(ClusterState.ACTIVE));
    assertFalse(activeFut.isDone());
    assertFalse(GridTestUtils.waitForCondition(assertListener::check, 2_000));
    exchangeHangLatch.countDown();
    activeFut.get();
    awaitPartitionMapExchange();
}
Also used : PartitionsExchangeAware(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.PartitionsExchangeAware) GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) CountDownLatch(java.util.concurrent.CountDownLatch) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 87 with LogListener

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

the class TransactionsMXBeanImplTest method checkLongOperationsDumpTimeoutViaTxMxBean.

/**
 * Checking changes and receiving lrt through MXBean.
 *
 * @param defTimeout Default lrt timeout.
 * @param newTimeout New lrt timeout.
 * @param waitTimeTx Waiting time for a lrt.
 * @param expectTx Expect or not a lrt to log.
 * @throws Exception If failed.
 */
private void checkLongOperationsDumpTimeoutViaTxMxBean(long defTimeout, long newTimeout, long waitTimeTx, boolean expectTx) throws Exception {
    IgniteEx ignite = startGrid(0);
    IgniteEx ignite1 = startGrid(1);
    ignite.cluster().state(ACTIVE);
    TransactionsMXBean txMXBean = txMXBean(0);
    TransactionsMXBean txMXBean1 = txMXBean(1);
    assertEquals(defTimeout, txMXBean.getLongOperationsDumpTimeout());
    assertEquals(defTimeout, txMXBean1.getLongOperationsDumpTimeout());
    Transaction tx = ignite.transactions().txStart();
    LogListener lrtLogLsnr = matches("First 10 long running transactions [total=1]").build();
    LogListener txLogLsnr = matches(((TransactionProxyImpl) tx).tx().xidVersion().toString()).build();
    testLog.registerListener(lrtLogLsnr);
    testLog.registerListener(txLogLsnr);
    txMXBean.setLongOperationsDumpTimeout(newTimeout);
    assertEquals(newTimeout, ignite.context().cache().context().tm().longOperationsDumpTimeout());
    assertEquals(newTimeout, ignite1.context().cache().context().tm().longOperationsDumpTimeout());
    if (expectTx)
        assertTrue(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
    else
        assertFalse(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
}
Also used : TransactionsMXBean(org.apache.ignite.mxbean.TransactionsMXBean) Transaction(org.apache.ignite.transactions.Transaction) LogListener(org.apache.ignite.testframework.LogListener) TransactionProxyImpl(org.apache.ignite.internal.processors.cache.transactions.TransactionProxyImpl)

Example 88 with LogListener

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

the class GridLongRunningInitNewCrdFutureDiagnosticsTest method expectLogEvent.

/**
 * @param evtMsg Event message.
 * @param cnt Number of expected events.
 */
private LogListener expectLogEvent(String evtMsg, int cnt) {
    LogListener lsnr = LogListener.matches(s -> s.startsWith(evtMsg)).atLeast(cnt).build();
    log.registerListener(lsnr);
    return lsnr;
}
Also used : LogListener(org.apache.ignite.testframework.LogListener)

Example 89 with LogListener

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

the class GridLongRunningInitNewCrdFutureDiagnosticsTest method receiveDiagnosticLogForLongRunningFuture.

/**
 */
@Test
public void receiveDiagnosticLogForLongRunningFuture() throws Exception {
    LogListener lsnr = expectLogEvent(DIAGNOSTIC_MESSAGE, 1);
    startGrid(0);
    startGrid(1);
    startGrid(NODE_WITH_DIAGNOSTIC_LOG);
    startGrid(3);
    testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(1));
    testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(NODE_WITH_DIAGNOSTIC_LOG));
    testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(3));
    // It makes PME future on node#1
    stopGrid(0);
    // It makes new crd init future inside PME future on node#2
    stopGrid(1);
    assertTrue(lsnr.check(getTestTimeout()));
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 90 with LogListener

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

the class CacheRebalanceWithRemovedWalSegment method test.

/**
 * @throws Exception If failed.
 */
@Test
public void test() throws Exception {
    IgniteEx ignite = startGrids(2);
    ignite.cluster().state(ClusterState.ACTIVE);
    IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
    byte[] testVal = new byte[20 * 1024];
    for (int i = 0; i < 300; i++) cache.put(i, testVal);
    forceCheckpoint();
    ignite(1).close();
    for (int i = 300; i < 500; i++) cache.put(i, testVal);
    forceCheckpoint();
    stopAllGrids();
    ignite = startGridWithBlockedDemandMessages(1, 0);
    startGrid(0);
    ignite.cluster().state(ClusterState.ACTIVE);
    GridDhtPartitionsExchangeFuture exchangeFuture = ignite(0).context().cache().context().exchange().lastTopologyFuture();
    // Waiting for reservation, otherwise we can catch a problem during reservation.
    exchangeFuture.get();
    TestRecordingCommunicationSpi.spi(ignite).waitForBlocked();
    File walPath = new File(U.resolveWorkDirectory(ignite(0).context().config().getWorkDirectory(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, false), ignite(0).context().pdsFolderResolver().resolveFolders().folderName());
    for (File file : walPath.listFiles()) {
        if (U.delete(file))
            info("File deleted " + file);
        else
            info("Can't delete file " + file);
    }
    LogListener lsnr = LogListener.matches("Failed to continue supplying [grp=" + DEFAULT_CACHE_NAME + ", demander=" + ignite.localNode().id() + ", topVer=" + exchangeFuture.topologyVersion() + ']').build();
    listeningLog.registerListener(lsnr);
    TestRecordingCommunicationSpi.spi(ignite).stopBlock();
    awaitPartitionMapExchange();
    assertTrue(lsnr.check());
    assertPartitionsSame(idleVerify(ignite, DEFAULT_CACHE_NAME));
}
Also used : GridDhtPartitionsExchangeFuture(org.apache.ignite.internal.processors.cache.distributed.dht.preloader.GridDhtPartitionsExchangeFuture) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCache(org.apache.ignite.IgniteCache) File(java.io.File) 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