Search in sources :

Example 11 with GridStringLogger

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

the class IgniteDiagnosticMessagesTest method checkSeveralLongRunningTxs.

/**
 * @param atomicityMode Cache atomicity mode.
 * @throws Exception If failed.
 */
public void checkSeveralLongRunningTxs(CacheAtomicityMode atomicityMode) 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 = cacheConfiguration(atomicityMode);
        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 12 with GridStringLogger

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

the class IgniteClientFailuresTest method testNoMessagesFromFailureProcessor.

/**
 * Test verifies that FailureProcessor doesn't treat tcp-comm-worker thread as blocked when
 * the thread handles situation of failed client node and thus doesn't print full thread dump into logs.
 *
 * @throws Exception If failed.
 */
@Test
public void testNoMessagesFromFailureProcessor() throws Exception {
    GridStringLogger strLog = new GridStringLogger(false, new GridTestLog4jLogger());
    strLog.logLength(1024 * 1024);
    inMemoryLog = strLog;
    IgniteEx srv = startGrid(0);
    inMemoryLog = null;
    IgniteEx client00 = startGrid("client00");
    client00.getOrCreateCache(new CacheConfiguration<>("cache0"));
    breakClient(client00);
    boolean waitRes = GridTestUtils.waitForCondition(() -> {
        IgniteClusterEx cl = srv.cluster();
        return (cl.topology(cl.topologyVersion()).size() == 1);
    }, 30_000);
    assertTrue(waitRes);
    assertFalse(strLog.toString().contains("name=tcp-comm-worker"));
}
Also used : IgniteClusterEx(org.apache.ignite.internal.cluster.IgniteClusterEx) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 13 with GridStringLogger

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

the class IgniteClientFailuresTest method testExchangeWorkerIsNotTreatedAsBlockedWhenClientNodeFails.

/**
 * Test verifies that when some sys thread (on server node) tries to re-establish connection to failed client
 * and exchange-worker gets blocked waiting for it (e.g. to send partitions full map)
 * it is not treated as {@link FailureType#SYSTEM_WORKER_BLOCKED}
 * because this waiting is finite and part of normal operations.
 *
 * @throws Exception If failed.
 */
@Test
public void testExchangeWorkerIsNotTreatedAsBlockedWhenClientNodeFails() throws Exception {
    GridStringLogger strLog = new GridStringLogger(false, new GridTestLog4jLogger());
    strLog.logLength(1024 * 1024);
    inMemoryLog = strLog;
    IgniteEx srv0 = startGrid(0);
    inMemoryLog = null;
    IgniteEx client00 = startGrid("client00");
    client00.getOrCreateCache(new CacheConfiguration<>("cache0"));
    startGrid(1);
    breakClient(client00);
    final IgniteClusterEx cl = srv0.cluster();
    assertEquals(3, cl.topology(cl.topologyVersion()).size());
    startGrid("client01");
    boolean waitRes = GridTestUtils.waitForCondition(() -> (cl.topology(cl.topologyVersion()).size() == 3), 20_000);
    assertTrue(waitRes);
    String logRes = strLog.toString();
    assertFalse(logRes.contains(EXCHANGE_WORKER_BLOCKED_MSG));
}
Also used : IgniteClusterEx(org.apache.ignite.internal.cluster.IgniteClusterEx) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) GridTestLog4jLogger(org.apache.ignite.testframework.junits.logger.GridTestLog4jLogger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 14 with GridStringLogger

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

the class LongJVMPauseDetectorTest method testJulMessage.

/**
 * @throws Exception If failed.
 */
@Test
public void testJulMessage() throws Exception {
    this.strLog = new GridStringLogger(true);
    strLog.logLength(300000);
    startGrid(0);
    assertTrue(strLog.toString().contains("LongJVMPauseDetector was successfully started"));
}
Also used : GridStringLogger(org.apache.ignite.testframework.GridStringLogger) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test)

Example 15 with GridStringLogger

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

the class IgniteSemaphoreAbstractSelfTest method testSemaphoreClosing.

/**
 * @throws Exception If failed.
 */
@Test
public void testSemaphoreClosing() throws Exception {
    IgniteConfiguration cfg;
    GridStringLogger stringLogger;
    stringLogger = new GridStringLogger();
    cfg = optimize(getConfiguration("npeGrid"));
    cfg.setGridLogger(stringLogger);
    try (Ignite ignite = startGrid(cfg.getIgniteInstanceName(), cfg)) {
        ignite.semaphore("semaphore", 1, true, true);
    }
    assertFalse(stringLogger.toString().contains(NullPointerException.class.getName()));
}
Also used : IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridStringLogger(org.apache.ignite.testframework.GridStringLogger) Ignite(org.apache.ignite.Ignite) Test(org.junit.Test)

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