Search in sources :

Example 1 with GridStringLogger

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

the class GridNoopManagerSelfTest method testEnabledManager.

/**
 */
public void testEnabledManager() throws IgniteCheckedException {
    GridTestKernalContext ctx = new GridTestKernalContext(new GridStringLogger());
    assertTrue(new Manager(ctx, new Spi()).enabled());
    assertFalse(new Manager(ctx, new NoopSpi()).enabled());
    assertTrue(new Manager(ctx, new Spi(), new NoopSpi()).enabled());
    assertTrue(new Manager(ctx, new NoopSpi(), new Spi()).enabled());
}
Also used : GridTestKernalContext(org.apache.ignite.testframework.junits.GridTestKernalContext) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) IgniteSpi(org.apache.ignite.spi.IgniteSpi)

Example 2 with GridStringLogger

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

the class IgniteDiagnosticMessagesTest method testSeveralLongRunningTxs.

/**
 * @throws Exception If failed.
 */
public void testSeveralLongRunningTxs() throws Exception {
    int timeout = 3500;
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout));
    try {
        testSpi = true;
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        strLog.logLength(1024 * 100);
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setAtomicityMode(TRANSACTIONAL);
        final Ignite node0 = ignite(0);
        final Ignite node1 = ignite(1);
        node0.createCache(ccfg);
        UUID id0 = node0.cluster().localNode().id();
        TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearLockResponse.class, node1.name());
        IgniteCache<Object, Object> cache = node0.cache(DEFAULT_CACHE_NAME);
        int txCnt = 4;
        final List<Integer> keys = primaryKeys(cache, txCnt, 0);
        final AtomicInteger idx = new AtomicInteger();
        IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME);
                try (Transaction tx = node1.transactions().txStart(PESSIMISTIC, REPEATABLE_READ)) {
                    Integer key = keys.get(idx.getAndIncrement() % keys.size());
                    cache.putIfAbsent(key, String.valueOf(key));
                    tx.commit();
                }
                return null;
            }
        }, txCnt * 2, "tx");
        U.sleep(timeout * 2);
        assertFalse(fut.isDone());
        TestRecordingCommunicationSpi.spi(node0).stopBlock();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("Cache entries [cacheId=" + CU.cacheId(DEFAULT_CACHE_NAME) + ", cacheName=" + DEFAULT_CACHE_NAME + "]:"));
        assertTrue(countTxKeysInASingleBlock(log) == txCnt);
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) IgniteCache(org.apache.ignite.IgniteCache) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Transaction(org.apache.ignite.transactions.Transaction) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 3 with GridStringLogger

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

the class IgniteDiagnosticMessagesTest method testLongRunning.

/**
 * @throws Exception If failed.
 */
public void testLongRunning() throws Exception {
    System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, "3500");
    try {
        testSpi = true;
        startGrid(0);
        GridStringLogger strLog = this.strLog = new GridStringLogger();
        startGrid(1);
        awaitPartitionMapExchange();
        CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME);
        ccfg.setWriteSynchronizationMode(FULL_SYNC);
        ccfg.setCacheMode(PARTITIONED);
        ccfg.setAtomicityMode(TRANSACTIONAL);
        final Ignite node0 = ignite(0);
        node0.createCache(ccfg);
        final Ignite node1 = ignite(1);
        UUID id0 = node0.cluster().localNode().id();
        TestRecordingCommunicationSpi.spi(node0).blockMessages(GridNearSingleGetResponse.class, node1.name());
        IgniteInternalFuture fut = GridTestUtils.runAsync(new Callable<Void>() {

            @Override
            public Void call() throws Exception {
                Integer key = primaryKey(node0.cache(DEFAULT_CACHE_NAME));
                node1.cache(DEFAULT_CACHE_NAME).get(key);
                return null;
            }
        }, "get");
        U.sleep(10_000);
        assertFalse(fut.isDone());
        TestRecordingCommunicationSpi.spi(node0).stopBlock();
        fut.get();
        String log = strLog.toString();
        assertTrue(log.contains("GridPartitionedSingleGetFuture waiting for response [node=" + id0));
        assertTrue(log.contains("General node info [id=" + id0));
    } finally {
        System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) UUID(java.util.UUID) IgniteInternalFuture(org.apache.ignite.internal.IgniteInternalFuture) NearCacheConfiguration(org.apache.ignite.configuration.NearCacheConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration)

Example 4 with GridStringLogger

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

the class ContinuousQueryRemoteFilterMissingInClassPathSelfTest method testNoWarningMessageOnClientNode.

/**
 * @throws Exception If fail.
 */
public void testNoWarningMessageOnClientNode() throws Exception {
    ldr = new URLClassLoader(URLS, getClass().getClassLoader());
    setExternalLoader = true;
    clientMode = false;
    final Ignite ignite0 = startGrid(1);
    executeContiniouseQuery(ignite0.cache("simple"));
    log = new GridStringLogger();
    clientMode = true;
    startGrid(2);
    assertTrue(!log.toString().contains("Failed to unmarshal continuous query remote filter on client node. " + "Can be ignored."));
}
Also used : URLClassLoader(java.net.URLClassLoader) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite)

Example 5 with GridStringLogger

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

the class ContinuousQueryRemoteFilterMissingInClassPathSelfTest method testExceptionOnServerNode.

/**
 * @throws Exception If fail.
 */
public void testExceptionOnServerNode() throws Exception {
    ldr = new URLClassLoader(URLS, getClass().getClassLoader());
    clientMode = false;
    setExternalLoader = true;
    final Ignite ignite0 = startGrid(1);
    executeContiniouseQuery(ignite0.cache("simple"));
    log = new GridStringLogger();
    setExternalLoader = false;
    startGrid(2);
    assertTrue(log.toString().contains("class org.apache.ignite.IgniteCheckedException: " + "Failed to find class with given class loader for unmarshalling"));
}
Also used : URLClassLoader(java.net.URLClassLoader) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite)

Aggregations

GridStringLogger (org.apache.ignite.testframework.GridStringLogger)15 Ignite (org.apache.ignite.Ignite)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)6 NearCacheConfiguration (org.apache.ignite.configuration.NearCacheConfiguration)6 URLClassLoader (java.net.URLClassLoader)4 UUID (java.util.UUID)4 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)4 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)3 Transaction (org.apache.ignite.transactions.Transaction)3 IgniteCache (org.apache.ignite.IgniteCache)2 File (java.io.File)1 Callable (java.util.concurrent.Callable)1 CountDownLatch (java.util.concurrent.CountDownLatch)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)1 IgniteLogger (org.apache.ignite.IgniteLogger)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)1 GridQueryFieldsResult (org.apache.ignite.internal.processors.query.GridQueryFieldsResult)1 GridCompoundFuture (org.apache.ignite.internal.util.future.GridCompoundFuture)1