Skip to content
This repository has been archived by the owner on Jun 22, 2018. It is now read-only.

Commit

Permalink
Changed port to avoid conflict with jenkins II
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangrundig committed Jul 10, 2015
1 parent 24d2b01 commit e7bac46
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
18 changes: 16 additions & 2 deletions src/main/java/org/apache/mesos/mini/MesosCluster.java
Expand Up @@ -66,12 +66,26 @@ public void start() {
* @param containerName The name of the image
* @return The id of the container
*/
public String addAndStartContainer(String containerName) {
public String addAndStartContainer(String containerName, PortBinding ... portBindings) {
DockerUtil dockerUtil = new DockerUtil(config.dockerClient);
dockerUtil.pullImage(containerName, "latest");
CreateContainerCmd command = config.dockerClient.createContainerCmd(containerName);

String name = containerName.replace("/","_");
CreateContainerCmd command = config.dockerClient.createContainerCmd(containerName).withName(name);
if (portBindings != null) {
command.withPortBindings(portBindings);
}
return dockerUtil.createAndStart(command);
}
/**
* Pull and start a docker image. This container will be destroyed when the Mesos cluster is shut down.
*
* @param containerName The name of the image
* @return The id of the container
*/
public String addAndStartContainer(String containerName) {
return addAndStartContainer(containerName, null);
}

public State getStateInfo() throws UnirestException {
String json = Unirest.get("http://" + mesosContainer.getMesosMasterURL() + "/state.json").asString().getBody();
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/apache/mesos/mini/DockerProxyTest.java
Expand Up @@ -57,7 +57,7 @@ public void testInstantiate() throws InterruptedException, UnirestException {
class HelloWorldContainer extends AbstractContainer {

public static final String HELLO_WORLD_IMAGE = "tutum/hello-world";
public static final int PORT = 9599;
public static final int PORT = 80;

protected HelloWorldContainer(DockerClient dockerClient) {
super(dockerClient);
Expand All @@ -70,7 +70,7 @@ protected void pullImage() {

@Override
protected CreateContainerCmd dockerCommand() {
return dockerClient.createContainerCmd(HELLO_WORLD_IMAGE).withName("hello-world").withPortBindings(PortBinding.parse("0.0.0.0:" + PORT + ":" + PORT));
return dockerClient.createContainerCmd(HELLO_WORLD_IMAGE).withName("hello-world");
}
}
}
1 change: 1 addition & 0 deletions src/test/java/org/apache/mesos/mini/MesosClusterTest.java
@@ -1,5 +1,6 @@
package org.apache.mesos.mini;

import com.github.dockerjava.api.model.PortBinding;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;
import org.apache.mesos.mini.mesos.MesosClusterConfig;
Expand Down

0 comments on commit e7bac46

Please sign in to comment.