Search in sources :

Example 56 with WithSystemProperty

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

the class IgniteWalRebalanceLoggingTest method testFullRebalanceWithShortCpHistoryLogMsgs.

/**
 * Test checks log messages in case of short history of checkpoint.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
@WithSystemProperty(key = IGNITE_PDS_WAL_REBALANCE_THRESHOLD, value = "1")
public void testFullRebalanceWithShortCpHistoryLogMsgs() throws Exception {
    LogListener expMsgsLsnr = LogListener.matches(str -> str.startsWith("Partitions were reserved, but maximum available counter is greater than " + "demanded or WAL contains too many updates: ") && str.contains("grp=cache_group1") && str.contains("grp=cache_group2")).andMatches(str -> str.startsWith("Starting rebalance routine") && (str.contains("cache_group1") || str.contains("cache_group2")) && str.contains("fullPartitions=[0-7], histPartitions=[]")).times(2).build();
    checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(expMsgsLsnr);
    assertTrue(expMsgsLsnr.check());
}
Also used : G(org.apache.ignite.internal.util.typedef.G) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) IGNITE_PDS_WAL_REBALANCE_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE) IgniteCache(org.apache.ignite.IgniteCache) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CURRENT_SEGMENT(org.apache.ignite.internal.pagemem.wal.record.RolloverType.CURRENT_SEGMENT) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 57 with WithSystemProperty

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

the class IgniteWalRebalanceLoggingTest method testHistoricalRebalanceLogMsg.

/**
 * Check that in case of Historical rebalance we log appropriate messages.
 * <p>
 *     <b>Steps:</b>
 *     <ol>
 *         <li>set IGNITE_PDS_WAL_REBALANCE_THRESHOLD to 1</li>
 *         <li>Start two nodes.</li>
 *         <li>Create two caches each in it's own cache group and populate them with some data.</li>
 *         <li>Stop second node and add more data to both caches.</li>
 *         <li>Wait checkpoint frequency * 2. This is required to guarantee that at least one checkpoint would be
 *         created.</li>
 *         <li>Start, previously stopped node and await for PME.</li>
 *     </ol>
 * <p>
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_WAL_REBALANCE_THRESHOLD, value = "1")
public void testHistoricalRebalanceLogMsg() throws Exception {
    LogListener expMsgsLsnr = LogListener.matches(str -> str.startsWith("Cache groups with earliest reserved checkpoint and a reason why a previous checkpoint was inapplicable:") && str.contains("cache_group1") && str.contains("cache_group2")).times(3).andMatches(str -> str.startsWith("Starting rebalance routine") && (str.contains("cache_group1") || str.contains("cache_group2")) && str.contains("fullPartitions=[], histPartitions=[0-7]")).times(2).build();
    LogListener unexpectedMessagesLsnr = LogListener.matches((str) -> str.startsWith("Partitions weren't present in any history reservation:") || str.startsWith("Partitions were reserved, but maximum available counter is greater than demanded:")).build();
    checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(expMsgsLsnr, unexpectedMessagesLsnr);
    assertTrue(expMsgsLsnr.check());
    assertFalse(unexpectedMessagesLsnr.check());
}
Also used : G(org.apache.ignite.internal.util.typedef.G) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) LogListener(org.apache.ignite.testframework.LogListener) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) IgniteEx(org.apache.ignite.internal.IgniteEx) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) IGNITE_PDS_WAL_REBALANCE_THRESHOLD(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_WAL_REBALANCE_THRESHOLD) WALPointer(org.apache.ignite.internal.processors.cache.persistence.wal.WALPointer) IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE) IgniteCache(org.apache.ignite.IgniteCache) RendezvousAffinityFunction(org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction) CheckpointRecord(org.apache.ignite.internal.pagemem.wal.record.CheckpointRecord) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) CURRENT_SEGMENT(org.apache.ignite.internal.pagemem.wal.record.RolloverType.CURRENT_SEGMENT) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) LogListener(org.apache.ignite.testframework.LogListener) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 58 with WithSystemProperty

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

the class WalArchiveSizeConfigurationTest method testIncorrectIgniteThresholdWalArchiveSizePercentageProperty.

/**
 * Check that if the {@link IgniteSystemProperties#IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE}
 * are set to more than 1.0, then there will be an error when starting the node.
 */
@Test
@WithSystemProperty(key = IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, value = "2")
public void testIncorrectIgniteThresholdWalArchiveSizePercentageProperty() {
    DataStorageConfiguration dsCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true));
    assertThrowsAnyCause(log, () -> startGrid(0, (IgniteConfiguration cfg) -> cfg.setDataStorageConfiguration(dsCfg)), IgniteCheckedException.class, "IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE must be less than or equal to 1.0");
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 59 with WithSystemProperty

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

the class WalCompactionNoArchiverTest method testNoCompressionErrors.

/**
 * Tests that attempts to compress WAL segment don't result with error.
 */
@Test
@WithSystemProperty(key = "IGNITE_WAL_COMPRESSOR_WORKER_THREAD_CNT", value = "1")
public void testNoCompressionErrors() throws Exception {
    IgniteEx ig = startGrid(0);
    ig.cluster().active(true);
    IgniteCache<Integer, byte[]> cache = ig.cache(CACHE_NAME);
    for (int i = 0; i < ENTRIES; i++) {
        // At least 20MB of raw data in total.
        final byte[] val = new byte[40000];
        val[i] = 1;
        cache.put(i, val);
    }
    stopAllGrids();
    ig = startGrid(0);
    cache = ig.cache(CACHE_NAME);
    for (int i = 0; i < ENTRIES; i++) {
        // At least 20MB of raw data in total.
        final byte[] val = new byte[40000];
        val[i] = 1;
        cache.put(i, val);
    }
    IgniteWriteAheadLogManager wal = ig.context().cache().context().wal();
    Object compressor = U.field(wal, "compressor");
    assertNotNull(compressor);
    Object error = U.field(compressor, "lastCompressionError");
    if (error != null)
        fail("Unexpected error in FileCompressor: " + error);
}
Also used : IgniteWriteAheadLogManager(org.apache.ignite.internal.pagemem.wal.IgniteWriteAheadLogManager) 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 60 with WithSystemProperty

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

the class FailureHandlingConfigurationTest method testOverridingBySysProps.

/**
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT, value = "80000")
@WithSystemProperty(key = IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT, value = "90000")
public void testOverridingBySysProps() throws Exception {
    sysWorkerBlockedTimeout = 1L;
    checkpointReadLockTimeout = 2L;
    IgniteEx ignite = startGrid(0);
    ignite.cluster().active(true);
    WorkersRegistry reg = ignite.context().workersRegistry();
    IgniteCacheDatabaseSharedManager dbMgr = ignite.context().cache().context().database();
    FailureHandlingMxBean mBean = getMBean();
    assertEquals(sysWorkerBlockedTimeout, ignite.configuration().getSystemWorkerBlockedTimeout());
    assertEquals(checkpointReadLockTimeout, ignite.configuration().getDataStorageConfiguration().getCheckpointReadLockTimeout());
    long workerPropVal = Long.getLong(IGNITE_SYSTEM_WORKER_BLOCKED_TIMEOUT);
    long checkpointPropVal = Long.getLong(IGNITE_CHECKPOINT_READ_LOCK_TIMEOUT);
    assertEquals(workerPropVal, reg.getSystemWorkerBlockedTimeout());
    assertEquals(checkpointPropVal, dbMgr.checkpointReadLockTimeout());
    assertEquals(workerPropVal, mBean.getSystemWorkerBlockedTimeout());
    assertEquals(checkpointPropVal, mBean.getCheckpointReadLockTimeout());
}
Also used : WorkersRegistry(org.apache.ignite.internal.worker.WorkersRegistry) FailureHandlingMxBean(org.apache.ignite.mxbean.FailureHandlingMxBean) IgniteEx(org.apache.ignite.internal.IgniteEx) IgniteCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.IgniteCacheDatabaseSharedManager) 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