Search in sources :

Example 6 with ModuleHandle

use of org.folio.okapi.util.ModuleHandle in project okapi by folio-org.

the class ProcessModuleHandleTest method test2.

@Test
public void test2(TestContext context) {
    final Async async = context.async();
    LaunchDescriptor desc = new LaunchDescriptor();
    desc.setExec("sleepxx 10 %p");
    ModuleHandle mh = createModuleHandle(desc, 0);
    mh.start(res -> {
        context.assertFalse(res.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 7 with ModuleHandle

use of org.folio.okapi.util.ModuleHandle in project okapi by folio-org.

the class ProcessModuleHandleTest method test6.

@Test
public void test6(TestContext context) {
    final Async async = context.async();
    LaunchDescriptor desc = new LaunchDescriptor();
    desc.setExec("java " + invokeTest);
    ModuleHandle mh = createModuleHandle(desc, 9231);
    mh.start(res1 -> {
        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 8 with ModuleHandle

use of org.folio.okapi.util.ModuleHandle 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 9 with ModuleHandle

use of org.folio.okapi.util.ModuleHandle 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 10 with ModuleHandle

use of org.folio.okapi.util.ModuleHandle 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)

Aggregations

ModuleHandle (org.folio.okapi.util.ModuleHandle)11 LaunchDescriptor (org.folio.okapi.bean.LaunchDescriptor)9 Async (io.vertx.ext.unit.Async)8 ProcessModuleHandle (org.folio.okapi.util.ProcessModuleHandle)8 Test (org.junit.Test)8 DeploymentDescriptor (org.folio.okapi.bean.DeploymentDescriptor)3 Timer (com.codahale.metrics.Timer)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 EnvEntry (org.folio.okapi.bean.EnvEntry)1 Success (org.folio.okapi.common.Success)1