use of com.yahoo.logserver.handlers.logmetrics.LogMetricsHandler in project vespa by vespa-engine.
the class LogMetricsTestCase method testLevelCountTotal.
/**
* Log some messages to the handler and verify that they are
* counted by the handler and that the count for each level is
* correct.
*/
@Test
public void testLevelCountTotal() throws java.io.IOException, InvalidLogFormatException {
LogMetricsHandler a = new LogMetricsHandler();
for (LogMessage aMsg : msg) {
a.handle(aMsg);
}
long count = a.getMetricsCount();
a.close();
// Not all messages are processes (debug and spam)
assertEquals(count, 7);
}
use of com.yahoo.logserver.handlers.logmetrics.LogMetricsHandler in project vespa by vespa-engine.
the class LogMetricsTestCase method testLevelCountAggregated.
/**
* Log some messages to the handler and verify that they are
* counted by the handler and that the count for each level is
* correct (the count for each host is summed into one count for
* each level).
*/
@Test
public void testLevelCountAggregated() throws java.io.IOException, InvalidLogFormatException {
LogMetricsHandler a = new LogMetricsHandler();
for (LogMessage aMsg : msg) {
a.handle(aMsg);
}
Map<String, Long> levelCount = a.getMetricsPerLevel();
assertEquals(levelCount.entrySet().size(), 5);
for (Map.Entry<String, Long> entry : levelCount.entrySet()) {
String key = entry.getKey();
if (key.equals("config")) {
assertEquals(entry.getValue(), new Long(1));
} else if (key.equals("info")) {
assertEquals(entry.getValue(), new Long(4));
} else if (key.equals("warning")) {
assertEquals(entry.getValue(), new Long(1));
} else if (key.equals("severe")) {
assertEquals(entry.getValue(), new Long(0));
} else if (key.equals("error")) {
assertEquals(entry.getValue(), new Long(1));
} else if (key.equals("fatal")) {
assertEquals(entry.getValue(), new Long(1));
} else if (key.equals("debug")) {
// always 0
assertEquals(entry.getValue(), new Long(0));
}
}
a.close();
}
Aggregations