use of org.apache.apex.api.Launcher in project apex-malhar by apache.
the class ApplicationTest method testApplication.
@Test
public void testApplication() throws Exception {
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
EmbeddedAppLauncher<?> launcher = Launcher.getLauncher(Launcher.LaunchMode.EMBEDDED);
Attribute.AttributeMap launchAttributes = new Attribute.AttributeMap.DefaultAttributeMap();
launchAttributes.put(EmbeddedAppLauncher.RUN_ASYNC, true);
EnricherAppWithJSONFile enricherAppWithJSONFile = new EnricherAppWithJSONFile();
enricherAppWithJSONFile.outputFn = outputFn;
Launcher.AppHandle appHandle = launcher.launchApp(enricherAppWithJSONFile, conf, launchAttributes);
int sleepTimeCounterForLoopExit = 0;
int sleepTimePerIteration = 500;
// wait until expected result count or timeout
while (results.size() < enricherAppWithJSONFile.getDataGenerator().getLimit()) {
sleepTimeCounterForLoopExit += sleepTimePerIteration;
if (sleepTimeCounterForLoopExit > 30000) {
break;
}
Thread.sleep(sleepTimePerIteration);
}
appHandle.shutdown(ShutdownMode.KILL);
assertTrue(results.size() >= enricherAppWithJSONFile.getDataGenerator().getLimit());
assertEnrichedOutput();
}
use of org.apache.apex.api.Launcher in project apex-malhar by apache.
the class SimpleTransformApplicationTest method testApplication.
@Test
public void testApplication() throws Exception {
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
EmbeddedAppLauncher<?> launcher = Launcher.getLauncher(Launcher.LaunchMode.EMBEDDED);
Attribute.AttributeMap launchAttributes = new Attribute.AttributeMap.DefaultAttributeMap();
launchAttributes.put(EmbeddedAppLauncher.RUN_ASYNC, true);
SimpleTransformApplication simpleTransformApplication = new SimpleTransformApplication();
simpleTransformApplication.outputFn = outputFn;
Launcher.AppHandle appHandle = launcher.launchApp(simpleTransformApplication, conf, launchAttributes);
int sleepTimeCounterForLoopExit = 0;
int sleepTimePerIteration = 500;
// wait until expected result count or timeout
while (results.size() < simpleTransformApplication.pojoDataGenerator.getMaxTuples()) {
sleepTimeCounterForLoopExit += sleepTimePerIteration;
if (sleepTimeCounterForLoopExit > 30000) {
break;
}
Thread.sleep(sleepTimePerIteration);
}
appHandle.shutdown(Launcher.ShutdownMode.KILL);
assertEquals(results.size(), simpleTransformApplication.pojoDataGenerator.getMaxTuples());
assertTransformationsGenerated(simpleTransformApplication);
}
use of org.apache.apex.api.Launcher in project apex-malhar by apache.
the class PythonExecutorApplicationTest method testApplication.
@JepPythonTestContext(jepPythonBasedTest = true)
@Test
public void testApplication() throws Exception {
Configuration conf = new Configuration(false);
conf.addResource(this.getClass().getResourceAsStream("/META-INF/properties.xml"));
EmbeddedAppLauncher<?> launcher = Launcher.getLauncher(Launcher.LaunchMode.EMBEDDED);
Attribute.AttributeMap launchAttributes = new Attribute.AttributeMap.DefaultAttributeMap();
launchAttributes.put(EmbeddedAppLauncher.RUN_ASYNC, true);
PythonExecutorApplication pythonExecutorApplication = new PythonExecutorApplication();
pythonExecutorApplication.outputFn = outputFn;
Launcher.AppHandle appHandle = launcher.launchApp(pythonExecutorApplication, conf, launchAttributes);
int sleepTimeCounterForLoopExit = 0;
int sleepTimePerIteration = 1000;
// wait until expected result count or timeout
while (results.size() < pythonExecutorApplication.pojoDataGenerator.getMaxTuples()) {
sleepTimeCounterForLoopExit += sleepTimePerIteration;
if (sleepTimeCounterForLoopExit > 30000) {
break;
}
LOG.info("Test sleeping until the application time out is reached");
Thread.sleep(sleepTimePerIteration);
}
appHandle.shutdown(Launcher.ShutdownMode.KILL);
assertEquals(pythonExecutorApplication.pojoDataGenerator.getMaxTuples(), results.size());
}
Aggregations