use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class P2PUnsupportedClassVersionTest method errorMessageListener.
/**
*/
private LogListener errorMessageListener(String clsName) {
LogListener errMsgLsnr = LogListener.matches(UnsupportedClassVersionError.class.getName() + ": " + clsName.replace(".", "/")).build();
lsnrLog.registerListener(errMsgLsnr);
return errMsgLsnr;
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class P2PUnsupportedClassVersionTest method testEntryProcessor.
/**
*/
@Test
public void testEntryProcessor() throws Exception {
IgniteCache<String, String> cache = cli.getOrCreateCache("my-cache");
cache.put("1", "1");
LogListener errMsgLsnr = errorMessageListener(ENTRY_PROC_CLS_NAME);
CacheEntryProcessor<String, String, Boolean> proc = (CacheEntryProcessor<String, String, Boolean>) getExternalClassLoader().loadClass(ENTRY_PROC_CLS_NAME).newInstance();
assertThrowsWithCause(() -> cache.invoke("1", proc), IgniteCheckedException.class);
assertTrue(errMsgLsnr.check());
// Check node is alive.
cache.put("2", "2");
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ClassLoadingProblemExtendedLoggingTest method testCNFE.
/**
* Tests logging when executing job and class is not found on initiator.
*/
@Test
public void testCNFE() throws Exception {
LogListener srvLsnr1 = LogListener.matches("Failed to get resource from node").build();
LogListener srvLsnr2 = LogListener.matches("Failed to find class on remote node").build();
LogListener clientLsnr = LogListener.matches("Failed to resolve class").build();
listeningLog.registerListener(srvLsnr1);
listeningLog.registerListener(srvLsnr2);
listeningLog.registerListener(clientLsnr);
AtomicInteger reqCntr = new AtomicInteger(0);
spi(ignite).closure((node, msg) -> {
if (msg instanceof GridDeploymentRequest && allowSuccessfulClassRequestsCnt - reqCntr.get() <= 0)
setFieldValue(msg, "rsrcName", "asdf");
reqCntr.incrementAndGet();
});
Class cls = getExternalClassLoader().loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1");
try {
client.compute().execute(cls, ignite.cluster().localNode().id());
} catch (Exception ignored) {
/* No-op. */
}
assertTrue(srvLsnr1.check() || srvLsnr2.check());
assertTrue(clientLsnr.check());
spi(ignite).closure(null);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ClassLoadingProblemExtendedLoggingTest method testTimeout.
/**
* Tests logging when executing job with communication problems.
*/
@Test
public void testTimeout() throws ClassNotFoundException {
LogListener lsnr1 = LogListener.matches(msg -> msg.replace("\n", "").matches(".*?Failed to get resource from node \\(is node alive\\?\\).*?" + TimeoutException.class.getName() + ".*")).build();
LogListener lsnr2 = LogListener.matches("Failed to send class-loading request to node").build();
listeningLog.registerListener(lsnr1);
listeningLog.registerListener(lsnr2);
TestRecordingCommunicationSpi clientSpi = spi(client);
AtomicInteger reqCntr = new AtomicInteger(0);
spi(ignite).closure((node, msg) -> {
if (msg instanceof GridDeploymentRequest && allowSuccessfulClassRequestsCnt - reqCntr.get() <= 0)
clientSpi.blockMessages(GridDeploymentResponse.class, ignite.name());
reqCntr.incrementAndGet();
});
Class cls = getExternalClassLoader().loadClass("org.apache.ignite.tests.p2p.P2PTestTaskExternalPath1");
try {
client.compute().execute(cls, ignite.cluster().localNode().id());
} catch (Exception ignored) {
/* No-op. */
}
doSleep(1500);
assertTrue(lsnr1.check() || lsnr2.check());
clientSpi.stopBlock();
}
use of org.apache.ignite.testframework.LogListener 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.");
}
Aggregations