Search in sources :

Example 11 with LaunchDescriptor

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();
        });
    });
}
Also used : Async(io.vertx.ext.unit.Async) ProcessModuleHandle(org.folio.okapi.util.ProcessModuleHandle) ModuleHandle(org.folio.okapi.util.ModuleHandle) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor) Test(org.junit.Test)

Example 12 with LaunchDescriptor

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();
    });
}
Also used : Async(io.vertx.ext.unit.Async) ProcessModuleHandle(org.folio.okapi.util.ProcessModuleHandle) ModuleHandle(org.folio.okapi.util.ModuleHandle) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor) Test(org.junit.Test)

Example 13 with LaunchDescriptor

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();
    });
}
Also used : Async(io.vertx.ext.unit.Async) ProcessModuleHandle(org.folio.okapi.util.ProcessModuleHandle) ModuleHandle(org.folio.okapi.util.ModuleHandle) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor) Test(org.junit.Test)

Example 14 with LaunchDescriptor

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);
    });
}
Also used : ModuleDescriptor(org.folio.okapi.bean.ModuleDescriptor) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor)

Aggregations

LaunchDescriptor (org.folio.okapi.bean.LaunchDescriptor)14 Test (org.junit.Test)10 ModuleHandle (org.folio.okapi.util.ModuleHandle)9 Async (io.vertx.ext.unit.Async)8 ProcessModuleHandle (org.folio.okapi.util.ProcessModuleHandle)8 DeploymentDescriptor (org.folio.okapi.bean.DeploymentDescriptor)4 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 EnvEntry (org.folio.okapi.bean.EnvEntry)1 ModuleDescriptor (org.folio.okapi.bean.ModuleDescriptor)1 Success (org.folio.okapi.common.Success)1 CompList (org.folio.okapi.util.CompList)1