Search in sources :

Example 51 with LogListener

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;
}
Also used : LogListener(org.apache.ignite.testframework.LogListener)

Example 52 with LogListener

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");
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) CacheEntryProcessor(org.apache.ignite.cache.CacheEntryProcessor) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 53 with LogListener

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);
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) TimeoutException(java.util.concurrent.TimeoutException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 54 with LogListener

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();
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) TestRecordingCommunicationSpi.spi(org.apache.ignite.internal.TestRecordingCommunicationSpi.spi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) RunWith(org.junit.runner.RunWith) TimeoutException(java.util.concurrent.TimeoutException) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) LT(org.apache.ignite.internal.util.typedef.internal.LT) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) GridTestUtils.setFieldValue(org.apache.ignite.testframework.GridTestUtils.setFieldValue) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse) Ints.asList(com.google.common.primitives.Ints.asList) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) Parameterized(org.junit.runners.Parameterized) SHARED(org.apache.ignite.configuration.DeploymentMode.SHARED) TestRecordingCommunicationSpi(org.apache.ignite.internal.TestRecordingCommunicationSpi) LogListener(org.apache.ignite.testframework.LogListener) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridDeploymentRequest(org.apache.ignite.internal.managers.deployment.GridDeploymentRequest) GridDeploymentResponse(org.apache.ignite.internal.managers.deployment.GridDeploymentResponse) TimeoutException(java.util.concurrent.TimeoutException) TimeoutException(java.util.concurrent.TimeoutException) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 55 with LogListener

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.");
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) MalformedURLException(java.net.MalformedURLException)

Aggregations

LogListener (org.apache.ignite.testframework.LogListener)144 Test (org.junit.Test)116 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)93 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)68 IgniteEx (org.apache.ignite.internal.IgniteEx)65 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)35 Ignite (org.apache.ignite.Ignite)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)31 IgniteCache (org.apache.ignite.IgniteCache)24 WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)23 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)18 GridTestUtils (org.apache.ignite.testframework.GridTestUtils)16 List (java.util.List)15 CountDownLatch (java.util.concurrent.CountDownLatch)15 Pattern (java.util.regex.Pattern)15 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)13 UUID (java.util.UUID)12 Collections (java.util.Collections)11