use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class EagerTtlTest method testOneNodeRestartWithTtlCache.
/**
* Checks of restart node with TTL cache.
*
* @throws Exception If failed.
*/
@Test
public void testOneNodeRestartWithTtlCache() throws Exception {
eagerTtl = true;
IgniteEx ignite = startGrid(0);
ignite.cluster().state(ClusterState.ACTIVE);
IgniteCache<Integer, Integer> cache = ignite.cache(DEFAULT_CACHE_NAME);
for (int i = 0; i < ENTRIES; i++) cache.put(i, i);
ignite.close();
LogListener assertListener = LogListener.matches(ASSERTION_ERR).build();
listeningLog.registerListener(assertListener);
ignite = startGrid(0);
CountDownLatch exchangeHangLatch = new CountDownLatch(1);
ignite.context().cache().context().exchange().registerExchangeAwareComponent(new PartitionsExchangeAware() {
@Override
public void onInitBeforeTopologyLock(GridDhtPartitionsExchangeFuture fut) {
try {
exchangeHangLatch.await();
} catch (InterruptedException e) {
log.error("Interrupted of waiting latch", e);
fail(e.getMessage());
}
}
});
IgniteInternalFuture<?> activeFut = GridTestUtils.runAsync(() -> ignite(0).cluster().state(ClusterState.ACTIVE));
assertFalse(activeFut.isDone());
assertFalse(GridTestUtils.waitForCondition(assertListener::check, 2_000));
exchangeHangLatch.countDown();
activeFut.get();
awaitPartitionMapExchange();
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class TransactionsMXBeanImplTest method checkLongOperationsDumpTimeoutViaTxMxBean.
/**
* Checking changes and receiving lrt through MXBean.
*
* @param defTimeout Default lrt timeout.
* @param newTimeout New lrt timeout.
* @param waitTimeTx Waiting time for a lrt.
* @param expectTx Expect or not a lrt to log.
* @throws Exception If failed.
*/
private void checkLongOperationsDumpTimeoutViaTxMxBean(long defTimeout, long newTimeout, long waitTimeTx, boolean expectTx) throws Exception {
IgniteEx ignite = startGrid(0);
IgniteEx ignite1 = startGrid(1);
ignite.cluster().state(ACTIVE);
TransactionsMXBean txMXBean = txMXBean(0);
TransactionsMXBean txMXBean1 = txMXBean(1);
assertEquals(defTimeout, txMXBean.getLongOperationsDumpTimeout());
assertEquals(defTimeout, txMXBean1.getLongOperationsDumpTimeout());
Transaction tx = ignite.transactions().txStart();
LogListener lrtLogLsnr = matches("First 10 long running transactions [total=1]").build();
LogListener txLogLsnr = matches(((TransactionProxyImpl) tx).tx().xidVersion().toString()).build();
testLog.registerListener(lrtLogLsnr);
testLog.registerListener(txLogLsnr);
txMXBean.setLongOperationsDumpTimeout(newTimeout);
assertEquals(newTimeout, ignite.context().cache().context().tm().longOperationsDumpTimeout());
assertEquals(newTimeout, ignite1.context().cache().context().tm().longOperationsDumpTimeout());
if (expectTx)
assertTrue(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
else
assertFalse(waitForCondition(() -> lrtLogLsnr.check() && txLogLsnr.check(), waitTimeTx));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridLongRunningInitNewCrdFutureDiagnosticsTest method expectLogEvent.
/**
* @param evtMsg Event message.
* @param cnt Number of expected events.
*/
private LogListener expectLogEvent(String evtMsg, int cnt) {
LogListener lsnr = LogListener.matches(s -> s.startsWith(evtMsg)).atLeast(cnt).build();
log.registerListener(lsnr);
return lsnr;
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridLongRunningInitNewCrdFutureDiagnosticsTest method receiveDiagnosticLogForLongRunningFuture.
/**
*/
@Test
public void receiveDiagnosticLogForLongRunningFuture() throws Exception {
LogListener lsnr = expectLogEvent(DIAGNOSTIC_MESSAGE, 1);
startGrid(0);
startGrid(1);
startGrid(NODE_WITH_DIAGNOSTIC_LOG);
startGrid(3);
testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(1));
testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(NODE_WITH_DIAGNOSTIC_LOG));
testRecordingCommSpi.blockMessages(GridDhtPartitionsSingleMessage.class, getTestIgniteInstanceName(3));
// It makes PME future on node#1
stopGrid(0);
// It makes new crd init future inside PME future on node#2
stopGrid(1);
assertTrue(lsnr.check(getTestTimeout()));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class CacheRebalanceWithRemovedWalSegment method test.
/**
* @throws Exception If failed.
*/
@Test
public void test() throws Exception {
IgniteEx ignite = startGrids(2);
ignite.cluster().state(ClusterState.ACTIVE);
IgniteCache cache = ignite.cache(DEFAULT_CACHE_NAME);
byte[] testVal = new byte[20 * 1024];
for (int i = 0; i < 300; i++) cache.put(i, testVal);
forceCheckpoint();
ignite(1).close();
for (int i = 300; i < 500; i++) cache.put(i, testVal);
forceCheckpoint();
stopAllGrids();
ignite = startGridWithBlockedDemandMessages(1, 0);
startGrid(0);
ignite.cluster().state(ClusterState.ACTIVE);
GridDhtPartitionsExchangeFuture exchangeFuture = ignite(0).context().cache().context().exchange().lastTopologyFuture();
// Waiting for reservation, otherwise we can catch a problem during reservation.
exchangeFuture.get();
TestRecordingCommunicationSpi.spi(ignite).waitForBlocked();
File walPath = new File(U.resolveWorkDirectory(ignite(0).context().config().getWorkDirectory(), DataStorageConfiguration.DFLT_WAL_ARCHIVE_PATH, false), ignite(0).context().pdsFolderResolver().resolveFolders().folderName());
for (File file : walPath.listFiles()) {
if (U.delete(file))
info("File deleted " + file);
else
info("Can't delete file " + file);
}
LogListener lsnr = LogListener.matches("Failed to continue supplying [grp=" + DEFAULT_CACHE_NAME + ", demander=" + ignite.localNode().id() + ", topVer=" + exchangeFuture.topologyVersion() + ']').build();
listeningLog.registerListener(lsnr);
TestRecordingCommunicationSpi.spi(ignite).stopBlock();
awaitPartitionMapExchange();
assertTrue(lsnr.check());
assertPartitionsSame(idleVerify(ignite, DEFAULT_CACHE_NAME));
}
Aggregations