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());
}
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);
}
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());
}
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);
}
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));
}
Aggregations