Search in sources :

Example 61 with WithSystemProperty

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

the class ConsistentIdImplicitlyExplicitlyTest method testConsistentIdConfiguredInJvmProp.

/**
 * Consistent ID is not configured in the {@link IgniteConfiguration}, but set in the JVM property.
 *
 * @throws Exception if failed.
 */
@Test
@WithSystemProperty(key = IGNITE_OVERRIDE_CONSISTENT_ID, value = "JvmProp consistent id")
public void testConsistentIdConfiguredInJvmProp() throws Exception {
    String specificConsistentId = System.getProperty(IGNITE_OVERRIDE_CONSISTENT_ID);
    LogListener lsnr = expectLogEvent(WARN_MESSAGE, 0);
    Ignite ignite = startGrid(0);
    assertEquals(specificConsistentId, ignite.configuration().getConsistentId());
    assertEquals(specificConsistentId, ignite.cluster().localNode().consistentId());
    assertTrue(lsnr.check());
    info("Consistent ID: " + ignite.cluster().localNode().consistentId());
}
Also used : LogListener(org.apache.ignite.testframework.LogListener) Ignite(org.apache.ignite.Ignite) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 62 with WithSystemProperty

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

the class WalDeletionArchiveAbstractTest method testCorrectDeletedCheckpointHistoryButKeepWalFiles.

/**
 * Correct delete checkpoint history from memory depends on IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE.
 * WAL files doesn't delete because deleting was disabled.
 */
@Test
@WithSystemProperty(key = IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE, value = "2")
public void testCorrectDeletedCheckpointHistoryButKeepWalFiles() throws Exception {
    // given: configured grid with disabled WAL removing.
    Ignite ignite = startGrid(dbCfg -> dbCfg.setMaxWalArchiveSize(DataStorageConfiguration.UNLIMITED_WAL_ARCHIVE));
    GridCacheDatabaseSharedManager dbMgr = gridDatabase(ignite);
    CheckpointHistory hist = dbMgr.checkpointHistory();
    assertNotNull(hist);
    IgniteCache<Integer, Object> cache = ignite.getOrCreateCache(cacheConfiguration());
    // when: put to cache
    for (int i = 0; i < 500; i++) {
        cache.put(i, i);
        if (i % 10 == 0)
            forceCheckpoint();
    }
    forceCheckpoint();
    // then: WAL files was not deleted but some of checkpoint history was deleted.
    FileWriteAheadLogManager wal = wal(ignite);
    assertNull(getFieldValueHierarchy(wal, "cleaner"));
    FileDescriptor[] files = wal.walArchiveFiles();
    assertTrue(Stream.of(files).anyMatch(desc -> desc.file().getName().endsWith("0001.wal")));
    assertTrue(hist.checkpoints().size() == 2);
}
Also used : CacheAtomicityMode(org.apache.ignite.cache.CacheAtomicityMode) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) Arrays(java.util.Arrays) GridTestUtils.waitForCondition(org.apache.ignite.testframework.GridTestUtils.waitForCondition) ClusterState(org.apache.ignite.cluster.ClusterState) U(org.apache.ignite.internal.util.typedef.internal.U) IgniteEx(org.apache.ignite.internal.IgniteEx) IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE(org.apache.ignite.IgniteSystemProperties.IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) GridTestUtils.getFieldValueHierarchy(org.apache.ignite.testframework.GridTestUtils.getFieldValueHierarchy) DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) Checkpointer(org.apache.ignite.internal.processors.cache.persistence.checkpoint.Checkpointer) WALMode(org.apache.ignite.configuration.WALMode) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) Collection(java.util.Collection) Test(org.junit.Test) Ignite(org.apache.ignite.Ignite) IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE(org.apache.ignite.IgniteSystemProperties.IGNITE_PDS_MAX_CHECKPOINT_MEMORY_HISTORY_SIZE) File(java.io.File) IgniteCache(org.apache.ignite.IgniteCache) Consumer(java.util.function.Consumer) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) Stream(java.util.stream.Stream) CacheConfiguration(org.apache.ignite.configuration.CacheConfiguration) GB(org.apache.ignite.internal.util.IgniteUtils.GB) MB(org.apache.ignite.internal.util.IgniteUtils.MB) KB(org.apache.ignite.internal.util.IgniteUtils.KB) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GridCacheDatabaseSharedManager(org.apache.ignite.internal.processors.cache.persistence.GridCacheDatabaseSharedManager) CheckpointHistory(org.apache.ignite.internal.processors.cache.persistence.checkpoint.CheckpointHistory) FileWriteAheadLogManager(org.apache.ignite.internal.processors.cache.persistence.wal.FileWriteAheadLogManager) Ignite(org.apache.ignite.Ignite) FileDescriptor(org.apache.ignite.internal.processors.cache.persistence.wal.FileDescriptor) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 63 with WithSystemProperty

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

the class WalDeletionArchiveAbstractTest method testSingleCleanWalArchive.

/**
 * Checks that the deletion of WAL segments occurs with the maximum number of segments.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_CHECKPOINT_TRIGGER_ARCHIVE_SIZE_PERCENTAGE, value = "1000")
public void testSingleCleanWalArchive() throws Exception {
    IgniteConfiguration cfg = getConfiguration(getTestIgniteInstanceName(0)).setCacheConfiguration(cacheConfiguration()).setDataStorageConfiguration(new DataStorageConfiguration().setCheckpointFrequency(Long.MAX_VALUE).setMaxWalArchiveSize(5 * MB).setWalSegmentSize((int) MB).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true).setMaxSize(GB).setCheckpointPageBufferSize(GB)));
    ListeningTestLogger listeningLog = new ListeningTestLogger(cfg.getGridLogger());
    cfg.setGridLogger(listeningLog);
    IgniteEx n = startGrid(cfg);
    n.cluster().state(ClusterState.ACTIVE);
    awaitPartitionMapExchange();
    for (int i = 0; walArchiveSize(n) < 20L * cfg.getDataStorageConfiguration().getWalSegmentSize(); ) n.cache(DEFAULT_CACHE_NAME).put(i++, new byte[(int) (512 * KB)]);
    assertEquals(-1, wal(n).lastTruncatedSegment());
    assertEquals(0, gridDatabase(n).lastCheckpointMarkWalPointer().index());
    Collection<String> logStrs = new ConcurrentLinkedQueue<>();
    listeningLog.registerListener(logStr -> {
        if (logStr.contains("Finish clean WAL archive"))
            logStrs.add(logStr);
    });
    forceCheckpoint();
    long maxWalArchiveSize = cfg.getDataStorageConfiguration().getMaxWalArchiveSize();
    assertTrue(waitForCondition(() -> walArchiveSize(n) < maxWalArchiveSize, getTestTimeout()));
    assertEquals(logStrs.toString(), 1, logStrs.size());
}
Also used : DataStorageConfiguration(org.apache.ignite.configuration.DataStorageConfiguration) DataRegionConfiguration(org.apache.ignite.configuration.DataRegionConfiguration) IgniteConfiguration(org.apache.ignite.configuration.IgniteConfiguration) IgniteEx(org.apache.ignite.internal.IgniteEx) ListeningTestLogger(org.apache.ignite.testframework.ListeningTestLogger) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GridCommonAbstractTest(org.apache.ignite.testframework.junits.common.GridCommonAbstractTest) Test(org.junit.Test) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 64 with WithSystemProperty

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

the class GridTcpCommunicationSpiConfigSelfTest method testNotEmptyHostNameAttr.

/**
 * Test checks that attribute {@link TcpCommunicationSpi#ATTR_HOST_NAMES} is not empty.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = IGNITE_TCP_COMM_SET_ATTR_HOST_NAMES, value = "true")
public void testNotEmptyHostNameAttr() throws Exception {
    InetSocketAddress inetSockAddr = new InetSocketAddress(0);
    String ip = inetSockAddr.getHostName();
    String host = U.resolveLocalAddresses(inetSockAddr.getAddress()).get2().iterator().next();
    log.info("Testing ip=" + ip + " host=" + host);
    int nodeIdx = 0;
    locHost = ip;
    checkHostNamesAttr(startGrid(nodeIdx++), false, false);
    locHost = host;
    checkHostNamesAttr(startGrid(nodeIdx++), false, false);
    locHost = null;
    checkHostNamesAttr(startGrid(nodeIdx++), true, false);
}
Also used : InetSocketAddress(java.net.InetSocketAddress) GridSpiTest(org.apache.ignite.testframework.junits.spi.GridSpiTest) GridAbstractTest(org.apache.ignite.testframework.junits.GridAbstractTest) Test(org.junit.Test) GridSpiAbstractConfigTest(org.apache.ignite.testframework.junits.spi.GridSpiAbstractConfigTest) WithSystemProperty(org.apache.ignite.testframework.junits.WithSystemProperty)

Example 65 with WithSystemProperty

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

the class TcpCommunicationSpiMultiJvmTest method testIPv6NodeSuccessfullyConnectesToNodeWithIPv4Only.

/**
 * Verifies that node supporting IPv6 successfully connects and communicates with node
 * supporting IPv4 only.
 *
 * @throws Exception If failed.
 */
@Test
@WithSystemProperty(key = "java.net.preferIPv4Stack", value = "true")
public void testIPv6NodeSuccessfullyConnectesToNodeWithIPv4Only() throws Exception {
    remoteNodePrefersIPv4 = false;
    replacingAttrSpi = false;
    IgniteEx ig = startGrid(0);
    replacingAttrSpi = true;
    localAddrStr = "127.0.0.1";
    externalAddr = new InetSocketAddress("127.0.0.1", 45010);
    startGrid(1);
    AtomicBoolean cacheCreatedAndLoaded = createAndLoadCacheAsync(ig);
    assertTrue(GridTestUtils.waitForCondition(cacheCreatedAndLoaded::get, 10_000));
}
Also used : AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) InetSocketAddress(java.net.InetSocketAddress) 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)

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