use of org.folio.okapi.bean.LaunchDescriptor in project okapi by folio-org.
the class ProcessModuleHandleTest method test7.
@Test
public void test7(TestContext context) {
final Async async = context.async();
// Cannot rely on sh and kill on Windows
String os = System.getProperty("os.name").toLowerCase();
if (os.contains("win")) {
async.complete();
return;
}
LaunchDescriptor desc = new LaunchDescriptor();
desc.setCmdlineStart("java -DpidFile=test-module.pid " + invokeTest + " 2>&1 >/dev/null &");
desc.setCmdlineStop("kill `cat test-module.pid`; rm -f test-module.pid");
ModuleHandle mh = createModuleHandle(desc, 9231);
mh.start(res1 -> {
context.assertTrue(res1.succeeded());
mh.stop(res2 -> {
context.assertTrue(res2.succeeded());
async.complete();
});
});
}
use of org.folio.okapi.bean.LaunchDescriptor in project okapi by folio-org.
the class ProcessModuleHandleTest method test1a.
@Test
public void test1a(TestContext context) {
final Async async = context.async();
LaunchDescriptor desc = new LaunchDescriptor();
desc.setExec("java -version %p");
ModuleHandle mh = createModuleHandle(desc, 9231);
mh.start(res -> {
if (res.succeeded()) {
// error did not expect to succeed!
mh.stop(res2 -> {
context.assertTrue(res2.succeeded());
context.assertFalse(res.failed());
async.complete();
});
}
context.assertFalse(res.succeeded());
String msg = res.cause().getMessage();
context.assertTrue(msg.startsWith("Deployment failed. Could not connect to port 9231"));
async.complete();
});
}
use of org.folio.okapi.bean.LaunchDescriptor in project okapi by folio-org.
the class ProcessModuleHandleTest method test5.
@Test
public void test5(TestContext context) {
final Async async = context.async();
LaunchDescriptor desc = new LaunchDescriptor();
desc.setCmdlineStart("java -Dport=9000 -jar unknown.jar");
ModuleHandle mh = createModuleHandle(desc, 9231);
mh.start(res -> {
context.assertFalse(res.succeeded());
context.assertEquals("Can not deploy: No %p in the cmdlineStart", res.cause().getMessage());
async.complete();
});
}
use of org.folio.okapi.bean.LaunchDescriptor in project okapi by folio-org.
the class DiscoveryManager method addAndDeploy2.
private void addAndDeploy2(DeploymentDescriptor dd, ProxyContext pc, Handler<ExtendedAsyncResult<DeploymentDescriptor>> fut, final String nodeId) {
if (moduleManager == null) {
fut.handle(new Failure<>(INTERNAL, "no module manager (should not happen)"));
return;
}
String modId = dd.getSrvcId();
moduleManager.get(modId, gres -> {
if (gres.failed()) {
if (gres.getType() == NOT_FOUND) {
fut.handle(new Failure<>(NOT_FOUND, "Module " + modId + " not found"));
} else {
fut.handle(new Failure<>(gres.getType(), gres.cause()));
}
return;
}
ModuleDescriptor md = gres.result();
LaunchDescriptor modLaunchDesc = md.getLaunchDescriptor();
if (modLaunchDesc == null) {
fut.handle(new Failure<>(USER, "Module " + modId + " has no launchDescriptor"));
return;
}
dd.setDescriptor(modLaunchDesc);
callDeploy(nodeId, pc, dd, fut);
});
}
Aggregations