use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class IgniteWalRebalanceLoggingTest method checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg.
/**
* Test utility method.
*
* @param lsnrs Listeners to register with server logger.
* @throws Exception If failed.
*/
private void checkFollowingPartitionsWereReservedForPotentialHistoryRebalanceMsg(LogListener... lsnrs) throws Exception {
startGridsMultiThreaded(2).cluster().active(true);
IgniteCache<Integer, String> cache1 = createCache("cache1", "cache_group1");
IgniteCache<Integer, String> cache2 = createCache("cache2", "cache_group2");
for (int i = 0; i < KEYS_LOW_BORDER; i++) {
cache1.put(i, "abc" + i);
cache2.put(i, "abc" + i);
if (i % 20 == 0)
forceCheckpointAndRollOwerWal();
}
stopGrid(1);
for (int i = KEYS_LOW_BORDER; i < KEYS_UPPER_BORDER; i++) {
cache1.put(i, "abc" + i);
cache2.put(i, "abc" + i);
if (i % 20 == 0)
forceCheckpointAndRollOwerWal();
}
srvLog.clearListeners();
for (LogListener lsnr : lsnrs) srvLog.registerListener(lsnr);
startGrid(1);
awaitPartitionMapExchange(false, true, null);
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class TransactionSensitiveDataTest method checkSensitiveDataDuringExchange.
/**
* Receiving a log message "Partition release future:" during the exchange
* to check whether or not sensitive data is in printed transactions.
*
* @param check Check sensitive data in log message.
* @throws Exception If failed.
*/
private void checkSensitiveDataDuringExchange(BiConsumer<String, String> check) throws Exception {
assert nonNull(check);
IgniteEx crd = startGrids(NODE_COUNT);
awaitPartitionMapExchange();
AtomicReference<String> strToCheckRef = new AtomicReference<>();
LogListener logLsnr = LogListener.matches(logStr -> {
if (logStr.contains("Partition release future:") && currentThread().getName().contains(crd.name())) {
strToCheckRef.set(logStr);
return true;
}
return false;
}).build();
testLog.registerListener(logLsnr);
IgniteCache<Object, Object> cache = crd.getOrCreateCache(DEFAULT_CACHE_NAME).withKeepBinary();
IgniteBinary binary = crd.binary();
BinaryObject binKey = binary.toBinary(new Key(0));
BinaryObject binPerson = binary.toBinary(new Person(1, "name_1"));
cache.put(binKey, binPerson);
Transaction tx = crd.transactions().txStart();
cache.put(binKey, binPerson);
GridTestUtils.runAsync(() -> {
logLsnr.check(10 * crd.configuration().getNetworkTimeout());
tx.commit();
return null;
});
startGrid(NODE_COUNT);
check.accept(maskIdHash(strToCheckRef.get()), maskIdHash(toStr(binKey, Key.class)));
check.accept(maskIdHash(strToCheckRef.get()), maskIdHash(toStr(binPerson, Person.class)));
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class TcpDiscoveryIpFinderFailureTest method runClientNodeIpFinderFailureTest.
/**
*/
private void runClientNodeIpFinderFailureTest(long reconnectDelay) throws Exception {
List<LogListener> listeners = new ArrayList<>();
listeners.add(LogListener.matches("Failed to get registered addresses from IP " + "finder (retrying every " + reconnectDelay + "ms; change 'reconnectDelay' to configure " + "the frequency of retries) [maxTimeout=4000]").build());
listeners.add(LogListener.matches("Unable to get registered addresses from IP finder," + " timeout is reached (consider increasing 'joinTimeout' for join process or " + "'netTimeout' for reconnection) [joinTimeout=10000, netTimeout=4000]").build());
listeners.forEach(listeningLog::registerListener);
IgniteConfiguration cfgSrv = getConfigurationDynamicIpFinder("Server", false);
TcpDiscoverySpi discoverySpi = new TcpDiscoverySpi();
discoverySpi.setJoinTimeout(10000);
discoverySpi.setNetworkTimeout(4000);
discoverySpi.setReconnectDelay((int) reconnectDelay);
discoverySpi.setIpFinder(dynamicIpFinder);
IgniteConfiguration cfgClient = getConfigurationDynamicIpFinder("Client", true, discoverySpi);
IgniteEx crd = startGrid(cfgSrv);
IgniteEx client = startGrid(cfgClient);
waitForTopology(2);
dynamicIpFinder.breakService();
Ignition.stop(crd.name(), true);
CountDownLatch latch = new CountDownLatch(1);
client.events().localListen(event -> {
listeners.forEach(lsnr -> assertTrue(lsnr.check()));
latch.countDown();
return true;
}, EVT_CLIENT_NODE_DISCONNECTED);
assertTrue("Failed to wait for client node disconnected.", latch.await(6, SECONDS));
}
use of org.apache.ignite.testframework.LogListener 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());
}
use of org.apache.ignite.testframework.LogListener in project ignite by apache.
the class GridIndexRebuildTest method testPartialIndexRebuild.
/**
* We start several nodes, populate caches, then start replacing values. After that one node is killed, new index
* created. Finally, we restart the node, index rebuild starting after recovery. And we checke indexes by "validate
* indexes" task.
*/
@SuppressWarnings("unchecked")
@Test
public void testPartialIndexRebuild() throws Exception {
LogListener lsnr = LogListener.matches("B+Tree is corrupted").build();
listeningLog.registerListener(lsnr);
long start = System.currentTimeMillis();
IgniteEx grid1 = startGrids(4);
grid1.cluster().active(true);
final int accountCnt = 2048;
try (IgniteDataStreamer streamer = grid1.dataStreamer(SECOND_CACHE)) {
for (long i = 0; i < accountCnt; i++) streamer.addData(i, new Account(i));
streamer.flush();
}
AtomicBoolean stop = new AtomicBoolean();
IgniteCache<Object, Object> cache2 = grid1.cache(SECOND_CACHE);
new Thread(new Runnable() {
@Override
public void run() {
long i = 0;
while (!stop.get()) {
try {
if (i % 13 == 7)
cache2.put(i, new Account2(i));
else
cache2.put(i, new Account(i));
i++;
} catch (Throwable e) {
e.printStackTrace();
}
}
}
}).start();
long diff = System.currentTimeMillis() - start;
U.sleep(7500 - (diff % 5000));
stopGrid(3);
stop.set(true);
cache2.query(new SqlFieldsQuery("CREATE INDEX idx" + UUID.randomUUID().toString().replaceAll("-", "_") + " on Account (amount)")).getAll();
startGrid(3);
awaitPartitionMapExchange();
U.sleep(3_000);
ImmutableSet<UUID> nodes = ImmutableSet.of(grid(2).localNode().id(), grid(3).localNode().id());
VisorValidateIndexesTaskArg arg = new VisorValidateIndexesTaskArg(null, null, 10000, 1, true, true);
VisorTaskArgument<VisorValidateIndexesTaskArg> visorTaskArg = new VisorTaskArgument<>(nodes, arg, true);
ComputeTaskInternalFuture<VisorValidateIndexesTaskResult> execute = grid1.context().task().execute(new VisorValidateIndexesTask(), visorTaskArg);
VisorValidateIndexesTaskResult res = execute.get();
Map<UUID, VisorValidateIndexesJobResult> results = res.results();
boolean hasIssue = false;
for (VisorValidateIndexesJobResult jobResult : results.values()) {
System.err.println(jobResult);
hasIssue |= jobResult.hasIssues();
}
assertFalse(hasIssue);
assertFalse("B+Tree is corrupted.", lsnr.check());
}
Aggregations