Search in sources :

Example 21 with XLogFilter

use of org.apache.oozie.util.XLogFilter 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 22 with XLogFilter

use of org.apache.oozie.util.XLogFilter 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)

Example 23 with XLogFilter

use of org.apache.oozie.util.XLogFilter in project oozie by apache.

the class TestXLogUserFilterParam method testloglevel_DEBUF_INFO.

// Test multiple log level
public void testloglevel_DEBUF_INFO() throws Exception {
    setLogFile();
    String logLevel = XLogUserFilterParam.LOG_LEVEL + "=DEBUG|INFO";
    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, 4);
    assertTrue(lines[1].startsWith("2014-02-27 02:06:49,215 DEBUG CoordActionStartXCommand:545 [pool-2-thread-236] - USER[-] GROUP[-] " + "TOKEN[-] APP[-]"));
    assertTrue(lines[2].startsWith("2014-02-27 02:06:49,215 DEBUG CoordActionStartXCommand:545 [pool-2-thread-236] - USER[-] GROUP[-] " + "TOKEN[-] APP[-] JOB[0601839-140127221758655-oozie-wrkf-C]"));
    assertTrue(lines[3].startsWith("2014-02-27 02:06:49,215 INFO CoordActionStartXCommand:545 [pool-2-thread-236] - USER[-] GROUP[-] " + "TOKEN[-] APP[-] JOB[0601839-140127221758655-oozie-wrkf-C]"));
}
Also used : HashMap(java.util.HashMap) XLogFilter(org.apache.oozie.util.XLogFilter) XLogUserFilterParam(org.apache.oozie.util.XLogUserFilterParam)

Aggregations

XLogFilter (org.apache.oozie.util.XLogFilter)23 XLogUserFilterParam (org.apache.oozie.util.XLogUserFilterParam)16 File (java.io.File)15 FileOutputStream (java.io.FileOutputStream)15 InputStream (java.io.InputStream)15 Properties (java.util.Properties)15 HashMap (java.util.HashMap)13 Date (java.util.Date)9 Services (org.apache.oozie.service.Services)6 FileWriter (java.io.FileWriter)3 EmbeddedServletContainer (org.apache.oozie.test.EmbeddedServletContainer)3 XLogStreamingService (org.apache.oozie.service.XLogStreamingService)2 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 LinkedHashSet (java.util.LinkedHashSet)1 List (java.util.List)1 CoordinatorAction (org.apache.oozie.client.CoordinatorAction)1 CommandException (org.apache.oozie.command.CommandException)1 DagXLogInfoService (org.apache.oozie.service.DagXLogInfoService)1