Search in sources :

Example 26 with GridStringLogger

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

the class ContinuousQueryRemoteFilterMissingInClassPathSelfTest method testClientJoinsExtClassLoaderNoWarning.

/**
 * @throws Exception If fail.
 */
@Test
public void testClientJoinsExtClassLoaderNoWarning() throws Exception {
    setExternalLoader = true;
    Ignite ignite0 = startGrid(1);
    executeContinuousQuery(ignite0.cache(DEFAULT_CACHE_NAME));
    log = new GridStringLogger();
    startClientGrid(2);
    assertTrue(!log.toString().contains("Failed to unmarshal continuous query remote filter on client node. " + "Can be ignored."));
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 27 with GridStringLogger

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

the class GridCacheConfigurationConsistencySelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    if (useStrLog) {
        strLog = new GridStringLogger(false, cfg.getGridLogger());
        cfg.setGridLogger(strLog);
    }
    cfg.setDeploymentMode(depMode);
    if (cacheEnabled) {
        CacheConfiguration cacheCfg = defaultCacheConfiguration();
        cacheCfg.setName(cacheName);
        cacheCfg.setCacheMode(cacheMode);
        cacheCfg.setAffinity(aff);
        cacheCfg.setBackups(backups);
        cacheCfg.setAtomicityMode(TRANSACTIONAL);
        if (initCache != null)
            initCache.apply(cacheCfg);
        cfg.setCacheConfiguration(cacheCfg);
    } else
        cfg.setCacheConfiguration();
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 28 with GridStringLogger

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

the class GridCacheConfigurationConsistencySelfTest method testCacheUtilsCheckAttributeMismatch.

/**
 * @throws Exception If failed.
 */
@Test
public void testCacheUtilsCheckAttributeMismatch() throws Exception {
    Ignite ignite = startGrid(1);
    final ClusterNode node = ignite.cluster().localNode();
    final GridStringLogger strLog = new GridStringLogger(false, log);
    CU.checkAttributeMismatch(strLog, "cache", node.id(), "cacheMode", "Cache mode", LOCAL, PARTITIONED, false);
    assertTrue("No expected message in log: " + strLog.toString(), strLog.toString().contains("Cache mode mismatch"));
    strLog.reset();
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public Void call() throws Exception {
            CU.checkAttributeMismatch(strLog, "cache", node.id(), "cacheMode", "Cache mode", LOCAL, PARTITIONED, true);
            return null;
        }
    }, IgniteCheckedException.class, "Cache mode mismatch");
    final CacheConfiguration cfg1 = defaultCacheConfiguration();
    cfg1.setCacheMode(LOCAL);
    final CacheConfiguration cfg2 = defaultCacheConfiguration();
    cfg2.setCacheMode(PARTITIONED);
    CU.checkAttributeMismatch(strLog, cfg1, cfg2, node.id(), new T2<>("cacheMode", "Cache mode"), false);
    assertTrue("No expected message in log: " + strLog.toString(), strLog.toString().contains("Cache mode mismatch"));
    GridTestUtils.assertThrows(log, new Callable<Void>() {

        /**
         * {@inheritDoc}
         */
        @Override
        public Void call() throws Exception {
            CU.checkAttributeMismatch(strLog, cfg1, cfg2, node.id(), new T2<>("cacheMode", "Cache mode"), true);
            return null;
        }
    }, IgniteCheckedException.class, "Cache mode mismatch");
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) IgniteCheckedException(org.apache.ignite.IgniteCheckedException) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) T2(org.apache.ignite.internal.util.typedef.T2) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 29 with GridStringLogger

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

the class TcpDiscoverySelfTest method getConfiguration.

/**
 * {@inheritDoc}
 */
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
    IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName);
    ((TcpCommunicationSpi) cfg.getCommunicationSpi()).setSharedMemoryPort(-1);
    TcpDiscoverySpi spi = nodeSpi.get();
    if (spi == null) {
        spi = igniteInstanceName.contains("testPingInterruptedOnNodeFailedFailingNode") ? new TestTcpDiscoverySpi() : new TcpDiscoverySpi();
    } else
        nodeSpi.set(null);
    discoMap.put(igniteInstanceName, spi);
    spi.setIpFinder(ipFinder);
    spi.setNetworkTimeout(2500);
    spi.setIpFinderCleanFrequency(5000);
    spi.setJoinTimeout(5000);
    cfg.setDiscoverySpi(spi);
    cfg.setFailureDetectionTimeout(7500);
    if (ccfgs != null)
        cfg.setCacheConfiguration(ccfgs);
    else
        cfg.setCacheConfiguration();
    if (segPlc != null)
        cfg.setSegmentationPolicy(segPlc);
    cfg.setIncludeEventTypes(EVT_TASK_FAILED, EVT_TASK_FINISHED, EVT_JOB_MAPPED);
    cfg.setIncludeProperties();
    cfg.setMetricsUpdateFrequency(1000);
    if (!igniteInstanceName.contains("LoopbackProblemTest"))
        cfg.setLocalHost("127.0.0.1");
    if (igniteInstanceName.contains("testFailureDetectionOnNodePing")) {
        // To make test faster: on Windows 1 connect takes 1 second.
        spi.setReconnectCount(1);
        cfg.setMetricsUpdateFrequency(40000);
        cfg.setClientFailureDetectionTimeout(41000);
    }
    cfg.setConnectorConfiguration(null);
    if (nodeId != null)
        cfg.setNodeId(nodeId);
    if (igniteInstanceName.contains("NonSharedIpFinder")) {
        TcpDiscoveryVmIpFinder finder = new TcpDiscoveryVmIpFinder();
        finder.setAddresses(Arrays.asList("127.0.0.1:47501"));
        spi.setIpFinder(finder);
    } else if (igniteInstanceName.contains("MulticastIpFinder")) {
        TcpDiscoveryMulticastIpFinder finder = new TcpDiscoveryMulticastIpFinder();
        finder.setAddressRequestAttempts(5);
        finder.setMulticastGroup(GridTestUtils.getNextMulticastGroup(getClass()));
        finder.setMulticastPort(GridTestUtils.getNextMulticastPort(getClass()));
        spi.setIpFinder(finder);
        // (possibly due to http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7122846).
        if (U.isMacOs())
            spi.setLocalAddress(F.first(U.allLocalIps()));
    } else if (igniteInstanceName.contains("testPingInterruptedOnNodeFailedPingingNode"))
        cfg.setFailureDetectionTimeout(30_000);
    else if (igniteInstanceName.contains("testNoRingMessageWorkerAbnormalFailureNormalNode"))
        cfg.setFailureDetectionTimeout(3_000);
    else if (igniteInstanceName.contains("testNoRingMessageWorkerAbnormalFailureSegmentedNode")) {
        cfg.setFailureDetectionTimeout(6_000);
        cfg.setGridLogger(strLog = new GridStringLogger());
        strLog.logLength(300_000);
    } else if (igniteInstanceName.contains("testNodeShutdownOnRingMessageWorkerFailureFailedNode")) {
        cfg.setGridLogger(strLog = new GridStringLogger());
        strLog.logLength(300_000);
    }
    return cfg;
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) TcpDiscoveryMulticastIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.multicast.TcpDiscoveryMulticastIpFinder) TcpDiscoveryVmIpFinder(org.apache.ignite.spi.discovery.tcp.ipfinder.vm.TcpDiscoveryVmIpFinder) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) TcpCommunicationSpi(org.apache.ignite.spi.communication.tcp.TcpCommunicationSpi)

Example 30 with GridStringLogger

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

the class AffinityDistributionLoggingTest method runAndGetExchangeLog.

/**
 * Starts a specified number of Ignite nodes and log partition node exchange during a last node's startup.
 *
 * @param testClientNode Whether it is necessary to get exchange log from the client node.
 * @return Log of latest partition map exchange.
 * @throws Exception In case of an error.
 */
private String runAndGetExchangeLog(boolean testClientNode) throws Exception {
    assert nodes > 1;
    IgniteEx ignite = startGrids(nodes - 1);
    awaitPartitionMapExchange();
    GridCacheProcessor proc = ignite.context().cache();
    GridCacheContext cctx = proc.context().cacheContext(CU.cacheId(DEFAULT_CACHE_NAME));
    final GridStringLogger log = new GridStringLogger(false, this.log);
    GridAffinityAssignmentCache aff = GridTestUtils.getFieldValue(cctx.affinity(), "aff");
    GridTestUtils.setFieldValue(aff, "log", log);
    if (testClientNode)
        startClientGrid(getConfiguration("client"));
    else
        startGrid(nodes);
    awaitPartitionMapExchange();
    return log.toString();
}
Also used : GridCacheContext(org.apache.ignite.internal.processors.cache.GridCacheContext) GridAffinityAssignmentCache(org.apache.ignite.internal.processors.affinity.GridAffinityAssignmentCache) IgniteEx(org.apache.ignite.internal.IgniteEx) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) GridCacheProcessor(org.apache.ignite.internal.processors.cache.GridCacheProcessor)

Aggregations

GridStringLogger (org.apache.ignite.testframework.GridStringLogger)37 Ignite (org.apache.ignite.Ignite)22 Test (org.junit.Test)16 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)14 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)9 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)9 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)9 UUID (java.util.UUID)7 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)7 Transaction (org.apache.ignite.transactions.Transaction)5 URLClassLoader (java.net.URLClassLoader)4 IgniteCache (org.apache.ignite.IgniteCache)4 BinaryMarshaller (org.apache.ignite.internal.binary.BinaryMarshaller)4 ClusterNode (org.apache.ignite.cluster.ClusterNode)2 IgniteEx (org.apache.ignite.internal.IgniteEx)2 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)2 IgniteClusterEx (org.apache.ignite.internal.cluster.IgniteClusterEx)2 GridTestLog4jLogger (org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger)2 File (java.io.File)1 Callable (java.util.concurrent.Callable)1