use of org.apache.oozie.util.XLogUserFilterParam in project oozie by apache.
the class TestXLogUserFilterParam method testLength.
// test length
public void testLength() throws Exception {
setLogFile();
String logLevel = XLogUserFilterParam.LIMIT + "=1";
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { logLevel });
XLogFilter xf = new XLogFilter(new XLogUserFilterParam(paramMap));
String out = doStreamLog(xf);
String[] lines = out.split(System.getProperty("line.separator"));
assertEquals(lines.length, 1);
}
use of org.apache.oozie.util.XLogUserFilterParam in project oozie by apache.
the class TestXLogUserFilterParam method testStartEnd_EndOffset.
// Test start and end date, start as absolute
public void testStartEnd_EndOffset() throws Exception {
File log4jFile = new File(getTestCaseConfDir(), "test-log4j.properties");
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = cl.getResourceAsStream("test-no-dash-log4j.properties");
Properties log4jProps = new Properties();
log4jProps.load(is);
// prevent conflicts with other tests by changing the log file location
log4jProps.setProperty("log4j.appender.oozie.File", getTestCaseDir() + "/oozie.log");
log4jProps.store(new FileOutputStream(log4jFile), "");
setSystemProperty(XLogService.LOG4J_FILE, log4jFile.getName());
new Services().init();
XLogFilter.reset();
Map<String, String[]> paramMap = new HashMap<String, String[]>();
String param = "start=14-02-20 02:06:25,499;end=3m;debug";
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { param });
XLogFilter filter = new XLogFilter(new XLogUserFilterParam(paramMap));
// Param date will be overwritten by user param
String out = doStreamLog(filter, dt.parse("14-02-20 02:06:25,499"), new Date());
assertEquals(out.split(System.getProperty("line.separator")).length, 1);
assertTrue(out.split(System.getProperty("line.separator"))[0].contains("Log start time = Tue Feb 20 02:06:25"));
assertTrue(out.split(System.getProperty("line.separator"))[0].contains("Log end time = Tue Feb 20 02:11:25"));
}
use of org.apache.oozie.util.XLogUserFilterParam in project oozie by apache.
the class TestXLogUserFilterParam method testloglevel_ErrorWithLen.
// test log level with length
public void testloglevel_ErrorWithLen() throws Exception {
setLogFile();
String logLevel = XLogUserFilterParam.LOG_LEVEL + "=ERROR;" + XLogUserFilterParam.LIMIT + "=1";
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { logLevel });
XLogFilter xf = new XLogFilter(new XLogUserFilterParam(paramMap));
String out = doStreamLog(xf);
String[] lines = out.split(System.getProperty("line.separator"));
assertEquals(lines.length, 1);
}
use of org.apache.oozie.util.XLogUserFilterParam in project oozie by apache.
the class TestXLogUserFilterParam method testloglevel_Error.
public void testloglevel_Error() throws Exception {
setLogFile();
String logLevel = XLogUserFilterParam.LOG_LEVEL + "=ERROR";
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { logLevel });
XLogFilter xf = new XLogFilter(new XLogUserFilterParam(paramMap));
String out = doStreamLog(xf);
int count = 0;
for (String line : out.split(System.getProperty("line.separator"))) {
assertFalse(line.contains("DEBUG"));
assertFalse(line.contains("INFO"));
count++;
}
assertEquals(count, 20);
}
use of org.apache.oozie.util.XLogUserFilterParam in project oozie by apache.
the class TestXLogUserFilterParam method testTextSearch.
// Test text search
public void testTextSearch() throws Exception {
setLogFile();
XLogFilter filter = new XLogFilter();
String param = XLogUserFilterParam.SEARCH_TEXT + "=substitution;" + XLogUserFilterParam.LIMIT + "=2";
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { param });
XLogUserFilterParam logUtil = new XLogUserFilterParam(paramMap);
filter.setUserLogFilter(logUtil);
String out = doStreamLog(filter);
String[] lines = out.split(System.getProperty("line.separator"));
assertEquals(lines.length, 2);
assertTrue(lines[0].contains("E0803: IO error, Variable substitution depth too large: 20 ${dniInputDir}"));
assertTrue(lines[1].contains("E0803: IO error, Variable substitution depth too large: 20 ${dniInputDir}"));
}
Aggregations