use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridP2PScanQueryWithTransformerTest method executeP2PClassLoadingDisabledTest.
/**
* Executes scenario with p2p loading of Transformer class failed
* with client or server node sending Scan Query request.
*
* @param withClientNode Flag to execute scan query from client or server node.
* @throws Exception If test scenario failed.
*/
private void executeP2PClassLoadingDisabledTest(boolean withClientNode) throws Exception {
ListeningTestLogger listeningLogger = new ListeningTestLogger();
LogListener clsDeployedMsgLsnr = LogListener.matches("Class was deployed in SHARED or CONTINUOUS mode: " + "class org.apache.ignite.tests.p2p.cache.ScanQueryTestTransformerWrapper").build();
listeningLogger.registerListener(clsDeployedMsgLsnr);
logger = listeningLogger;
IgniteEx ig0 = startGrid(0);
logger = null;
IgniteCache<Integer, Integer> cache = ig0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
populateCache(cache);
IgniteEx requestNode;
if (withClientNode)
requestNode = startClientGrid(1);
else {
clsLoader = TEST_CLASS_LOADER;
requestNode = startGrid(1);
}
IgniteCache<Object, Object> reqNodeCache = requestNode.getOrCreateCache(DEFAULT_CACHE_NAME);
QueryCursor<Integer> query = reqNodeCache.query(new ScanQuery<Integer, Integer>(), loadTransformerClosure());
try {
List<Integer> all = query.getAll();
} catch (Exception e) {
// No-op.
checkTopology(2);
assertFalse(clsDeployedMsgLsnr.check());
return;
}
fail("Expected exception on executing scan query hasn't been not thrown.");
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class GridP2PScanQueryWithTransformerTest method executeP2PClassLoadingEnabledTest.
/**
* Executes scenario with successful p2p loading of Transformer class
* with client or server node sending Scan Query request and iterating over result set.
*
* @param withClientNode Flag to execute scan query from client or server node.
* @throws Exception If failed.
*/
private void executeP2PClassLoadingEnabledTest(boolean withClientNode) throws Exception {
ListeningTestLogger listeningLogger = new ListeningTestLogger();
LogListener clsDeployedMsgLsnr = LogListener.matches("Class was deployed in SHARED or CONTINUOUS mode: " + "class org.apache.ignite.tests.p2p.cache.ScanQueryTestTransformer").build();
listeningLogger.registerListener(clsDeployedMsgLsnr);
logger = listeningLogger;
IgniteEx ig0 = startGrid(0);
logger = null;
IgniteCache<Integer, Integer> cache = ig0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME));
int sumPopulated = populateCache(cache);
IgniteEx requestingNode;
if (withClientNode)
requestingNode = startClientGrid(1);
else {
clsLoader = TEST_CLASS_LOADER;
requestingNode = startGrid(1);
}
// Scan query doesn't work on unstable topology.
awaitPartitionMapExchange();
IgniteCache<Object, Object> reqNodeCache = requestingNode.getOrCreateCache(DEFAULT_CACHE_NAME);
QueryCursor<Integer> query = reqNodeCache.query(new ScanQuery<Integer, Integer>(), loadTransformerClass());
int sumQueried = 0;
for (Integer val : query) sumQueried += val;
assertTrue(sumQueried == sumPopulated * SCALE_FACTOR);
assertTrue(clsDeployedMsgLsnr.check());
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class CheckIndexesInlineSizeOnNodeJoinMultiJvmTest method beforeTest.
/**
* {@inheritDoc}
*/
@Override
protected void beforeTest() throws Exception {
super.beforeTest();
stopAllGrids();
cleanPersistenceDir();
assertEquals(INITIAL_PAYLOAD_SIZE, Integer.parseInt(System.getProperty(IGNITE_MAX_INDEX_PAYLOAD_SIZE)));
testLog = new ListeningTestLogger(false, log);
startGrids(NODES_CNT).cluster().active(true);
for (Map.Entry<String, Object[]> entry : getSqlStatements().entrySet()) executeSql(grid(0), entry.getKey(), entry.getValue());
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class H2TreeCorruptedTreeExceptionTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(gridName);
cfg.setConsistentId(gridName);
cfg.setCacheConfiguration(new CacheConfiguration<>().setName(DEFAULT_CACHE_NAME).setAffinity(new RendezvousAffinityFunction().setPartitions(1)).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
ListeningTestLogger listeningTestLog = new ListeningTestLogger(false, log);
listeningTestLog.registerListener(logListener);
listeningTestLog.registerListener(logSensListener);
cfg.setGridLogger(listeningTestLog);
return cfg;
}
use of org.apache.ignite.testframework.ListeningTestLogger in project ignite by apache.
the class CheckpointReadLockFailureTest method testPrintCpRLockHolder.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_PDS_LOG_CP_READ_LOCK_HOLDERS, value = "true")
public void testPrintCpRLockHolder() throws Exception {
CountDownLatch canRelease = new CountDownLatch(1);
testLog = new ListeningTestLogger(log);
LogListener lsnr = LogListener.matches(LOCK_HOLD_MESSAGE).build();
testLog.registerListener(lsnr);
IgniteEx ig = startGrid(0);
ig.cluster().state(ClusterState.ACTIVE);
GridCacheDatabaseSharedManager db = (GridCacheDatabaseSharedManager) ig.context().cache().context().database();
CheckpointReadWriteLock checkpointReadWriteLock = U.field(db.checkpointManager.checkpointTimeoutLock(), "checkpointReadWriteLock");
ReentrantReadWriteLockWithTracking tracker = U.field(checkpointReadWriteLock, "checkpointLock");
GridTestUtils.runAsync(() -> {
checkpointReadWriteLock.readLock();
try {
canRelease.await(tracker.lockWaitThreshold() + 500, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
checkpointReadWriteLock.readUnlock();
}
}, "async-runnable-runner-1");
assertTrue(GridTestUtils.waitForCondition(lsnr::check, tracker.lockWaitThreshold() + 1000));
stopGrid(0);
}
Aggregations