use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class IgniteCacheDatabaseSharedManagerSelfTest method testCheckMinWalArchiveSize.
/**
* Checking the correctness of validation {@link DataStorageConfiguration#getMinWalArchiveSize()}.
*
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_THRESHOLD_WAL_ARCHIVE_SIZE_PERCENTAGE, value = "-1")
public void testCheckMinWalArchiveSize() throws Exception {
DataStorageConfiguration cfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)).setMaxWalArchiveSize(UNLIMITED_WAL_ARCHIVE);
for (long i : F.asList(10L, 100L, HALF_MAX_WAL_ARCHIVE_SIZE)) checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
int max = DFLT_WAL_SEGMENT_SIZE;
cfg.setMaxWalArchiveSize(max);
for (long i : F.asList(1L, 10L, HALF_MAX_WAL_ARCHIVE_SIZE, (long) max)) checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
for (long i : F.asList(max * 2, max * 3)) {
assertThrows(log, () -> {
checkWalArchiveSizeConfiguration(cfg.setMinWalArchiveSize(i), log);
return null;
}, IgniteCheckedException.class, null);
}
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class PerformanceStatisticsPropertiesTest method testFileMaxSize.
/**
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_PERF_STAT_FILE_MAX_SIZE, value = "" + TEST_FILE_MAX_SIZE)
public void testFileMaxSize() throws Exception {
long initLen = srv.context().cache().cacheDescriptors().values().stream().mapToInt(desc -> 1 + cacheStartRecordSize(desc.cacheName().getBytes().length, false)).sum();
long expOpsCnt = (TEST_FILE_MAX_SIZE - initLen) / (/*typeOp*/
1 + OperationType.cacheRecordSize());
startCollectStatistics();
for (int i = 0; i < expOpsCnt * 2; i++) srv.cache(DEFAULT_CACHE_NAME).get(i);
AtomicInteger opsCnt = new AtomicInteger();
stopCollectStatisticsAndRead(new TestHandler() {
@Override
public void cacheOperation(UUID nodeId, OperationType type, int cacheId, long startTime, long duration) {
opsCnt.incrementAndGet();
}
});
assertEquals(expOpsCnt, opsCnt.get());
long expLen = initLen + opsCnt.get() * (/*typeOp*/
1 + OperationType.cacheRecordSize());
List<File> files = statisticsFiles();
assertEquals(1, files.size());
long statFileLen = files.get(0).length();
assertEquals(expLen, statFileLen);
assertTrue(statFileLen <= TEST_FILE_MAX_SIZE);
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class PendingExchangeTest method testWithShortAfinityHistory.
/**
* Thats starts several caches in order to affinity history is exhausted.
*
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_AFFINITY_HISTORY_SIZE, value = "2")
public void testWithShortAfinityHistory() throws Exception {
createClusterWithPendingExchnageDuringRebalance((ignite, exchangeManager) -> {
GridCompoundFuture compFut = new GridCompoundFuture();
for (int i = 0; i < 20; i++) {
int finalNum = i;
compFut.add(GridTestUtils.runAsync(() -> ignite.createCache(DEFAULT_CACHE_NAME + "_new" + finalNum)));
}
compFut.markInitialized();
waitForExchnagesBegin(exchangeManager, 20);
return compFut;
});
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class TransactionsMXBeanImplTest method testChangeLongOperationsDumpTimeoutOnImmutableCluster.
/**
* Test to verify the correct change of {@link TransactionsMXBean#getLongOperationsDumpTimeout()}
* in an immutable cluster.
*
* @throws Exception If failed.
*/
@Test
@WithSystemProperty(key = IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, value = "100")
public void testChangeLongOperationsDumpTimeoutOnImmutableCluster() throws Exception {
Map<IgniteEx, TransactionsMXBean> allNodes = startGridAndActivate(2);
Map<IgniteEx, TransactionsMXBean> clientNodes = new HashMap<>();
Map<IgniteEx, TransactionsMXBean> srvNodes = new HashMap<>(allNodes);
clientNode = true;
for (int i = 2; i < 4; i++) {
IgniteEx igniteEx = startGrid(i);
TransactionsMXBean transactionsMXBean = txMXBean(i);
allNodes.put(igniteEx, transactionsMXBean);
clientNodes.put(igniteEx, transactionsMXBean);
}
// check for default value
checkPropertyValueViaTxMxBean(allNodes, 100L, TransactionsMXBean::getLongOperationsDumpTimeout);
// create property update latches for client nodes
Map<IgniteEx, List<CountDownLatch>> updateLatches = new HashMap<>();
clientNodes.keySet().forEach(ignite -> updateLatches.put(ignite, F.asList(new CountDownLatch(1), new CountDownLatch(1))));
clientNodes.forEach((igniteEx, bean) -> igniteEx.context().distributedMetastorage().listen((key) -> key.startsWith(DIST_CONF_PREFIX), (String key, Serializable oldVal, Serializable newVal) -> {
if ((long) newVal == 200)
updateLatches.get(igniteEx).get(0).countDown();
if ((long) newVal == 300)
updateLatches.get(igniteEx).get(1).countDown();
}));
long newTimeout = 200L;
// update value via server node
updatePropertyViaTxMxBean(allNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
// check new value in server nodes
checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
// check new value in client nodes
for (List<CountDownLatch> list : updateLatches.values()) {
CountDownLatch countDownLatch = list.get(0);
countDownLatch.await(100, TimeUnit.MILLISECONDS);
}
newTimeout = 300L;
// update value via server node
updatePropertyViaTxMxBean(clientNodes, TransactionsMXBean::setLongOperationsDumpTimeout, newTimeout);
// check new value in server nodes
checkPropertyValueViaTxMxBean(srvNodes, newTimeout, TransactionsMXBean::getLongOperationsDumpTimeout);
// check new value on client nodes
for (List<CountDownLatch> list : updateLatches.values()) {
CountDownLatch countDownLatch = list.get(1);
countDownLatch.await(100, TimeUnit.MILLISECONDS);
}
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class CacheMetricsManageTest method testTxContentionMetric.
/**
* Test correct metric for tx key contention.
*/
@Test
@WithSystemProperty(key = IGNITE_DUMP_TX_COLLISIONS_INTERVAL, value = "30000")
public void testTxContentionMetric() throws Exception {
Assume.assumeFalse("https://issues.apache.org/jira/browse/IGNITE-9224", MvccFeatureChecker.forcedMvcc());
backups = 1;
useTestCommSpi = true;
Ignite ig = startGridsMultiThreaded(2);
int contCnt = (int) U.staticField(IgniteTxManager.class, "COLLISIONS_QUEUE_THRESHOLD") * 20;
CountDownLatch txLatch = new CountDownLatch(contCnt * 2);
CountDownLatch txLatch0 = new CountDownLatch(contCnt * 2);
ig.cluster().active(true);
client = true;
Ignite cl = startGrid();
CacheConfiguration<?, ?> dfltCacheCfg = getCacheConfiguration();
dfltCacheCfg.setStatisticsEnabled(true);
String cacheName = dfltCacheCfg.getName();
IgniteCache<Integer, Integer> cache = ig.cache(cacheName);
IgniteCache<Integer, Integer> cache0 = cl.cache(cacheName);
CacheMetricsMXBean mxBeanCache = mxBean(0, cacheName, CacheLocalMetricsMXBeanImpl.class);
final List<Integer> priKeys = primaryKeys(cache, 3, 1);
final Integer backKey = backupKey(cache);
IgniteTransactions txMgr = cl.transactions();
CountDownLatch blockOnce = new CountDownLatch(1);
for (Ignite ig0 : G.allGrids()) {
TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
commSpi0.blockMessages(new IgniteBiPredicate<ClusterNode, Message>() {
@Override
public boolean apply(ClusterNode node, Message msg) {
if (msg instanceof GridNearTxPrepareResponse && blockOnce.getCount() > 0) {
blockOnce.countDown();
return true;
}
return false;
}
});
}
IgniteInternalFuture f = GridTestUtils.runAsync(() -> {
try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
cache0.put(priKeys.get(0), 0);
cache0.put(priKeys.get(2), 0);
tx.commit();
}
});
blockOnce.await();
GridCompoundFuture<?, ?> finishFut = new GridCompoundFuture<>();
for (int i = 0; i < contCnt; ++i) {
IgniteInternalFuture f0 = GridTestUtils.runAsync(() -> {
try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
cache0.put(priKeys.get(0), 0);
cache0.put(priKeys.get(1), 0);
txLatch0.countDown();
tx.commit();
txLatch.countDown();
}
try (Transaction tx = txMgr.txStart(PESSIMISTIC, READ_COMMITTED)) {
cache0.put(priKeys.get(2), 0);
cache0.put(backKey, 0);
txLatch0.countDown();
tx.commit();
txLatch.countDown();
}
});
finishFut.add(f0);
}
finishFut.markInitialized();
txLatch0.await();
for (Ignite ig0 : G.allGrids()) {
TestRecordingCommunicationSpi commSpi0 = (TestRecordingCommunicationSpi) ig0.configuration().getCommunicationSpi();
commSpi0.stopBlock();
}
IgniteTxManager txManager = ((IgniteEx) ig).context().cache().context().tm();
assertTrue(GridTestUtils.waitForCondition(new GridAbsPredicate() {
@Override
public boolean apply() {
try {
U.invoke(IgniteTxManager.class, txManager, "collectTxCollisionsInfo");
} catch (IgniteCheckedException e) {
fail(e.toString());
}
String coll = mxBeanCache.getTxKeyCollisions();
if (coll.contains("val=" + priKeys.get(2)) || coll.contains("val=" + priKeys.get(0)))
;
return true;
}
}, 10_000));
f.get();
finishFut.get();
txLatch.await();
}
Aggregations