use of io.elastest.epm.client.DockerContainer.DockerBuilder in project elastest-torm by elastest.
the class DockerComposeService method setup.
public void setup() throws IOException, InterruptedException {
// 1. Start docker-compose-ui container
dockerComposeUiContainerName = dockerService.generateContainerName(dockerComposeUiPrefix);
int dockerComposeBindPort = dockerService.findRandomOpenPort();
Binding bindNoVncPort = bindPort(dockerComposeBindPort);
ExposedPort exposedNoVncPort = tcp(dockerComposeUiPort);
String dockerComposeServiceUrl = "http://" + dockerService.getDockerServerIp() + ":" + dockerComposeBindPort;
log.debug("Starting docker-compose-ui container: {}", dockerComposeUiContainerName);
List<PortBinding> portBindings = asList(new PortBinding(bindNoVncPort, exposedNoVncPort));
Volume volume = new Volume(dockerDefaultSocket);
List<Volume> volumes = asList(volume);
List<Bind> binds = asList(new Bind(dockerDefaultSocket, volume));
DockerBuilder dockerBuilder = dockerBuilder(dockerComposeUiImageId, dockerComposeUiContainerName).portBindings(portBindings).volumes(volumes).binds(binds);
dockerService.startAndWaitContainer(dockerBuilder.build());
// 2. Create Retrofit object to call docker-compose-ui REST API
OkHttpClient okHttpClient = new OkHttpClient.Builder().readTimeout(dockerComposeTimeout, SECONDS).connectTimeout(dockerComposeTimeout, SECONDS).build();
Retrofit retrofit = new Retrofit.Builder().client(okHttpClient).addCallAdapterFactory(RxJavaCallAdapterFactory.create()).addConverterFactory(GsonConverterFactory.create()).baseUrl(dockerComposeServiceUrl).build();
dockerComposeApi = retrofit.create(DockerComposeApi.class);
log.debug("docker-compose-ui up and running on URL: {}", dockerComposeServiceUrl);
// 3.Delete default example projects
dockerService.waitForHostIsReachable(dockerComposeServiceUrl);
String[] defaultProjects = { "env-demo", "hello-node", "node-redis", "volumes-demo", "volumes-relative-paths" };
removeProjects(defaultProjects);
}
use of io.elastest.epm.client.DockerContainer.DockerBuilder in project elastest-torm by elastest.
the class PcapService method startPcap.
public Boolean startPcap(String execId) {
String containerName = containerPrefix + execId;
if (!containersList.containsKey(containerName)) {
DockerBuilder dockerBuilder = DockerContainer.dockerBuilder(dockpcapImage, containerName).network(dockpcapNetworkPrefix + execId);
DockerContainer dockerContainer = dockerBuilder.build();
containersList.put(containerName, dockerContainer);
try {
dockerService.startAndWaitContainer(dockerContainer);
return true;
} catch (InterruptedException e) {
log.error("Pcap not started {}", execId, e);
}
}
return false;
}
use of io.elastest.epm.client.DockerContainer.DockerBuilder in project elastest-torm by elastest.
the class DockerIntegrationTest method testDocker.
@Test
@DisplayName("Ask for Chrome to Docker")
void testDocker() throws Exception {
// Test data (input)
String imageId = "selenium/standalone-chrome-debug:3.5.3";
log.debug("Starting Hub with image {}", imageId);
String containerName = dockerService.generateContainerName("hub-for-test-");
Binding bindPort = bindPort(dockerService.findRandomOpenPort());
ExposedPort exposedPort = tcp(4444);
Binding bindHubVncPort = bindPort(dockerService.findRandomOpenPort());
ExposedPort exposedHubVncPort = tcp(5900);
List<PortBinding> portBindings = asList(new PortBinding(bindPort, exposedPort), new PortBinding(bindHubVncPort, exposedHubVncPort));
DockerBuilder dockerBuilder = dockerBuilder(imageId, containerName).portBindings(portBindings);
dockerService.startAndWaitContainer(dockerBuilder.build());
// Assertions
assertTrue(dockerService.existsContainer(containerName));
// Tear down
log.debug("Stoping Hub");
dockerService.stopAndRemoveContainer(containerName);
}
Aggregations