use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class CacheDataRegionConfigurationTest method testWarningOnBaselineTopologyChange.
/**
* Verifies that warning is printed out to logs if after removing nodes from baseline
* some caches reach or cross dangerous limit of metainformation overhead per data region.
*
* @throws Exception If failed.
*/
@Test
public void testWarningOnBaselineTopologyChange() throws Exception {
DataRegionConfiguration defaultRegionCfg = new DataRegionConfiguration();
defaultRegionCfg.setInitialSize(DFLT_MEM_PLC_SIZE);
defaultRegionCfg.setMaxSize(DFLT_MEM_PLC_SIZE);
defaultRegionCfg.setPersistenceEnabled(true);
memCfg = new DataStorageConfiguration();
memCfg.setDefaultDataRegionConfiguration(defaultRegionCfg);
// one hour to guarantee that checkpoint will be triggered by 'dirty pages amount' trigger
memCfg.setCheckpointFrequency(60 * 60 * 1000);
ListeningTestLogger srv0Logger = new ListeningTestLogger(false, null);
LogListener cacheGrpLsnr0 = matches("Cache group 'default' brings high overhead").build();
srv0Logger.registerListener(cacheGrpLsnr0);
logger = srv0Logger;
IgniteEx ignite0 = startGrid("srv0");
ListeningTestLogger srv1Logger = new ListeningTestLogger(false, null);
LogListener cacheGrpLsnr1 = matches("Cache group 'default' brings high overhead").build();
srv1Logger.registerListener(cacheGrpLsnr1);
logger = srv1Logger;
startGrid("srv1");
ignite0.cluster().active(true);
ignite0.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME).setDataRegionName(defaultRegionCfg.getName()).setCacheMode(CacheMode.PARTITIONED).setAffinity(new RendezvousAffinityFunction(false, 512)));
assertFalse(cacheGrpLsnr0.check());
assertFalse(cacheGrpLsnr1.check());
stopGrid("srv1");
ignite0.cluster().baselineAutoAdjustEnabled(false);
long topVer = ignite0.cluster().topologyVersion();
ignite0.cluster().setBaselineTopology(topVer);
awaitPartitionMapExchange();
assertTrue(cacheGrpLsnr0.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class CacheDataRegionConfigurationTest method testNoFailNodeIfUnknownDataRegion.
/**
* Test checks that nodes will not fall if you receive a request
* to create a cache with an unknown data region.
*
* @throws Exception If failed.
*/
@Test
public void testNoFailNodeIfUnknownDataRegion() throws Exception {
failureHnd = new StopNodeOrHaltFailureHandler();
ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME);
memCfg = new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true));
LogListener logLsnr = matches("Possible failure suppressed accordingly to a configured handler").build();
logger = new ListeningTestLogger(false, log, logLsnr);
IgniteEx srvNode = startGrid(0);
String dataRegionName = "region";
IgniteConfiguration clientCfg = getConfiguration(getTestIgniteInstanceName(1)).setDataStorageConfiguration(new DataStorageConfiguration().setDataRegionConfigurations(new DataRegionConfiguration().setName(dataRegionName)).setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(true)));
IgniteEx clientNode = startClientGrid(optimize(clientCfg));
srvNode.cluster().active(true);
assertThrows(log, () -> {
clientNode.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + 1).setDataRegionName(dataRegionName));
return null;
}, CacheException.class, null);
assertThrows(log, () -> {
clientNode.getOrCreateCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + 1).setDataRegionName(UUID.randomUUID().toString()));
return null;
}, CacheException.class, null);
IgniteCache<Object, Object> cacheSrv = srvNode.cache(DEFAULT_CACHE_NAME);
IgniteCache<Object, Object> cacheClient = clientNode.cache(DEFAULT_CACHE_NAME);
cacheSrv.put(1, 1);
assertEquals(1, cacheSrv.get(1));
cacheClient.put(2, 2);
assertEquals(2, cacheClient.get(2));
assertFalse(logLsnr.check());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class ClusterStateOnStartPropertyTest method getConfiguration.
/**
* {@inheritDoc}
*/
@Override
protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception {
IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName).setClusterStateOnStart(state).setCacheConfiguration(new CacheConfiguration().setName(DEFAULT_CACHE_NAME)).setConsistentId(igniteInstanceName).setDataStorageConfiguration(new DataStorageConfiguration().setDefaultDataRegionConfiguration(new DataRegionConfiguration().setPersistenceEnabled(persistence)));
if (autoActivation != null)
cfg.setAutoActivationEnabled(autoActivation);
if (activeOnStart != null)
cfg.setActiveOnStart(activeOnStart);
// Warn messages must be printed only if both options (old and new) are presented.
if (autoActivation != null || activeOnStart != null) {
ListeningTestLogger testLog = new ListeningTestLogger(false, log);
LogListener lsnr = LogListener.matches(persistence ? "Property `autoActivation` will be ignored due to the property `clusterStateOnStart` is presented." : "Property `activeOnStart` will be ignored due to the property `clusterStateOnStart` is presented.").build();
testLog.registerListener(lsnr);
logListeners.put(igniteInstanceName, lsnr);
cfg.setGridLogger(testLog);
}
return cfg;
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridTransactionsSystemUserTimeMetricsTest method testSamplingLimit.
/**
* Tests transactions sampling with dumping 100% of transactions in log but limited by 2 dump records per second.
*
* @throws Exception If failed.
*/
@Test
public void testSamplingLimit() throws Exception {
logTxDumpLsnr.reset();
transactionDumpLsnr.reset();
int txCnt = 10;
int txDumpCnt = 2;
LogListener transactionDumpsSkippedLsnr = LogListener.matches("Transaction time dumps skipped because of log throttling: " + (txCnt - txDumpCnt)).build();
listeningTestLog.registerListener(transactionDumpsSkippedLsnr);
applyJmxParameters(null, 1.0, txDumpCnt);
// Wait for a second to reset hit counter.
doSleep(1000);
for (int i = 0; i < txCnt; i++) doInTransaction(client, txCallable);
// Wait for a second to reset hit counter.
doSleep(1000);
// One more sample to print information about skipped previous samples.
doInTransaction(client, txCallable);
assertTrue(logTxDumpLsnr.check());
assertTrue(transactionDumpLsnr.check());
assertTrue(transactionDumpsSkippedLsnr.check());
assertEquals(txDumpCnt + 1, transactionDumpLsnr.value());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridTransactionsSystemUserTimeMetricsTest method testLongTransactionDumpLimit.
/**
* Tests that tx time dumps appear in log correctly and after tx completion. Also checks that LRT dump
* now contains information about current system and user time.
*
* @throws Exception If failed.
*/
@Test
public void testLongTransactionDumpLimit() throws Exception {
logTxDumpLsnr.reset();
transactionDumpLsnr.reset();
int txCnt = 10;
List<String> txLogLines = new LinkedList<>();
txLogLines.add("First 10 long running transactions \\[total=" + txCnt + "\\]");
for (int i = 0; i < txCnt; i++) txLogLines.add(".*?>>> Transaction .*? systemTime=[0-4]{1,4}, userTime=[0-4]{1,4}.*");
LogListener lrtLogLsnr = new MessageOrderLogListener(txLogLines.toArray(new String[0]));
listeningTestLog.registerListener(lrtLogLsnr);
applyJmxParameters(5000L, null, txCnt);
doAsyncTransactions(client, txCnt, 5200);
doSleep(3000);
assertFalse(logTxDumpLsnr.check());
doSleep(3000);
assertTrue(logTxDumpLsnr.check());
assertTrue(transactionDumpLsnr.check());
assertTrue(lrtLogLsnr.check());
assertEquals(txCnt, transactionDumpLsnr.value());
}
Aggregations