Search in sources :

Example 46 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class PagesPossibleCorruptionDiagnosticTest method testDiagnosticCollectedOnCorruptedPageList.

/**
 * Tests page list pages are collected in {@link CorruptedFreeListException}.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_PAGES_LIST_DISABLE_ONHEAP_CACHING, value = "true")
public void testDiagnosticCollectedOnCorruptedPageList() throws Exception {
    IgniteEx ignite = startGrid(0);
    ignite.cluster().state(ClusterState.ACTIVE);
    IgniteCache<Integer, Integer> cache = ignite.getOrCreateCache(new CacheConfiguration<Integer, Integer>(DEFAULT_CACHE_NAME).setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL).setAffinity(new RendezvousAffinityFunction(false, 1)));
    cache.put(1, 1);
    cache.remove(1);
    int grpId = cacheGroupId(DEFAULT_CACHE_NAME, null);
    IgniteCacheOffheapManager.CacheDataStore dataStore = ignite.context().cache().cacheGroup(grpId).offheap().cacheDataStores().iterator().next();
    GridCacheOffheapManager.GridCacheDataStore store = (GridCacheOffheapManager.GridCacheDataStore) dataStore;
    AbstractFreeList freeList = store.getCacheStoreFreeList();
    ReuseBag bag = new LongListReuseBag();
    bag.addFreePage(pageId(0, FLAG_DATA, 10));
    bag.addFreePage(pageId(0, FLAG_DATA, 11));
    long[] pages = null;
    try {
        freeList.addForRecycle(bag);
    } catch (CorruptedFreeListException e) {
        pages = e.pageIds();
    }
    assertNotNull(pages);
}
Also used : LongListReuseBag(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.LongListReuseBag) IgniteCacheOffheapManager(org.apache.ignite.internal.processors.cache.IgniteCacheOffheapManager) LongListReuseBag(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.LongListReuseBag) ReuseBag(org.apache.ignite.internal.processors.cache.persistence.tree.reuse.ReuseBag) AbstractFreeList(org.apache.ignite.internal.processors.cache.persistence.freelist.AbstractFreeList) IgniteEx(org.apache.ignite.internal.IgniteEx) CorruptedFreeListException(org.apache.ignite.internal.processors.cache.persistence.freelist.CorruptedFreeListException) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 47 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class IgnitePdsBinarySortObjectFieldsTest method testGivenCacheWithPojoValueAndPds_WhenPut_ThenNoHangup.

/**
 * @throws Exception if failed.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_BINARY_SORT_OBJECT_FIELDS, value = "true")
public void testGivenCacheWithPojoValueAndPds_WhenPut_ThenNoHangup() throws Exception {
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    final IgniteCache<Long, Value> cache = ignite.getOrCreateCache(new CacheConfiguration<Long, Value>(CACHE_NAME).setAffinity(new RendezvousAffinityFunction().setPartitions(32)));
    GridTestUtils.assertTimeout(5, TimeUnit.SECONDS, () -> cache.put(1L, new Value(1L)));
    assertEquals(1, cache.size());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 48 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class FailureProcessorThreadDumpThrottlingTest method testThrottlingPerFailureType.

/**
 * Tests that thread dumps will be throttled per failure type and will be generated again after timeout exceeded.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "true")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "3000")
public void testThrottlingPerFailureType() throws Exception {
    LogListener dumpLsnr = LogListener.matches(THREAD_DUMP_MSG).times(4).build();
    LogListener throttledLsnr = LogListener.matches("Thread dump is hidden").times(4).build();
    testLog.registerListener(dumpLsnr);
    testLog.registerListener(throttledLsnr);
    IgniteEx ignite = ignite(0);
    FailureContext workerBlockedFailureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
    FailureContext opTimeoutFailureCtx = new FailureContext(SYSTEM_CRITICAL_OPERATION_TIMEOUT, new Throwable("Failure context error"));
    for (int i = 0; i < 2; i++) {
        ignite.context().failure().process(workerBlockedFailureCtx);
        ignite.context().failure().process(opTimeoutFailureCtx);
    }
    U.sleep(3000);
    for (int i = 0; i < 2; i++) {
        ignite.context().failure().process(workerBlockedFailureCtx);
        ignite.context().failure().process(opTimeoutFailureCtx);
    }
    assertTrue(dumpLsnr.check());
    assertTrue(throttledLsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 49 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class FailureProcessorThreadDumpThrottlingTest method testNoThreadDumps.

/**
 * Tests that thread dumps will not get if {@code IGNITE_DUMP_THREADS_ON_FAILURE == false}.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "false")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "0")
public void testNoThreadDumps() throws Exception {
    LogListener lsnr = LogListener.matches(THREAD_DUMP_MSG).times(0).build();
    testLog.registerListener(lsnr);
    IgniteEx ignite = ignite(0);
    FailureContext failureCtx = new FailureContext(SYSTEM_WORKER_BLOCKED, new Throwable("Failure context error"));
    for (int i = 0; i < 2; i++) ignite.context().failure().process(failureCtx);
    assertTrue(lsnr.check());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) FailureContext(org.apache.ignite.failure.FailureContext) IgniteEx(org.apache.ignite.internal.IgniteEx) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 50 with WithSystemProperty

use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.

the class AffinityHistoryCleanupTest method testAffinityHistoryCleanup.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_AFFINITY_HISTORY_SIZE, value = "5")
public void testAffinityHistoryCleanup() throws Exception {
    Ignite ignite = startGrid(0);
    // fullHistSize = 1
    checkHistory(ignite, F.asList(topVer(1, 0)), 1);
    startGrid(1);
    checkHistory(ignite, F.asList(// FullHistSize = 1.
    topVer(1, 0), // FullHistSize = 2.
    topVer(2, 0), // FullHistSize = 3.
    topVer(2, 1)), 3);
    startGrid(2);
    checkHistory(ignite, F.asList(// FullHistSize = 1.
    topVer(1, 0), // FullHistSize = 2.
    topVer(2, 0), // FullHistSize = 3.
    topVer(2, 1), // FullHistSize = 4.
    topVer(3, 0), // FullHistSize = 5.
    topVer(3, 1)), 5);
    startGrid(3);
    checkHistory(ignite, F.asList(// FullHistSize = 3.
    topVer(2, 1), // FullHistSize = 4.
    topVer(3, 0), // FullHistSize = 5.
    topVer(3, 1), // FullHistSize = 6 - 1 = 5.
    topVer(4, 0), // FullHistSize = 6 - 1 = 5.
    topVer(4, 1)), 5);
    startClientGrid(4);
    stopGrid(4);
    checkHistory(ignite, F.asList(// FullHistSize = 3.
    topVer(2, 1), // FullHistSize = 4.
    topVer(3, 0), // FullHistSize = 5.
    topVer(3, 1), // FullHistSize = 6 - 1 = 5.
    topVer(4, 0), // FullHistSize = 6 - 1 = 5.
    topVer(4, 1), // Client event -> FullHistSize = 5.
    topVer(5, 0), // Client event -> FullHistSize = 5.
    topVer(6, 0)), 5);
    startClientGrid(4);
    stopGrid(4);
    checkHistory(ignite, F.asList(// FullHistSize = 3.
    topVer(2, 1), // FullHistSize = 4.
    topVer(3, 0), // FullHistSize = 5.
    topVer(3, 1), // FullHistSize = 6 - 1 = 5.
    topVer(4, 0), // FullHistSize = 6 - 1 = 5.
    topVer(4, 1), // Client event -> FullHistSize = 5.
    topVer(5, 0), // Client event -> FullHistSize = 5.
    topVer(6, 0), // Client event -> FullHistSize = 5.
    topVer(7, 0), // Client event -> FullHistSize = 5.
    topVer(8, 0)), 5);
    startClientGrid(4);
    stopGrid(4);
    checkHistory(ignite, F.asList(// FullHistSize = 3.
    topVer(2, 1), // FullHistSize = 4.
    topVer(3, 0), // FullHistSize = 5.
    topVer(3, 1), // FullHistSize = 6 - 1 = 5.
    topVer(4, 0), // FullHistSize = 6 - 1 = 5.
    topVer(4, 1), // Client event -> FullHistSize = 5.
    topVer(5, 0), // Client event -> FullHistSize = 5.
    topVer(6, 0), // Client event -> FullHistSize = 5.
    topVer(7, 0), // Client event -> FullHistSize = 5.
    topVer(8, 0), // Client event -> FullHistSize = 5.
    topVer(9, 0), // Client event -> FullHistSize = 5.
    topVer(10, 0)), 5);
    startGrid(4);
    checkHistory(ignite, F.asList(// FullHistSize = 5.
    topVer(3, 1), // FullHistSize = 6 - 1 = 5.
    topVer(4, 0), // FullHistSize = 6 - 1 = 5.
    topVer(4, 1), // Client event -> FullHistSize = 5.
    topVer(5, 0), // Client event -> FullHistSize = 5.
    topVer(6, 0), // Client event -> FullHistSize = 5.
    topVer(7, 0), // Client event -> FullHistSize = 5.
    topVer(8, 0), // Client event -> FullHistSize = 5.
    topVer(9, 0), // Client event -> FullHistSize = 5.
    topVer(10, 0), // FullHistSize = 6 - 1 = 5.
    topVer(11, 0), // FullHistSize = 6 - 1 = 5.
    topVer(11, 1)), 5);
    stopGrid(4);
    startGrid(4);
    checkHistory(ignite, F.asList(// FullHistSize = 5.
    topVer(11, 0), // FullHistSize = 5.
    topVer(11, 1), // FullHistSize = 6 - 1 = 5.
    topVer(12, 0), // FullHistSize = 5.
    topVer(13, 0), // FullHistSize = 6 - 1 = 5.
    topVer(13, 1)), 5);
}
Also used : Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Aggregations

WithSystemProperty (org.apache.ignite.testframework.junits.WithSystemProperty)71 Test (org.junit.Test)71 GridCommonAbstractTest (org.apache.ignite.testframework.junits.common.GridCommonAbstractTest)59 IgniteEx (org.apache.ignite.internal.IgniteEx)46 Ignite (org.apache.ignite.Ignite)20 LogListener (org.apache.ignite.testframework.LogListener)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 IgniteConfiguration (org.apache.ignite.configuration.IgniteConfiguration)12 DataStorageConfiguration (org.apache.ignite.configuration.DataStorageConfiguration)11 CacheConfiguration (org.apache.ignite.configuration.CacheConfiguration)10 File (java.io.File)9 IgniteInternalFuture (org.apache.ignite.internal.IgniteInternalFuture)9 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)8 DataRegionConfiguration (org.apache.ignite.configuration.DataRegionConfiguration)8 ListeningTestLogger (org.apache.ignite.testframework.ListeningTestLogger)8 List (java.util.List)7 IgniteCache (org.apache.ignite.IgniteCache)7 RendezvousAffinityFunction (org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction)7 ClusterNode (org.apache.ignite.cluster.ClusterNode)7 TestRecordingCommunicationSpi (org.apache.ignite.internal.TestRecordingCommunicationSpi)7