Search in sources :

Example 36 with ListeningTestLogger

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

Example 37 with ListeningTestLogger

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

Example 38 with ListeningTestLogger

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());
}
Also used : ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 39 with ListeningTestLogger

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;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 40 with ListeningTestLogger

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);
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) IgniteEx(org.apache.ignite.internal.IgniteEx) CheckpointReadWriteLock(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointReadWriteLock) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) CountDownLatch(java.util.concurrent.CountDownLatch) ReentrantReadWriteLockWithTracking(org.apache.ignite.internal.util.ReentrantReadWriteLockWithTracking) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)101 Test (org.junit.Test)51 LogListener (org.apache.ignite.testframework.LogListener)48 IgniteEx (org.apache.ignite.internal.IgniteEx)36 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)32 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)30 Ignite (org.apache.ignite.Ignite)21 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)21 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)17 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)14 CountDownLatch (java.util.concurrent.CountDownLatch)9 IgniteCache (org.apache.ignite.IgniteCache)9 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 List (java.util.List)8 Pattern (java.util.regex.Pattern)8 ClusterState (org.apache.ignite.cluster.ClusterState)7 GridQueryProcessor (org.apache.ignite.internal.processors.query.GridQueryProcessor)7 Collections (java.util.Collections)6 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)6