use of org.apache.oozie.service.Services in project oozie by apache.
the class TestTimestampedMessageParser method setUp.
@Override
protected void setUp() throws Exception {
super.setUp();
services = new Services();
services.init();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestXConfiguration method testSubstituteVarUnlimited.
public void testSubstituteVarUnlimited() throws ServiceException {
Services services = new Services();
services.get(ConfigurationService.class).getConf().set(XConfiguration.CONFIGURATION_SUBSTITUTE_DEPTH, "-1");
services.init();
int depth = ConfigurationService.getInt(XConfiguration.CONFIGURATION_SUBSTITUTE_DEPTH);
assertEquals(-1, depth);
XConfiguration.initalized = false;
XConfiguration conf = new XConfiguration();
conf.set("key0", "hello");
int testMax = 100;
for (int i = 1; i < testMax + 5; i++) {
// key1, ${key0}
conf.set(String.valueOf("key" + i), String.valueOf("${key" + (i - 1) + "}"));
}
assertEquals("hello", conf.get("key0"));
assertEquals("hello", conf.get("key1"));
assertEquals("hello", conf.get("key" + (testMax - 1)));
services.destroy();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestXConfiguration method testSubstituteVar.
public void testSubstituteVar() throws ServiceException {
Services services = new Services();
services.init();
int depth = ConfigurationService.getInt(XConfiguration.CONFIGURATION_SUBSTITUTE_DEPTH);
XConfiguration.initalized = false;
XConfiguration conf = new XConfiguration();
conf.set("key0", "hello");
for (int i = 1; i < depth + 5; i++) {
// key1, ${key0}
conf.set(String.valueOf("key" + i), String.valueOf("${key" + (i - 1) + "}"));
}
assertEquals("hello", conf.get("key0"));
assertEquals("hello", conf.get("key1"));
assertEquals("hello", conf.get("key" + (depth - 1)));
try {
conf.get(String.valueOf("key" + (depth)));
fail("Fail to apply substitution depth");
} catch (IllegalStateException e) {
assertTrue(e.getMessage().contains("Variable substitution depth too large: " + depth));
}
services.destroy();
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestXLogFilter method testXLogFilter.
public void testXLogFilter() throws ServiceException, CommandException {
Services services = new Services();
services.init();
try {
XLogFilter xf2 = new XLogFilter();
xf2.constructPattern();
ArrayList<String> a = new ArrayList<String>();
a.add("2009-06-24 02:43:13,958");
a.add(" DEBUG");
a.add(" WorkflowRunnerCallable:323 - " + XLog.Info.get().createPrefix() + " test log");
assertEquals(true, xf2.matches(a));
} finally {
services.destroy();
}
XLogFilter.reset();
XLogFilter.defineParameter("USER");
XLogFilter.defineParameter("GROUP");
XLogFilter.defineParameter("TOKEN");
XLogFilter.defineParameter("APP");
XLogFilter.defineParameter("JOB");
XLogFilter.defineParameter("ACTION");
XLogFilter xf = new XLogFilter();
assertEquals(7, matches(xf));
xf.setLogLevel(XLog.Level.WARN.toString());
assertEquals(2, matches(xf));
xf.setLogLevel(XLog.Level.WARN.toString());
xf.setParameter("APP", "example-forkjoinwf");
assertEquals(0, matches(xf));
xf.setLogLevel(XLog.Level.DEBUG.toString() + "|" + XLog.Level.INFO.toString());
xf.setParameter("JOB", "14-200904160239--example-forkjoinwf");
assertEquals(2, matches(xf));
XLogFilter xf1 = new XLogFilter();
xf1.setParameter("USER", "oozie");
assertEquals(3, matches(xf1));
xf1.setParameter("GROUP", "oozie");
assertEquals(2, matches(xf1));
xf1.setParameter("TOKEN", "MYtoken");
assertEquals(1, matches(xf1));
}
use of org.apache.oozie.service.Services in project oozie by apache.
the class TestXLogUserFilterParam method testNoException_Withrecent.
// Test log duration - in range
public void testNoException_Withrecent() 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();
Services.get().getConf().setInt(XLogFilter.MAX_SCAN_DURATION, 10);
Map<String, String[]> paramMap = new HashMap<String, String[]>();
String param = XLogUserFilterParam.RECENT_LOG_OFFSET + "=9";
paramMap.put(RestConstants.LOG_FILTER_OPTION, new String[] { param });
XLogFilter filter = new XLogFilter(new XLogUserFilterParam(paramMap));
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 60 * 60 * 1000 * 15);
try {
doStreamLog(filter, startDate, endDate);
} catch (Exception e) {
fail("should not throw exception");
}
}
Aggregations