Search in sources :

Example 11 with XLogUserFilterParam

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);
}
Also used : HashMap(java.util.HashMap) XLogFilter(org.apache.oozie.util.XLogFilter) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam)

Example 12 with XLogUserFilterParam

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"));
}
Also used : Services(org.apache.oozie.service.Services) HashMap(java.util.HashMap) XLogFilter(org.apache.oozie.util.XLogFilter) InputStream(java.io.InputStream) FileOutputStream(java.io.FileOutputStream) Properties(java.util.Properties) File(java.io.File) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam) Date(java.util.Date)

Example 13 with XLogUserFilterParam

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);
}
Also used : HashMap(java.util.HashMap) XLogFilter(org.apache.oozie.util.XLogFilter) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam)

Example 14 with XLogUserFilterParam

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);
}
Also used : HashMap(java.util.HashMap) XLogFilter(org.apache.oozie.util.XLogFilter) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam)

Example 15 with XLogUserFilterParam

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}"));
}
Also used : XLogFilter(org.apache.oozie.util.XLogFilter) HashMap(java.util.HashMap) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam)

Aggregations

XLogFilter (org.apache.oozie.util.XLogFilter)16 XLogUserFilterParam (org.apache.oozie.util.XLogUserFilterParam)16 HashMap (java.util.HashMap)12 File (java.io.File)9 FileOutputStream (java.io.FileOutputStream)9 InputStream (java.io.InputStream)9 Properties (java.util.Properties)9 Services (org.apache.oozie.service.Services)6 Date (java.util.Date)5 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 CommandException (org.apache.oozie.command.CommandException)1 XLogStreamingService (org.apache.oozie.service.XLogStreamingService)1 XLog (org.apache.oozie.util.XLog)1 XLogAuditFilter (org.apache.oozie.util.XLogAuditFilter)1 XLogStreamer (org.apache.oozie.util.XLogStreamer)1