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);
}
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));
}
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());
}
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;
}
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)));
}
Aggregations