Search in sources :

Example 21 with WithSystemProperty

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

the class FileWriteAheadLogManagerSelfTest method testGettingMinWalArchiveSizeFromConfiguration.

/**
 * Testing of {@link FileWriteAheadLogManager#minWalArchiveSize(DataStorageConfiguration)}.
 */
@Test
@WithSystemProperty(key = IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, value = "-1")
public void testGettingMinWalArchiveSizeFromConfiguration() {
    DataStorageConfiguration cfg = new DataStorageConfiguration().setMaxWalArchiveSize(UNLIMITED_WAL_ARCHIVE);
    for (long i : F.asList(10L, 20L, HALF_MAX_WAL_ARCHIVE_SIZE)) assertEquals(UNLIMITED_WAL_ARCHIVE, minWalArchiveSize(cfg.setMinWalArchiveSize(i)));
    cfg.setMaxWalArchiveSize(100);
    for (long i : F.asList(10L, 20L)) assertEquals(i, minWalArchiveSize(cfg.setMinWalArchiveSize(i)));
    assertEquals(50, minWalArchiveSize(cfg.setMinWalArchiveSize(HALF_MAX_WAL_ARCHIVE_SIZE)));
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 22 with WithSystemProperty

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

the class FailureProcessorThreadDumpThrottlingTest method testDefaultThrottlingTimeout.

/**
 * Tests that default thread dump trhottling timeout equals failure detection timeout.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "true")
public void testDefaultThrottlingTimeout() throws Exception {
    IgniteEx ignite = ignite(0);
    assertEquals(ignite.context().failure().dumpThreadsTrottlingTimeout(), ignite.configuration().getFailureDetectionTimeout().longValue());
}
Also used : 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 23 with WithSystemProperty

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

the class FailureProcessorThreadDumpThrottlingTest method testThrottling.

/**
 * Tests that thread dumps will be throttled 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 testThrottling() throws Exception {
    LogListener dumpLsnr = LogListener.matches(THREAD_DUMP_MSG).times(2).build();
    LogListener throttledLsnr = LogListener.matches("Thread dump is hidden").times(2).build();
    testLog.registerListener(dumpLsnr);
    testLog.registerListener(throttledLsnr);
    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);
    U.sleep(3000);
    for (int i = 0; i < 2; i++) ignite.context().failure().process(failureCtx);
    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 24 with WithSystemProperty

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

the class FailureProcessorThreadDumpThrottlingTest method testNoThrottling.

/**
 * Tests that thread dumps will get for every failure for disabled throttling.
 */
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE, value = "true")
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DUMP_THREADS_ON_FAILURE_THROTTLING_TIMEOUT, value = "0")
public void testNoThrottling() throws Exception {
    LogListener lsnr = LogListener.matches(THREAD_DUMP_MSG).times(2).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 25 with WithSystemProperty

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

the class H2TreeCorruptedTreeExceptionTest method testCorruptedTree.

/**
 */
@Test
@WithSystemProperty(key = IGNITE_TO_STRING_INCLUDE_SENSITIVE, value = "false")
public void testCorruptedTree() throws Exception {
    IgniteEx srv = startGrid(0);
    srv.cluster().active(true);
    IgniteCache<Integer, Integer> cache = srv.getOrCreateCache(DEFAULT_CACHE_NAME);
    cache.query(new SqlFieldsQuery("create table a (col1 varchar primary key, col2 varchar) with " + "\"CACHE_GROUP=" + GRP_NAME + "\""));
    cache.query(new SqlFieldsQuery("create index " + IDX_NAME + " on a(col2)"));
    failWithCorruptTree.set(true);
    try {
        cache.query(new SqlFieldsQuery("insert into a(col1, col2) values (1, ?1)").setArgs(VERY_SENS_STR_DATA));
        fail("Cache operations are expected to fail");
    } catch (Throwable e) {
        assertTrue(X.hasCause(e, CorruptedTreeException.class));
    }
    assertTrue(logListener.check());
    assertFalse(logSensListener.check());
    System.setProperty(IGNITE_TO_STRING_INCLUDE_SENSITIVE, Boolean.TRUE.toString());
    clearGridToStringClassCache();
    logListener.reset();
    logSensListener.reset();
    try {
        cache.query(new SqlFieldsQuery("insert into a(col1, col2) values (2, ?1)").setArgs(VERY_SENS_STR_DATA));
    } catch (Throwable e) {
        assertTrue(X.hasCause(e, CorruptedTreeException.class));
    }
    assertFalse(logListener.check());
    assertTrue(logSensListener.check());
}
Also used : IgniteEx(org.apache.ignite.internal.IgniteEx) SqlFieldsQuery(org.apache.ignite.cache.query.SqlFieldsQuery) 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