use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class BasicIndexTest method testInlineSizeChange.
/**
*/
@Test
@WithSystemProperty(key = IGNITE_THROTTLE_INLINE_SIZE_CALCULATION, value = "1")
public void testInlineSizeChange() throws Exception {
isPersistenceEnabled = true;
indexes = Collections.singletonList(new QueryIndex("valStr"));
inlineSize = 33;
srvLog = new ListeningTestLogger(false, log);
String msg1 = "curSize=1";
String msg2 = "curSize=2";
String msg3 = "curSize=3";
LogListener lstn1 = LogListener.matches(msg1).build();
LogListener lstn2 = LogListener.matches(msg2).build();
LogListener lstn3 = LogListener.matches(msg3).build();
srvLog.registerListener(lstn1);
srvLog.registerListener(lstn2);
srvLog.registerListener(lstn3);
IgniteEx ig0 = startGrid(0);
ig0.cluster().active(true);
populateCache();
IgniteCache<Key, Val> cache = grid(0).cache(DEFAULT_CACHE_NAME);
execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 1 PARALLEL 28");
List<List<?>> res = execSql(cache, "explain select * from Val where valLong > ?", 10);
log.info("exp: " + res.get(0).get(0));
assertTrue(lstn1.check());
execSql(cache, "drop index \"idx1\"");
execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 2 PARALLEL 28");
execSql(cache, "explain select * from Val where valLong > ?", 10);
assertTrue(lstn2.check());
execSql(cache, "drop index \"idx1\"");
stopAllGrids();
ig0 = startGrid(0);
ig0.cluster().active(true);
cache = ig0.cache(DEFAULT_CACHE_NAME);
execSql(cache, "create index \"idx1\" on Val(valLong) INLINE_SIZE 3 PARALLEL 28");
execSql(cache, "explain select * from Val where valLong > ?", 10);
assertTrue(lstn3.check());
stopAllGrids();
cleanPersistenceDir();
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class IgniteWithoutArchiverWalIteratorInvalidCrcTest method nodeShouldStartIfLogicalRecordCorruptedAfterCheckpointOrWalStart.
/**
* A logical record was corrupted or just doesn't exist because the end of wal is reached, after start checkpoint without end.
* -----||------||----X----> OR ----X----->
* We recover all before it, and start the node.
*/
@Test
@WithSystemProperty(key = GridCacheDatabaseSharedManager.IGNITE_PDS_SKIP_CHECKPOINT_ON_NODE_STOP, value = "true")
public void nodeShouldStartIfLogicalRecordCorruptedAfterCheckpointOrWalStart() throws Exception {
startNodeAndPopulate();
stopGrid(0);
IgniteWriteAheadLogManager walMgr = ignite.context().cache().context().wal();
File walDir = U.field(walMgr, "walWorkDir");
IgniteWalIteratorFactory iterFactory = new IgniteWalIteratorFactory();
List<FileDescriptor> walFiles = getWalFiles(walDir, iterFactory);
FileDescriptor lastWalFile = walFiles.get(walFiles.size() - 1);
List<WALPointer> pointers = WalTestUtils.getPointers(lastWalFile, iterFactory, LOGICAL);
WalTestUtils.corruptWalSegmentFile(lastWalFile, pointers.get(pointers.size() - 1));
IgniteEx ex = startGrid(0);
ex.cluster().active(true);
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class IgniteWalReaderTest method testRebalanceFlag.
/**
* Tests transaction generation and WAL for putAll cache operation.
*
* @throws Exception if failed.
*/
@Test
@WithSystemProperty(key = IgniteSystemProperties.IGNITE_DISABLE_WAL_DURING_REBALANCING, value = "false")
public void testRebalanceFlag() throws Exception {
backupCnt = 1;
IgniteEx ignite = startGrid("node0");
Ignite ignite1 = startGrid(1);
ignite.cluster().state(ACTIVE);
IgniteCache<Integer, IndexedObject> cache = ignite.cache(CACHE_NAME);
int cntEntries = 100;
List<Integer> keys = findKeys(ignite.localNode(), cache, cntEntries, 0, 0);
Map<Integer, IndexedObject> map = new TreeMap<>();
for (Integer key : keys) map.putIfAbsent(key, new IndexedObject(key));
cache.putAll(map);
Ignite ignite2 = startGrid(2);
ignite.cluster().setBaselineTopology(ignite2.cluster().topologyVersion());
backupCnt = 0;
awaitPartitionMapExchange(false, true, null);
String subfolderName1 = genDbSubfolderName(ignite, 0);
String subfolderName2 = genDbSubfolderName(ignite1, 1);
String subfolderName3 = genDbSubfolderName(ignite2, 2);
stopAllGrids();
String workDir = U.defaultWorkDirectory();
IgniteWalIteratorFactory factory = new IgniteWalIteratorFactory(log);
Map<GridCacheOperation, Integer> operationsFound = new EnumMap<>(GridCacheOperation.class);
IgniteInClosure<DataRecord> drHnd = dataRecord -> {
for (int i = 0; i < dataRecord.entryCount(); i++) {
DataEntry entry = dataRecord.get(i);
GridCacheOperation op = entry.op();
Integer cnt = operationsFound.get(op);
operationsFound.put(op, cnt == null ? 1 : (cnt + 1));
}
};
scanIterateAndCount(factory, createIteratorParametersBuilder(workDir, subfolderName1).filesOrDirs(workDir + "/db/wal/" + subfolderName1, workDir + "/db/wal/archive/" + subfolderName1), 1, 1, null, drHnd);
primary = false;
scanIterateAndCount(factory, createIteratorParametersBuilder(workDir, subfolderName2).filesOrDirs(workDir + "/db/wal/" + subfolderName2, workDir + "/db/wal/archive/" + subfolderName2), 1, 1, null, drHnd);
rebalance = true;
scanIterateAndCount(factory, createIteratorParametersBuilder(workDir, subfolderName3).filesOrDirs(workDir + "/db/wal/" + subfolderName3, workDir + "/db/wal/archive/" + subfolderName3), 1, 0, null, drHnd);
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class IgniteWalRebalanceLoggingTest method testFullRebalanceLogMsgs.
/**
* Check that in case of Full rebalance we log appropriate messages.
* <p>
* <b>Steps:</b>
* <ol>
* <li>restore IGNITE_PDS_WAL_REBALANCE_THRESHOLD to default 500000</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 = "500000")
public void testFullRebalanceLogMsgs() throws Exception {
LogListener expMsgsLsnr = LogListener.matches("Partitions weren't present in any history reservation: " + "[[grp=cache_group2 part=[[0-7]]], [grp=cache_group1 part=[[0-7]]]]").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());
}
use of org.apache.ignite.testframework.junits.WithSystemProperty in project ignite by apache.
the class TcpDiscoveryMetricsWarnLogTest method testMetricsWarningLog.
/**
* Test checks that the desired message occurs in logs.
*
* @throws Exception If any error occurs.
*/
@Test
@WithSystemProperty(key = IGNITE_DISCOVERY_METRICS_QNT_WARN, value = "20")
public void testMetricsWarningLog() throws Exception {
testLog.warning("IGNITE_DISCOVERY_METRICS_QNT_WARN = " + System.getProperty(IGNITE_DISCOVERY_METRICS_QNT_WARN));
LogListener logLsnr0 = LogListener.matches(LOG_MSG).andMatches("TcpDiscoveryMetricsWarnLogTest0").atLeast(1).build();
LogListener logLsnr1 = LogListener.matches(LOG_MSG).andMatches("TcpDiscoveryMetricsWarnLogTest1").atLeast(1).build();
LogListener logLsnr2 = LogListener.matches(LOG_MSG).andMatches("TcpDiscoveryMetricsWarnLogTest2").atLeast(1).build();
testLog.registerListener(logLsnr0);
testLog.registerListener(logLsnr1);
testLog.registerListener(logLsnr2);
Ignite ignite0 = startGrid(0);
startGrid(1);
startClientGrid(2);
for (int i = 1; i <= 30; i++) createAndFillCache(i, ignite0);
awaitMetricsUpdate(3);
assertTrue(logLsnr0.check());
assertTrue(logLsnr1.check());
assertTrue(logLsnr2.check());
}
Aggregations