DeploymentManager { Future<DeploymentDescriptor> deploy(DeploymentDescriptor md1) { String id = md1.getInstId(); if (id != null && list.containsKey(id)) { return Future.failedFuture(new OkapiError(ErrorType.USER, messages.getMessage("10700", id))); } String srvc = md1.getSrvcId(); if (srvc == null) { return Future.failedFuture(new OkapiError(ErrorType.USER, messages.getMessage("10701"))); } int usePort = ports.get(); if (usePort == -1) { return Future.failedFuture(new OkapiError(ErrorType.USER, messages.getMessage("10702"))); } if (id == null) { id = UUID.randomUUID().toString(); md1.setInstId(id); } logger.info("deploy instId {}", id); return deploy2(usePort, md1); } DeploymentManager(Vertx vertx, DiscoveryManager dm, EnvManager em,
                           String host, int listenPort, String nodeName, JsonObject config); Future<Void> init(); Future<Void> shutdown();  }
@Test public void testProcessNotFound(TestContext context) { createDeploymentManager(context); Async async = context.async(); LaunchDescriptor descriptor = new LaunchDescriptor(); descriptor.setExec( "java -Dport=%p -jar " + "../okapi-test-module/target/unknown.jar"); DeploymentDescriptor dd = new DeploymentDescriptor("2", "sid", descriptor); dm.deploy(dd).onComplete(res -> { context.assertFalse(res.succeeded()); context.assertEquals("Service returned with exit code 1", res.cause().getMessage()); async.complete(); }); async.await(); }
@Test public void testNoPortsAvailable(TestContext context) { JsonObject conf = new JsonObject(); conf.put("port_start", "9231"); conf.put("port_end", "9231"); DeploymentManagerTest.this.createDeploymentManager(context, new EnvStoreNull(), conf); Async async = context.async(); LaunchDescriptor descriptor = new LaunchDescriptor(); descriptor.setExec( "java -Dport=%p -jar " + "../okapi-test-module/target/unknown.jar"); DeploymentDescriptor dd = new DeploymentDescriptor("2", "sid", descriptor); dm.deploy(dd).onComplete(res -> { context.assertFalse(res.succeeded()); context.assertEquals("all ports in use", res.cause().getMessage()); async.complete(); }); async.await(); }