Search in sources :

Example 56 with LogListener

use of org.apache.ignite.testframework.LogListener 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 57 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class CheckIndexesInlineSizeOnNodeJoinMultiJvmTest method performTestScenario.

/**
 * Restarts node with given index and check messages in the log after node restart.
 *
 * @param restartNodeIdx Index of restarting node.
 * @throws Exception If something goes wrong.
 */
private void performTestScenario(int restartNodeIdx) throws Exception {
    assertTrue("Wrong restart node index: " + restartNodeIdx, restartNodeIdx >= 0 && restartNodeIdx < NODES_CNT);
    Map<Integer, UUID> nodeIdxToNodeId = IntStream.range(0, NODES_CNT).boxed().collect(Collectors.toMap(i -> i, i -> grid(i).localNode().id()));
    stopGrid(restartNodeIdx);
    nodeId = UUID.randomUUID();
    nodeIdxToNodeId.put(restartNodeIdx, nodeId);
    Collection<LogListener> listeners = registerListeners(restartNodeIdx, nodeIdxToNodeId);
    assertFalse(F.isEmpty(listeners));
    startGrid(restartNodeIdx);
    awaitPartitionMapExchange();
    for (LogListener listener : listeners) assertTrue(listener.toString(), listener.check());
}
Also used : IntStream(java.util.stream.IntStream) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) F(org.apache.ignite.internal.util.typedef.F) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) Collection(java.util.Collection) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) StopNodeOrHaltFailureHandler(org.apache.ignite.failure.StopNodeOrHaltFailureHandler) String.format(java.lang.String.format) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) List(java.util.List) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) Map(java.util.Map) IGNITE_MAX_INDEX_PAYLOAD_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_MAX_INDEX_PAYLOAD_SIZE) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) INLINE_SIZES_DIFFER_WARN_MSG_FORMAT(org.apache.ignite.internal.processors.query.GridQueryProcessor.INLINE_SIZES_DIFFER_WARN_MSG_FORMAT) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) LogListener(org.apache.ignite.testframework.LogListener) UUID(java.util.UUID)

Example 58 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class MixedTracingSpiTest method testNodesWithDifferentTracingSpiPrintsWarningOnConsistencyCheck.

/**
 * Start two nodes: one with noop tracing spi and another one with open census tracing spi.
 * <p/>
 * Cause both tracing spi instances are annotated with {@code @IgniteSpiConsistencyChecked(optional = true)}
 * 'Remote SPI with the same name is not configured: <TracingSpiInstance></>' warning message is expected on
 * node start.
 * <p/>
 * Besides that 'Failed to create span from serialized value' is expected, cause it's not possible
 * to deserialize {@code NoopSpan.INSTANCE} from {@link NoopTracingSpi} on the node
 * with {@link OpenCensusTracingSpi}.
 *
 * @throws Exception If failed.
 */
@Test
public void testNodesWithDifferentTracingSpiPrintsWarningOnConsistencyCheck() throws Exception {
    List<LogListener> listeners = prepareLogListeners();
    startGrid(getConfiguration(getTestIgniteInstanceName(0) + "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
    startGrid(getConfiguration(getTestIgniteInstanceName(1) + "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
    listeners.forEach(lsnr -> assertTrue(lsnr.check()));
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) NoopTracingSpi(org.apache.ignite.spi.tracing.NoopTracingSpi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 59 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class MixedTracingSpiTest method testNodesWithOpenCensusTracingSpiPrintsNothingOnConsistencyCheck.

/**
 * Start two nodes, both with open census tracing spi instances. No warning messages are expected.
 *
 * @throws Exception If failed.
 */
@Test
public void testNodesWithOpenCensusTracingSpiPrintsNothingOnConsistencyCheck() throws Exception {
    List<LogListener> listeners = prepareLogListeners();
    startGrid(getConfiguration(getTestIgniteInstanceName(0) + "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
    startGrid(getConfiguration(getTestIgniteInstanceName(1) + "node-with-open-census-tracing").setTracingSpi(new OpenCensusTracingSpi()).setGridLogger(testLog));
    listeners.forEach(lsnr -> assertFalse(lsnr.check()));
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) OpenCensusTracingSpi(org.apache.ignite.spi.tracing.opencensus.OpenCensusTracingSpi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 60 with LogListener

use of org.apache.ignite.testframework.LogListener in project ignite by apache.

the class MixedTracingSpiTest method testNodesWithNoopTracingSpiPrintsNothingOnConsistencyCheck.

/**
 * Start two nodes, both with noop tracing spi instances. No warning messages are expected.
 *
 * @throws Exception If failed.
 */
@Test
public void testNodesWithNoopTracingSpiPrintsNothingOnConsistencyCheck() throws Exception {
    List<LogListener> listeners = prepareLogListeners();
    startGrid(getConfiguration(getTestIgniteInstanceName(0) + "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
    startGrid(getConfiguration(getTestIgniteInstanceName(1) + "node-with-noop-tracing").setTracingSpi(new NoopTracingSpi()).setGridLogger(testLog));
    listeners.forEach(lsnr -> assertFalse(lsnr.check()));
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) NoopTracingSpi(org.apache.ignite.spi.tracing.NoopTracingSpi) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

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