Search in sources :

Example 81 with LogListener

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

the class GridCommandHandlerInterruptCommandTest method testValidateIndexesCommand.

/**
 * Checks that validate_indexes command will cancel after it interrupted.
 *
 * @throws Exception If failed.
 */
@Test
public void testValidateIndexesCommand() throws Exception {
    lnsrLog = new ListeningTestLogger(false, log);
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    preloadeData(ignite);
    CountDownLatch startTaskLatch = waitForTaskEvent(ignite, VALIDATE_INDEX_TASK);
    LogListener lnsrValidationCancelled = LogListener.matches("Index validation was cancelled.").build();
    lnsrLog.registerListener(lnsrValidationCancelled);
    IgniteInternalFuture fut = GridTestUtils.runAsync(() -> assertSame(EXIT_CODE_UNEXPECTED_ERROR, execute("--cache", "validate_indexes")));
    startTaskLatch.await();
    fut.cancel();
    fut.get();
    assertTrue(GridTestUtils.waitForCondition(() -> ignite.compute().activeTaskFutures().isEmpty(), 10_000));
    assertTrue(GridTestUtils.waitForCondition(lnsrValidationCancelled::check, 10_000));
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Test(org.junit.Test)

Example 82 with LogListener

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

the class GridCommandHandlerInterruptCommandTest method testIdleVerifyCommand.

/**
 * Checks that idle verify command will not cancel if initiator client interrupted.
 *
 * @throws Exception If failed.
 */
@Test
public void testIdleVerifyCommand() throws Exception {
    lnsrLog = new ListeningTestLogger(false, log);
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    preloadeData(ignite);
    CountDownLatch startTaskLatch = waitForTaskEvent(ignite, IDLE_VERIFY_TASK_V2);
    LogListener lnsrValidationCancelled = LogListener.matches("The check procedure was cancelled.").build();
    lnsrLog.registerListener(lnsrValidationCancelled);
    IgniteInternalFuture fut = GridTestUtils.runAsync(() -> assertSame(EXIT_CODE_UNEXPECTED_ERROR, execute("--cache", "idle_verify")));
    startTaskLatch.await();
    fut.cancel();
    fut.get();
    assertTrue(GridTestUtils.waitForCondition(() -> ignite.compute().activeTaskFutures().isEmpty(), 30_000));
    assertFalse(lnsrValidationCancelled.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CountDownLatch(java.util.concurrent.CountDownLatch) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Test(org.junit.Test)

Example 83 with LogListener

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

the class GridCommandHandlerIndexForceRebuildTest method testCacheNamesArg.

/**
 * Checks --node-id and --cache-names options,
 * correctness of utility output and the fact that indexes were actually rebuilt.
 */
@Test
public void testCacheNamesArg() throws Exception {
    blockRebuildIdx.put(CACHE_NAME_2_1, new GridFutureAdapter<>());
    injectTestSystemOut();
    LogListener[] cache1Listeners = new LogListener[GRIDS_NUM];
    LogListener[] cache2Listeners = new LogListener[GRIDS_NUM];
    try {
        triggerIndexRebuild(LAST_NODE_NUM, Collections.singletonList(CACHE_NAME_2_1));
        for (int i = 0; i < GRIDS_NUM; i++) {
            cache1Listeners[i] = installRebuildCheckListener(grid(i), CACHE_NAME_1_1);
            cache2Listeners[i] = installRebuildCheckListener(grid(i), CACHE_NAME_1_2);
        }
        assertEquals(EXIT_CODE_OK, execute("--cache", "indexes_force_rebuild", "--node-id", grid(LAST_NODE_NUM).localNode().id().toString(), "--cache-names", CACHE_NAME_1_1 + "," + CACHE_NAME_2_1 + "," + CACHE_NAME_NON_EXISTING));
        blockRebuildIdx.remove(CACHE_NAME_2_1);
        waitForIndexesRebuild(grid(LAST_NODE_NUM));
        String outputStr = testOut.toString();
        validateOutputCacheNamesNotFound(outputStr, CACHE_NAME_NON_EXISTING);
        validateOutputIndicesRebuildingInProgress(outputStr, F.asMap(GRP_NAME_2, F.asList(CACHE_NAME_2_1)));
        validateOutputIndicesRebuildWasStarted(outputStr, F.asMap(GRP_NAME_1, F.asList(CACHE_NAME_1_1)));
        assertEquals("Unexpected number of lines in output.", 19, outputStr.split("\n").length);
        // Index rebuild must be triggered only for cache1_1 and only on node3.
        assertFalse(cache1Listeners[0].check());
        assertFalse(cache1Listeners[1].check());
        assertTrue(cache1Listeners[LAST_NODE_NUM].check());
        for (LogListener cache2Lsnr : cache2Listeners) assertFalse(cache2Lsnr.check());
    } finally {
        blockRebuildIdx.remove(CACHE_NAME_2_1);
        for (int i = 0; i < GRIDS_NUM; i++) {
            removeLogListener(grid(i), cache1Listeners[i]);
            removeLogListener(grid(i), cache2Listeners[i]);
        }
        assertTrue(waitForIndexesRebuild(grid(LAST_NODE_NUM)));
    }
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) MessageOrderLogListener(org.apache.ignite.testframework.MessageOrderLogListener) Test(org.junit.Test)

Example 84 with LogListener

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

the class ActiveOnStartPropertyTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    ListeningTestLogger testLog = new ListeningTestLogger(false, log);
    LogListener lsnr = LogListener.matches("Property activeOnStart deprecated. Use clusterStateOnStart instead.").build();
    testLog.registerListener(lsnr);
    logListeners.put(igniteInstanceName, lsnr);
    return super.getConfiguration(igniteInstanceName).setGridLogger(testLog).setActiveOnStart(activeOnStart).setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME)).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(persistenceEnabled)));
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 85 with LogListener

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

the class ExchangeLatchManagerTest method testExcessAcknowledgeForNewCoordinator.

/**
 * Checks reaction of latch on stale acknowledge from new coordinator.
 *
 * @throws Exception If failed.
 */
@Test
public void testExcessAcknowledgeForNewCoordinator() throws Exception {
    gridLogger = new ListeningTestLogger(log);
    LogListener staleMessageLsnr = LogListener.matches(STALE_ACK_LOG_MSG).build();
    LogListener errorLsnr = LogListener.matches(ERROR_MSG).build();
    IgniteEx ignite0 = startGrids(3);
    awaitPartitionMapExchange();
    TestRecordingCommunicationSpi spi0 = TestRecordingCommunicationSpi.spi(ignite0);
    spi0.blockMessages((node, msg) -> msg instanceof LatchAckMessage && node.order() == 2);
    spi0.record((node, msg) -> msg instanceof LatchAckMessage && node.order() == 3);
    Ignite ignite1 = G.allGrids().stream().filter(node -> node.cluster().localNode().order() == 2).findAny().get();
    assertNotNull("Could not find node with second order.", ignite1);
    TestRecordingCommunicationSpi spi1 = TestRecordingCommunicationSpi.spi(ignite1);
    spi1.blockMessages((node, msg) -> {
        if (msg instanceof LatchAckMessage && node.order() == 3) {
            LatchAckMessage ack = (LatchAckMessage) msg;
            return ack.topVer().topologyVersion() == 3;
        }
        return false;
    });
    IgniteInternalFuture exchangeDoingFut = GridTestUtils.runAsync(() -> ignite0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME)));
    spi0.waitForBlocked();
    spi0.waitForRecorded();
    ignite0.close();
    spi1.waitForBlocked();
    awaitPartitionMapExchange();
    assertTrue(exchangeDoingFut.isDone());
    gridLogger.registerAllListeners(errorLsnr, staleMessageLsnr);
    spi1.stopBlock();
    assertTrue(GridTestUtils.waitForCondition(() -> staleMessageLsnr.check(), 10_000));
    assertFalse(errorLsnr.check());
}
Also used : TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) Ignite(org.apache.ignite.Ignite) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) 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