use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class IgniteTopologyPrintFormatSelfTest method doServerLogTest.
/**
* @throws Exception If failed.
*/
private void doServerLogTest() throws Exception {
String nodeId8;
testLog = new ListeningTestLogger(log);
Pattern ptrn = Pattern.compile(String.format(ALIVE_NODES_MSG, 1, 2));
LogListener aliveNodesLsnr = LogListener.matches(ptrn).times(log.isDebugEnabled() ? 0 : 4).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, 2, nodeId8, 2, 0)).build();
lsnr2 = LogListener.matches(s -> s.contains(String.format(NUMBER_SRV_NODES, 2)) && s.contains(String.format(CLIENT_NODES_COUNT, 0))).build();
testLog.registerAllListeners(lsnr, lsnr2);
Ignite srv1 = startGrid("server1");
waitForDiscovery(srv, srv1);
} finally {
stopAllGrids();
}
checkLogMessages(aliveNodesLsnr, lsnr, lsnr2);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GracefulShutdownTest method testNotIdealOwners.
/**
* Try to stop node when not all backups are matching of ideal assignment.
*
* @throws Exception If failed.
*/
@Test
public void testNotIdealOwners() throws Exception {
backups = 1;
Ignite ignite0 = startGrid(0);
ignite0.cluster().active(true);
for (int i = 1; i <= 3; i++) {
IgniteCache cache = ignite0.cache("cache" + i);
assertNotNull(cache);
try (IgniteDataStreamer streamer = ignite0.dataStreamer("cache" + i)) {
for (int j = 0; j < 100; j++) streamer.addData(j, j);
}
}
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(ignite0);
spi.blockMessages((node, msg) -> {
String nodeName = (String) node.attributes().get(ATTR_IGNITE_INSTANCE_NAME);
if (msg instanceof GridDhtPartitionSupplyMessage) {
GridDhtPartitionSupplyMessage supplyMsg = (GridDhtPartitionSupplyMessage) msg;
if (supplyMsg.groupId() != CU.cacheId(GridCacheUtils.UTILITY_CACHE_NAME) && getTestIgniteInstanceName(1).equals(nodeName))
return true;
}
return false;
});
startGrid(1);
Ignite ignite2 = startGrid(2);
resetBaselineTopology();
spi.waitForBlocked();
for (CacheGroupContext grp : ((IgniteEx) ignite2).context().cache().cacheGroups()) {
GridTestUtils.waitForCondition(() -> !grp.topology().partitionMap(false).get(((IgniteEx) ignite2).localNode().id()).hasMovingPartitions(), 30_000);
}
LogListener lnsr = LogListener.matches("This node is waiting for backups of local partitions for group").build();
listeningLog.registerListener(lnsr);
IgniteInternalFuture fut = GridTestUtils.runAsync(() -> {
ignite2.close();
});
assertTrue(GridTestUtils.waitForCondition(lnsr::check, 30_000));
assertFalse(fut.isDone());
spi.stopBlock();
assertTrue(GridTestUtils.waitForCondition(fut::isDone, 30_000));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GracefulShutdownTest method tesStartCacheWhenNodeStopping.
/**
* Stopping node and start cache which does not allow it.
*
* @throws Exception If failed.
*/
@Test
public void tesStartCacheWhenNodeStopping() throws Exception {
backups = 2;
Ignite ignite0 = startGrid(0);
ignite0.cluster().active(true);
for (int i = 1; i <= 3; i++) {
IgniteCache cache = ignite0.cache("cache" + i);
assertNotNull(cache);
try (IgniteDataStreamer streamer = ignite0.dataStreamer("cache" + i)) {
for (int j = 0; j < 100; j++) streamer.addData(j, j);
}
}
TestRecordingCommunicationSpi spi = TestRecordingCommunicationSpi.spi(ignite0);
spi.blockMessages((node, msg) -> {
String nodeName = (String) node.attributes().get(ATTR_IGNITE_INSTANCE_NAME);
if (msg instanceof GridDhtPartitionSupplyMessage) {
GridDhtPartitionSupplyMessage supplyMsg = (GridDhtPartitionSupplyMessage) msg;
if (supplyMsg.groupId() != CU.cacheId(GridCacheUtils.UTILITY_CACHE_NAME) && getTestIgniteInstanceName(1).equals(nodeName))
return true;
}
return false;
});
Ignite ignite1 = startGrid(1);
Ignite ignite2 = startGrid(2);
resetBaselineTopology();
spi.waitForBlocked();
for (CacheGroupContext grp : ((IgniteEx) ignite2).context().cache().cacheGroups()) {
grp.preloader().rebalanceFuture().get();
}
ignite2.close();
LogListener lnsr = LogListener.matches("This node is waiting for completion of rebalance for group").build();
listeningLog.registerListener(lnsr);
IgniteInternalFuture fut = GridTestUtils.runAsync(() -> {
ignite1.close();
});
assertTrue(GridTestUtils.waitForCondition(lnsr::check, 30_000));
listeningLog.unregisterListener(lnsr);
assertFalse(fut.isDone());
ignite0.getOrCreateCache(new CacheConfiguration(DEFAULT_CACHE_NAME).setBackups(1));
spi.stopBlock();
lnsr = LogListener.matches("This node is waiting for backups of local partitions for group").build();
listeningLog.registerListener(lnsr);
assertTrue(GridTestUtils.waitForCondition(lnsr::check, 30_000));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ExpiryPolicyInfoLoggingTest method checkLoggingExpiryInfoForStaticallyCreatedCacheStartedInRecoveryMode.
/**
* Checking logging of expiry policy info for statically created cache wich started in recovery mode.
*/
@Test
public void checkLoggingExpiryInfoForStaticallyCreatedCacheStartedInRecoveryMode() throws Exception {
persistenceEnabled = true;
LogListener lsnr = LogListener.matches(s -> s.startsWith(String.format(STARTED_CACHE_IN_RECOVERY_MODE_MSG, CACHE_1_NAME)) && s.contains(String.format(EXPRITY_POLICY_MSG, ModifiedExpiryPolicy.class.getName(), true))).times(1).build();
log.registerListener(lsnr);
startGrid(0);
assertTrue(lsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ReadMetricsOnNodeStartupTest method testReadMetricsOnNodeStartup.
/**
* @throws Exception If failed.
*/
@Test
public void testReadMetricsOnNodeStartup() throws Exception {
LogListener lsnr = LogListener.matches(s -> s.contains("Exception")).atLeast(1).build();
listeningLog.registerListener(lsnr);
startGrid(0);
exportLatch.await();
stopGrid(0);
assertFalse("There was an exception during metric read. See log for details.", lsnr.check());
}
Aggregations