Search in sources :

Example 61 with ListeningTestLogger

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

the class GridCommandHandlerInterruptCommandTest method testCancelValidateIndexesClosure.

/**
 * Test invokes index validation closure and canceling it after started.
 *
 * @throws Exception If failed.
 */
@Test
public void testCancelValidateIndexesClosure() throws Exception {
    IgniteEx ignite0 = startGrid(0);
    ignite0.cluster().active(true);
    preloadeData(ignite0);
    AtomicBoolean cancelled = new AtomicBoolean(false);
    ValidateIndexesClosure clo = new ValidateIndexesClosure(cancelled::get, Collections.singleton(DEFAULT_CACHE_NAME), 0, 0, false, true);
    ListeningTestLogger listeningLogger = new ListeningTestLogger(false, log);
    GridTestUtils.setFieldValue(clo, "ignite", ignite0);
    GridTestUtils.setFieldValue(clo, "log", listeningLogger);
    LogListener lnsrValidationStarted = LogListener.matches("Current progress of ValidateIndexesClosure").build();
    listeningLogger.registerListener(lnsrValidationStarted);
    IgniteInternalFuture fut = GridTestUtils.runAsync(() -> GridTestUtils.assertThrows(log, clo::call, IgniteException.class, ValidateIndexesClosure.CANCELLED_MSG));
    assertTrue(GridTestUtils.waitForCondition(lnsrValidationStarted::check, 10_000));
    assertFalse(fut.isDone());
    cancelled.set(true);
    fut.get(10_000);
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) LogListener(org.apache.ignite.testframework.LogListener) IgniteException(org.apache.ignite.IgniteException) IgniteEx(org.apache.ignite.internal.IgniteEx) ValidateIndexesClosure(org.apache.ignite.internal.visor.verify.ValidateIndexesClosure) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) Test(org.junit.Test)

Example 62 with ListeningTestLogger

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

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

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

the class GridCommandHandlerIndexForceRebuildTest method installRebuildCheckListener.

/**
 * @param ignite IgniteEx instance.
 * @param cacheName Name of checked cache.
 * @return newly installed LogListener.
 */
private LogListener installRebuildCheckListener(IgniteEx ignite, String cacheName) {
    final MessageOrderLogListener lsnr = new MessageOrderLogListener(new MessageOrderLogListener.MessageGroup(true).add("Started indexes rebuilding for cache \\[name=" + cacheName + ".*").add("Finished indexes rebuilding for cache \\[name=" + cacheName + ".*"));
    ListeningTestLogger impl = GridTestUtils.getFieldValue(ignite.log(), "impl");
    assertNotNull(impl);
    impl.registerListener(lsnr);
    return lsnr;
}
Also used : MessageOrderLogListener(org.apache.ignite.testframework.MessageOrderLogListener) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger)

Example 65 with ListeningTestLogger

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

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