Search in sources :

Example 11 with DeploymentDescriptor

use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.

the class BeanTest method testDeploymentDescriptor3.

@Test
public void testDeploymentDescriptor3() {
    int fail = 0;
    final String docSampleDeployment = "{" + LS + "  \"srvcId\" : \"sample-module-1\"," + LS + "  \"descriptor\" : {" + LS + "    \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"" + LS + "  }" + LS + "}";
    try {
        final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment, DeploymentDescriptor.class);
        String pretty = Json.encodePrettily(md);
        assertEquals(docSampleDeployment, pretty);
    } catch (DecodeException ex) {
        ex.printStackTrace();
        fail = 400;
    }
    assertEquals(0, fail);
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) DecodeException(io.vertx.core.json.DecodeException) Test(org.junit.Test)

Example 12 with DeploymentDescriptor

use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.

the class InternalModule method discoveryDeploy.

private void discoveryDeploy(ProxyContext pc, String body, Handler<ExtendedAsyncResult<String>> fut) {
    try {
        final DeploymentDescriptor pmd = Json.decodeValue(body, DeploymentDescriptor.class);
        discoveryManager.addAndDeploy(pmd, pc, res -> {
            if (res.failed()) {
                fut.handle(new Failure<>(res.getType(), res.cause()));
                return;
            }
            DeploymentDescriptor md = res.result();
            final String s = Json.encodePrettily(md);
            final String baseuri = pc.getCtx().request().uri() + "/" + md.getSrvcId();
            location(pc, md.getInstId(), baseuri, s, fut);
        });
    } catch (DecodeException ex) {
        fut.handle(new Failure<>(USER, ex));
    }
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) DecodeException(io.vertx.core.json.DecodeException) Failure(org.folio.okapi.common.Failure)

Example 13 with DeploymentDescriptor

use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.

the class DeploymentManagerTest method test1.

@Test
public void test1(TestContext context) {
    async = context.async();
    LaunchDescriptor descriptor = new LaunchDescriptor();
    descriptor.setExec("java -Dport=%p -jar " + "../okapi-test-module/target/okapi-test-module-fat.jar");
    DeploymentDescriptor dd = new DeploymentDescriptor("1", "sid", descriptor);
    dm.deploy(dd, res1 -> {
        context.assertTrue(res1.succeeded());
        dm.undeploy(res1.result().getInstId(), res2 -> {
            // after undeploy so we have no stale process
            context.assertEquals("http://myhost.index:9231", res1.result().getUrl());
            context.assertTrue(res2.succeeded());
            async.complete();
        });
    });
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) LaunchDescriptor(org.folio.okapi.bean.LaunchDescriptor) Test(org.junit.Test)

Example 14 with DeploymentDescriptor

use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.

the class BeanTest method testDeploymentDescriptor4.

@Test
public void testDeploymentDescriptor4() {
    int fail = 0;
    final String docSampleDeployment = "{" + LS + "  \"srvcId\" : \"sample-module-1\"," + LS + "  \"descriptor\" : {" + LS + "    \"dockerImage\" : \"my-image\"," + LS + "    \"dockerArgs\" : {" + LS + "      \"Hostname\" : \"localhost\"," + LS + "      \"User\" : \"nobody\"" + LS + "    }" + LS + "  }" + LS + "}";
    try {
        final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment, DeploymentDescriptor.class);
        String pretty = Json.encodePrettily(md);
        assertEquals(docSampleDeployment, pretty);
    } catch (DecodeException ex) {
        ex.printStackTrace();
        fail = 400;
    }
    assertEquals(0, fail);
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) DecodeException(io.vertx.core.json.DecodeException) Test(org.junit.Test)

Example 15 with DeploymentDescriptor

use of org.folio.okapi.bean.DeploymentDescriptor in project okapi by folio-org.

the class BeanTest method testDeploymentDescriptor1.

@Test
public void testDeploymentDescriptor1() {
    int fail = 0;
    final String docSampleDeployment = "{" + LS + "  \"srvcId\" : \"sample-module-1\"," + LS + "  \"descriptor\" : {" + LS + "    \"exec\" : " + "\"java -Dport=%p -jar ../okapi-test-module/target/okapi-test-module-fat.jar\"," + LS + "    \"env\" : [ {" + LS + "      \"name\" : \"helloGreeting\"," + LS + "      \"value\" : \"hej\"" + LS + "    } ]" + LS + "  }" + LS + "}";
    try {
        final DeploymentDescriptor md = Json.decodeValue(docSampleDeployment, DeploymentDescriptor.class);
        String pretty = Json.encodePrettily(md);
        assertEquals(docSampleDeployment, pretty);
    } catch (DecodeException ex) {
        ex.printStackTrace();
        fail = 400;
    }
    assertEquals(0, fail);
}
Also used : DeploymentDescriptor(org.folio.okapi.bean.DeploymentDescriptor) DecodeException(io.vertx.core.json.DecodeException) Test(org.junit.Test)

Aggregations

DeploymentDescriptor (org.folio.okapi.bean.DeploymentDescriptor)20 DecodeException (io.vertx.core.json.DecodeException)6 Test (org.junit.Test)6 LinkedList (java.util.LinkedList)4 List (java.util.List)4 LaunchDescriptor (org.folio.okapi.bean.LaunchDescriptor)4 CompList (org.folio.okapi.util.CompList)4 ModuleHandle (org.folio.okapi.util.ModuleHandle)3 HashMap (java.util.HashMap)2 Failure (org.folio.okapi.common.Failure)2 OkapiClient (org.folio.okapi.common.OkapiClient)2 Timer (com.codahale.metrics.Timer)1 HttpMethod (io.vertx.core.http.HttpMethod)1 LinkedHashMap (java.util.LinkedHashMap)1 EnvEntry (org.folio.okapi.bean.EnvEntry)1 HealthDescriptor (org.folio.okapi.bean.HealthDescriptor)1 ModuleInstance (org.folio.okapi.bean.ModuleInstance)1 RoutingEntry (org.folio.okapi.bean.RoutingEntry)1 Success (org.folio.okapi.common.Success)1