use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.
the class LongJVMPauseDetectorTest method testStopWorkerThread.
/**
* @throws Exception If failed.
*/
@Test
public void testStopWorkerThread() throws Exception {
strLog = new GridStringLogger(true);
strLog.logLength(300_000);
startGrid(0);
stopGrid(0);
String log = strLog.toString();
assertFalse(log.contains("jvm-pause-detector-worker has been interrupted."));
assertTrue(log.contains("jvm-pause-detector-worker has been stopped."));
}
use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.
the class IgniteMassLoadSandboxTest method testCoveredWalLogged.
/**
* Test that WAL segments that are fully covered by checkpoint are logged
*
* @throws Exception if failed.
*/
@Test
public void testCoveredWalLogged() throws Exception {
GridStringLogger log0 = null;
try {
log0 = new GridStringLogger();
final IgniteConfiguration cfg = getConfiguration("testCoveredWalLogged");
cfg.setGridLogger(log0);
cfg.getDataStorageConfiguration().setWalAutoArchiveAfterInactivity(10);
final Ignite ignite = G.start(cfg);
ignite.cluster().active(true);
final IgniteCache<Object, Object> cache = ignite.cache(CACHE_NAME);
cache.put(1, new byte[cfg.getDataStorageConfiguration().getWalSegmentSize() - 1024]);
forceCheckpoint();
cache.put(1, new byte[cfg.getDataStorageConfiguration().getWalSegmentSize() - 1024]);
forceCheckpoint();
cache.put(1, new byte[cfg.getDataStorageConfiguration().getWalSegmentSize() - 1024]);
forceCheckpoint();
// needed by GridStringLogger
Thread.sleep(200);
final String log = log0.toString();
final String[] lines = log.split("\\r?\\n");
final Pattern chPtrn = Pattern.compile("Checkpoint finished");
final Pattern idxPtrn = Pattern.compile("idx=([0-9]+),");
final Pattern covererdPtrn = Pattern.compile("walSegmentsCovered=\\[(.+)\\], ");
boolean hasCheckpoint = false;
long nextCovered = 0;
for (String line : lines) {
if (!chPtrn.matcher(line).find())
continue;
hasCheckpoint = true;
final Matcher idxMatcher = idxPtrn.matcher(line);
assertTrue(idxMatcher.find());
final long idx = Long.valueOf(idxMatcher.group(1));
final Matcher coveredMatcher = covererdPtrn.matcher(line);
if (!coveredMatcher.find()) {
// no wal segments are covered by checkpoint
assertEquals(nextCovered, idx);
continue;
}
final String coveredMatcherGrp = coveredMatcher.group(1);
final long[] covered = !coveredMatcherGrp.isEmpty() ? Arrays.stream(coveredMatcherGrp.split(" - ")).mapToLong(e -> Integer.valueOf(e.trim())).toArray() : new long[0];
assertEquals(nextCovered, covered[0]);
final long lastCovered = covered[covered.length - 1];
// current wal is excluded
assertEquals(idx - 1, lastCovered);
nextCovered = lastCovered + 1;
}
assertTrue(hasCheckpoint);
} finally {
System.out.println(log0 != null ? log0.toString() : "Error initializing GridStringLogger");
stopAllGrids();
}
}
use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.
the class IgniteDevOnlyLogTest method testDevOnlyQuietMessage.
/**
* Check that dev-only messages appear in the log.
*/
@Ignore("https://issues.apache.org/jira/browse/IGNITE-9328")
@Test
public void testDevOnlyQuietMessage() throws Exception {
additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=true");
log = new GridStringLogger(false, grid(0).log());
Ignite ignite = startGrid(1);
String msg = getMessage(ignite);
warnDevOnly(msg);
assertTrue(log.toString().contains(msg));
}
use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.
the class IgniteDevOnlyLogTest method testDevOnlyVerboseMessage.
/**
* Check that dev-only messages appear in the log.
*/
@Test
public void testDevOnlyVerboseMessage() throws Exception {
additionalArgs = Collections.singletonList("-D" + IgniteSystemProperties.IGNITE_QUIET + "=false");
log = new GridStringLogger(false, grid(0).log());
Ignite ignite = startGrid(1);
String msg = getMessage(ignite);
warnDevOnly(msg);
assertTrue(log.toString().contains(msg));
}
use of org.apache.ignite.testframework.GridStringLogger in project ignite by apache.
the class IgniteDiagnosticMessagesTest method checkRemoteTx.
/**
* @param atomicityMode Cache atomicity mode.
* @throws Exception If failed.
*/
public void checkRemoteTx(CacheAtomicityMode atomicityMode) throws Exception {
int timeout = 3500;
System.setProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT, String.valueOf(timeout));
try {
testSpi = true;
startGrid(0);
GridStringLogger strLog = this.strLog = new GridStringLogger();
strLog.logLength(1024 * 100);
startGrid(1);
awaitPartitionMapExchange();
CacheConfiguration ccfg = cacheConfiguration(atomicityMode).setBackups(1);
if (atomicityMode != TRANSACTIONAL_SNAPSHOT || MvccFeatureChecker.isSupported(MvccFeatureChecker.Feature.NEAR_CACHE))
ccfg.setNearConfiguration(new NearCacheConfiguration<>());
final Ignite node0 = ignite(0);
final Ignite node1 = ignite(1);
node0.createCache(ccfg);
UUID id0 = node0.cluster().localNode().id();
TestRecordingCommunicationSpi.spi(node0).blockMessages(GridDhtTxPrepareResponse.class, node1.name());
int txCnt = 4;
final List<Integer> keys = primaryKeys(node1.cache(DEFAULT_CACHE_NAME), txCnt, 0);
final AtomicInteger idx = new AtomicInteger();
IgniteInternalFuture<Long> fut = GridTestUtils.runMultiThreadedAsync(new Callable<Void>() {
@Override
public Void call() throws Exception {
IgniteCache<Object, Object> cache = node1.cache(DEFAULT_CACHE_NAME);
try (Transaction tx = node1.transactions().txStart()) {
Integer key = keys.get(idx.getAndIncrement());
cache.getAndPut(key, "new-" + key);
tx.commit();
}
return null;
}
}, txCnt, "tx");
U.sleep(timeout * 2);
assertFalse(fut.isDone());
TestRecordingCommunicationSpi.spi(node0).stopBlock();
fut.get();
String log = strLog.toString();
assertTrue(log.contains("Related transactions ["));
assertTrue(log.contains("General node info [id=" + id0));
} finally {
System.clearProperty(IGNITE_LONG_OPERATIONS_DUMP_TIMEOUT);
}
}
Aggregations