Automate minimesos with jUnit

Step 1 of 4

Create jUnit Test

The following Java snippet the example jUnit test. At the top of the class we define the MesosCluster with Zookeeper and one master and agent.

The test queries for the Cluster state. Based on this it verifies the agent has started, and the master is listening on port 5050.

public class MesosClusterTest {
  @ClassRule
  public static MesosCluster cluster = new MesosCluster(new ClusterArchitecture.Builder()
    .withZooKeeper()
    .withMaster()
    .withAgent("ports(*):[9200-9200,9300-9300]")
    .build());

  @Test
  public void mesosClusterCanBeStarted() throws Exception {
    JSONObject stateInfo = cluster.getClusterStateInfo();
    Assert.assertEquals(1, stateInfo.getInt("activated_slaves"));
    Assert.assertTrue(cluster.getMasterContainer().getStateUrl().contains(":5050"));
  }
}

Task

Copy the snippet into MesosClusterTest.java file.

MesosClusterTest.java
pom.xml