use of org.apache.oozie.util.XLogFilter in project oozie by apache.
the class TestZKXLogStreamingService method testNoDashInConversionPattern.
public void testNoDashInConversionPattern() throws Exception {
XLogFilter.reset();
XLogFilter.defineParameter("USER");
XLogFilter.defineParameter("GROUP");
XLogFilter.defineParameter("TOKEN");
XLogFilter.defineParameter("APP");
XLogFilter.defineParameter("JOB");
XLogFilter.defineParameter("ACTION");
XLogFilter xf = new XLogFilter();
xf.setParameter("USER", "oozie");
xf.setLogLevel("DEBUG|INFO");
// Previously, a dash ("-") was always required somewhere in a line in order for that line to pass the filter; this test
// checks that this condition is no longer required for log streaming to work
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());
assertFalse(doStreamDisabledCheck());
LogFactory.getLog("a").info("2009-06-24 02:43:14,505 INFO _L1_:317 - SERVER[foo] USER[oozie] GROUP[oozie] TOKEN[-] APP[-] " + "JOB[-] ACTION[-] Released Lock");
LogFactory.getLog("a").info("2009-06-24 02:43:14,505 INFO _L2_:317 - SERVER[foo] USER[blah] GROUP[oozie] TOKEN[-] APP[-] " + "JOB[-] ACTION[-] Released Lock");
LogFactory.getLog("a").info("2009-06-24 02:43:14,505 INFO _L3_:317 SERVER[foo] USER[oozie] GROUP[oozie] TOKEN[-] APP[-] " + "JOB[-] ACTION[-] Released Lock");
LogFactory.getLog("a").info("2009-06-24 02:43:14,505 INFO _L4_:317 SERVER[foo] USER[blah] GROUP[oozie] TOKEN[-] APP[-] " + "JOB[-] ACTION[-] Released Lock");
String out = doStreamLog(xf);
String[] outArr = out.split("\n");
// Lines 2 and 4 are filtered out because they have the wrong user
assertEquals(2, outArr.length);
assertTrue(outArr[0].contains("_L1_"));
assertFalse(out.contains("_L2_"));
assertTrue(outArr[1].contains("_L3_"));
assertFalse(out.contains("_L4_"));
}
use of org.apache.oozie.util.XLogFilter in project oozie by apache.
the class TestXLogUserFilterParam method testsearchText_logLevel.
// Test text search with log level
public void testsearchText_logLevel() throws Exception {
setLogFile();
String param = XLogUserFilterParam.SEARCH_TEXT + "=substitution;" + XLogUserFilterParam.LOG_LEVEL + "=DEBUG";
Map<String, String[]> paramMap = new HashMap<String, String[]>();
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { param });
XLogFilter filter = new XLogFilter(new XLogUserFilterParam(paramMap));
String out = doStreamLog(filter);
String[] lines = out.split(System.getProperty("line.separator"));
assertEquals(lines.length, 1);
assertTrue(lines[0].contains("2014-02-27 02:06:47,499 DEBUG CoordActionStartXCommand:536 [pool-2-thread-236] - USER[-]"));
assertTrue(lines[0].contains("E0803: IO error, Variable substitution depth too large: 20 ${dniInputDir}"));
}
use of org.apache.oozie.util.XLogFilter 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.XLogFilter 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.XLogFilter 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);
}
Aggregations