use of org.folio.okapi.bean.Ports in project okapi by folio-org.
the class DeploymentManagerTest method setUp.
@Before
public void setUp(TestContext context) {
async = context.async();
vertx = Vertx.vertx();
ports = new Ports(9231, 9239);
em = new EnvManager(new EnvStoreNull());
ds = new DeploymentStoreNull();
em.init(vertx, res1 -> {
dis = new DiscoveryManager(ds);
dis.init(vertx, res2 -> {
dm = new DeploymentManager(vertx, dis, em, "myhost.index", ports, 9230, "");
async.complete();
});
});
}
use of org.folio.okapi.bean.Ports in project okapi by folio-org.
the class DockerModuleHandleTest method testHostNoExposedPorts.
@Test
public void testHostNoExposedPorts(TestContext context) {
Vertx vertx = Vertx.vertx();
LaunchDescriptor ld = new LaunchDescriptor();
ld.setDockerImage("folioci/mod-users:5.0.0-SNAPSHOT");
ld.setDockerPull(false);
Ports ports = new Ports(9232, 9233);
JsonObject conf = new JsonObject().put("dockerUrl", "tcp://localhost:9231");
DockerModuleHandle dh = new DockerModuleHandle(vertx, ld, "mod-users-5.0.0-SNAPSHOT", ports, "localhost", 0, /* no exposed port */
conf);
dh.start().onComplete(context.asyncAssertFailure(cause -> context.assertEquals("No exposedPorts in image", cause.getMessage())));
}
use of org.folio.okapi.bean.Ports in project okapi by folio-org.
the class DockerModuleHandleTest method createDockerModuleHandleForMock.
DockerModuleHandle createDockerModuleHandleForMock(Vertx vertx, JsonObject conf) {
LaunchDescriptor ld = new LaunchDescriptor();
ld.setDockerImage("folioci/mod-x");
Ports ports = new Ports(9232, 9233);
return new DockerModuleHandle(vertx, ld, "mod-x-1.0.0", ports, "localhost", 9232, conf);
}
use of org.folio.okapi.bean.Ports in project okapi by folio-org.
the class DockerModuleHandleTest method testDockerVersionAtLocal.
@Test
public void testDockerVersionAtLocal(TestContext context) {
// native transport = call docker via unix domain socket
Vertx vertx = Vertx.vertx(new VertxOptions().setPreferNativeTransport(true));
LaunchDescriptor ld = new LaunchDescriptor();
ld.setDockerImage("folioci/mod-users:5.0.0-SNAPSHOT");
JsonObject conf = new JsonObject();
// tell local Docker to use registry on non-listening port
conf.put("dockerRegistries", new JsonArray().add(new JsonObject().put("registry", "localhost:9231")));
Ports ports = new Ports(9232, 9233);
DockerModuleHandle dh = new DockerModuleHandle(vertx, ld, "mod-users-5.0.0-SNAPSHOT", ports, "localhost", 9232, conf);
JsonObject versionRes = new JsonObject();
{
Async async = context.async();
dh.getUrl("/version", "getVersion").onComplete(res -> {
if (res.succeeded()) {
versionRes.put("result", res.result());
}
async.complete();
});
async.await();
}
Assume.assumeTrue(versionRes.containsKey("result"));
context.assertTrue(versionRes.getJsonObject("result").containsKey("Version"));
logger.info("Local docker version {}", versionRes.getJsonObject("result").getString("Version"));
{
Async async = context.async();
// provoke 404 not found
dh.deleteUrl("/version", "msg").onComplete(context.asyncAssertFailure(cause -> {
context.assertTrue(cause.getMessage().startsWith("msg HTTP error 404"), cause.getMessage());
// provoke 404 not found
dh.postUrlJson("/version", null, "msg", "{}").onComplete(context.asyncAssertFailure(cause2 -> {
context.assertTrue(cause2.getMessage().startsWith("msg HTTP error 404"), cause2.getMessage());
async.complete();
}));
}));
async.await();
}
{
Async async = context.async();
dh.pullImage().onComplete(context.asyncAssertFailure(res -> {
assertThat(res.getMessage()).contains("9231").contains("connection refused");
async.complete();
}));
async.await();
}
}
use of org.folio.okapi.bean.Ports in project okapi by folio-org.
the class DockerModuleHandleTest method testNoDockerAtPort.
@Test
public void testNoDockerAtPort(TestContext context) {
Vertx vertx = Vertx.vertx();
LaunchDescriptor ld = new LaunchDescriptor();
ld.setDockerImage("folioci/mod-users:5.0.0-SNAPSHOT");
ld.setWaitIterations(3);
Ports ports = new Ports(9232, 9233);
JsonObject conf = new JsonObject().put("dockerUrl", "tcp://localhost:9231");
DockerModuleHandle dh = new DockerModuleHandle(vertx, ld, "mod-users-5.0.0-SNAPSHOT", ports, "localhost", 9232, conf);
dh.start().onComplete(context.asyncAssertFailure(this::assertConnectionRefused));
dh.stop().onComplete(context.asyncAssertFailure(this::assertConnectionRefused));
dh.startContainer().onComplete(context.asyncAssertFailure(this::assertConnectionRefused));
dh.stopContainer().onComplete(context.asyncAssertFailure(this::assertConnectionRefused));
dh.deleteContainer().onComplete(context.asyncAssertFailure(this::assertConnectionRefused));
}
Aggregations