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