use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ConsistentIdImplicitlyExplicitlyTest method testConsistentIdConfiguredInIgniteCfgAndJvmProp.
/**
* Consistent ID is configured in the {@link IgniteConfiguration} and in the JVM property.
*
* @throws Exception if failed.
*/
@Test
@WithSystemProperty(key = IGNITE_OVERRIDE_CONSISTENT_ID, value = "JvmProp consistent id")
public void testConsistentIdConfiguredInIgniteCfgAndJvmProp() throws Exception {
defConsistentId = "IgniteCfg consistent id";
String specificConsistentId = System.getProperty(IGNITE_OVERRIDE_CONSISTENT_ID);
;
LogListener lsnr = expectLogEvent(WARN_MESSAGE, 0);
Ignite ignite = startGrid(0);
assertEquals(specificConsistentId, ignite.configuration().getConsistentId());
assertEquals(specificConsistentId, ignite.cluster().localNode().consistentId());
assertTrue(lsnr.check());
info("Consistent ID: " + ignite.cluster().localNode().consistentId());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridCommandHandlerIndexForceRebuildTest method testComplexIndexRebuild.
/**
* Checks that index on 2 fields is rebuilt correctly.
*/
@Test
public void testComplexIndexRebuild() throws IgniteInterruptedCheckedException {
injectTestSystemOut();
LogListener lsnr = installRebuildCheckListener(grid(LAST_NODE_NUM), CACHE_NAME_NO_GRP);
assertEquals(EXIT_CODE_OK, execute("--cache", "indexes_force_rebuild", "--node-id", grid(LAST_NODE_NUM).localNode().id().toString(), "--cache-names", CACHE_NAME_NO_GRP));
assertTrue(waitForIndexesRebuild(grid(LAST_NODE_NUM)));
assertTrue(lsnr.check());
removeLogListener(grid(LAST_NODE_NUM), lsnr);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridCommandHandlerIndexForceRebuildTest method testGroupNamesArg.
/**
* Checks --node-id and --group-names options,
* correctness of utility output and the fact that indexes were actually rebuilt.
*/
@Test
public void testGroupNamesArg() throws Exception {
blockRebuildIdx.put(CACHE_NAME_1_2, new GridFutureAdapter<>());
injectTestSystemOut();
LogListener[] cache1Listeners = new LogListener[GRIDS_NUM];
LogListener[] cache2Listeners = new LogListener[GRIDS_NUM];
try {
triggerIndexRebuild(LAST_NODE_NUM, Collections.singletonList(CACHE_NAME_1_2));
for (int i = 0; i < GRIDS_NUM; i++) {
cache1Listeners[i] = installRebuildCheckListener(grid(i), CACHE_NAME_1_1);
cache2Listeners[i] = installRebuildCheckListener(grid(i), CACHE_NAME_NO_GRP);
}
assertEquals(EXIT_CODE_OK, execute("--cache", "indexes_force_rebuild", "--node-id", grid(LAST_NODE_NUM).localNode().id().toString(), "--group-names", GRP_NAME_1 + "," + GRP_NAME_2 + "," + GRP_NAME_NON_EXISTING));
blockRebuildIdx.remove(CACHE_NAME_1_2);
waitForIndexesRebuild(grid(LAST_NODE_NUM));
String outputStr = testOut.toString();
validateOutputCacheGroupsNotFound(outputStr, GRP_NAME_NON_EXISTING);
validateOutputIndicesRebuildingInProgress(outputStr, F.asMap(GRP_NAME_1, F.asList(CACHE_NAME_1_2)));
validateOutputIndicesRebuildWasStarted(outputStr, F.asMap(GRP_NAME_1, F.asList(CACHE_NAME_1_1), GRP_NAME_2, F.asList(CACHE_NAME_2_1)));
assertEquals("Unexpected number of lines in outputStr.", 20, outputStr.split("\n").length);
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_1_2);
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 IgniteTopologyPrintFormatSelfTest method doServerAndClientTest.
/**
* @throws Exception If failed.
*/
private void doServerAndClientTest() throws Exception {
String nodeId8;
testLog = new ListeningTestLogger(log);
Pattern ptrn = Pattern.compile(String.format(ALIVE_NODES_MSG, 1, 4));
LogListener aliveNodesLsnr = LogListener.matches(ptrn).times(log.isDebugEnabled() ? 0 : 16).build();
testLog.registerListener(aliveNodesLsnr);
LogListener lsnr;
LogListener lsnr2;
try {
Ignite srv = startGrid("server");
nodeId8 = U.id8(srv.cluster().localNode().id());
lsnr = LogListener.matches(String.format(TOPOLOGY_MSG, 4, nodeId8, 2, 2)).build();
lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 2))).build();
testLog.registerAllListeners(lsnr, lsnr2);
Ignite srv1 = startGrid("server1");
Ignite client1 = startClientGrid("first client");
Ignite client2 = startClientGrid("second client");
waitForDiscovery(srv, srv1, client1, client2);
} finally {
stopAllGrids();
}
checkLogMessages(aliveNodesLsnr, lsnr, lsnr2);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridCommandHandlerDefragmentationTest method testDefragmentationCancelInProgress.
/**
* @throws Exception If failed.
*/
@Test
public void testDefragmentationCancelInProgress() throws Exception {
IgniteEx ig = startGrid(0);
ig.cluster().state(ClusterState.ACTIVE);
IgniteCache<Object, Object> cache = ig.getOrCreateCache(DEFAULT_CACHE_NAME);
for (int i = 0; i < 1024; i++) cache.put(i, i);
forceCheckpoint(ig);
String grid0ConsId = ig.configuration().getConsistentId().toString();
ListeningTestLogger testLog = new ListeningTestLogger();
CommandHandler cmd = createCommandHandler(testLog);
assertEquals(EXIT_CODE_OK, execute(cmd, "--defragmentation", "schedule", "--nodes", grid0ConsId));
String port = grid(0).localNode().attribute(IgniteNodeAttributes.ATTR_REST_TCP_PORT).toString();
stopGrid(0);
blockCdl = new CountDownLatch(128);
UnaryOperator<IgniteConfiguration> cfgOp = cfg -> {
DataStorageConfiguration dsCfg = cfg.getDataStorageConfiguration();
FileIOFactory delegate = dsCfg.getFileIOFactory();
dsCfg.setFileIOFactory((file, modes) -> {
if (file.getName().contains("dfrg")) {
if (blockCdl.getCount() == 0) {
try {
// Slow down defragmentation process.
// This'll be enough for the test since we have, like, 900 partitions left.
Thread.sleep(100);
} catch (InterruptedException ignore) {
// No-op.
}
} else
blockCdl.countDown();
}
return delegate.create(file, modes);
});
return cfg;
};
IgniteInternalFuture<?> fut = GridTestUtils.runAsync(() -> {
try {
startGrid(0, cfgOp);
} catch (Exception e) {
// No-op.
throw new RuntimeException(e);
}
});
blockCdl.await();
LogListener logLsnr = LogListener.matches("Defragmentation cancelled successfully.").build();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--port", port, "--defragmentation", "cancel"));
assertTrue(logLsnr.check());
fut.get();
testLog.clearListeners();
logLsnr = LogListener.matches("Defragmentation is already completed or has been cancelled previously.").build();
testLog.registerListener(logLsnr);
assertEquals(EXIT_CODE_OK, execute(cmd, "--port", port, "--defragmentation", "cancel"));
assertTrue(logLsnr.check());
}
Aggregations