├── .editorconfig ├── .gitignore ├── .pullapprove.yml ├── .travis.yml ├── LICENSE ├── Makefile ├── README.md ├── bin ├── install ├── install-version └── minimesos ├── build.gradle ├── cli ├── Dockerfile ├── build.gradle └── src │ ├── integration-test │ ├── java │ │ └── com │ │ │ └── containersol │ │ │ └── minimesos │ │ │ └── main │ │ │ ├── CommandInitTest.java │ │ │ ├── CommandLogsTest.java │ │ │ ├── CommandPsTest.java │ │ │ ├── CommandTest.java │ │ │ ├── CommandUninstallTest.java │ │ │ └── CommandUpTest.java │ └── resources │ │ ├── app.json │ │ ├── clusterconfig │ │ ├── basic.groovy │ │ └── two-agents.groovy │ │ ├── configFiles │ │ ├── complete-minimesosFile │ │ ├── invalid-minimesosFile.txt │ │ ├── marathonAppConfig-minimesosFile │ │ └── withMarathon-minimesosFile │ │ └── logback-test.xml │ ├── main │ └── java │ │ └── com │ │ └── containersol │ │ └── minimesos │ │ └── main │ │ ├── Command.java │ │ ├── CommandDestroy.java │ │ ├── CommandHelp.java │ │ ├── CommandInfo.java │ │ ├── CommandInit.java │ │ ├── CommandInstall.java │ │ ├── CommandLogs.java │ │ ├── CommandPs.java │ │ ├── CommandState.java │ │ ├── CommandUninstall.java │ │ ├── CommandUp.java │ │ ├── CommandVersion.java │ │ └── Main.java │ └── test │ ├── java │ └── com │ │ └── containersol │ │ └── minimesos │ │ └── main │ │ ├── CommandInstallTest.java │ │ └── MainTest.java │ └── resources │ ├── app.json │ └── group.json ├── docs ├── cc-cc.png ├── images │ └── introduction-to-minimesos-screenshot.jpg ├── index.md └── minimesos.png ├── gradle.properties ├── gradle ├── quality.gradle ├── spock.gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── images ├── minimesos-talk.jpg └── minimesos.png ├── minimesos ├── build.gradle └── src │ ├── integration-test │ └── java │ │ └── com.containersol.minimesos │ │ └── integrationtest │ │ ├── AuthenticationTest.java │ │ ├── MesosClusterTest.java │ │ └── container │ │ ├── HelloWorldContainer.java │ │ └── MesosExecuteContainer.java │ ├── main │ ├── groovy │ │ └── com │ │ │ └── containersol │ │ │ └── minimesos │ │ │ └── config │ │ │ ├── AgentResourcesConfig.groovy │ │ │ ├── AppConfig.groovy │ │ │ ├── ClusterConfig.groovy │ │ │ ├── ConfigParser.groovy │ │ │ ├── ConsulConfig.groovy │ │ │ ├── ContainerConfig.groovy │ │ │ ├── ContainerConfigBlock.groovy │ │ │ ├── GroovyBlock.groovy │ │ │ ├── GroupConfig.groovy │ │ │ ├── MarathonConfig.groovy │ │ │ ├── MesosAgentConfig.groovy │ │ │ ├── MesosContainerConfig.groovy │ │ │ ├── MesosDNSConfig.groovy │ │ │ ├── MesosMasterConfig.groovy │ │ │ ├── RegistratorConfig.groovy │ │ │ ├── ResourceDef.groovy │ │ │ ├── ResourceDefRanges.groovy │ │ │ ├── ResourceDefScalar.groovy │ │ │ └── ZooKeeperConfig.groovy │ ├── java │ │ └── com │ │ │ └── containersol │ │ │ └── minimesos │ │ │ ├── MinimesosException.java │ │ │ ├── cluster │ │ │ ├── ClusterProcess.java │ │ │ ├── ClusterRepository.java │ │ │ ├── ClusterUtil.java │ │ │ ├── Consul.java │ │ │ ├── Filter.java │ │ │ ├── Marathon.java │ │ │ ├── MesosAgent.java │ │ │ ├── MesosCluster.java │ │ │ ├── MesosClusterFactory.java │ │ │ ├── MesosContainer.java │ │ │ ├── MesosDns.java │ │ │ ├── MesosMaster.java │ │ │ ├── Registrator.java │ │ │ └── ZooKeeper.java │ │ │ ├── docker │ │ │ ├── DockerClientFactory.java │ │ │ └── DockerContainersUtil.java │ │ │ ├── integrationtest │ │ │ └── container │ │ │ │ ├── AbstractContainer.java │ │ │ │ └── ContainerName.java │ │ │ ├── junit │ │ │ └── MesosClusterTestRule.java │ │ │ ├── marathon │ │ │ └── MarathonContainer.java │ │ │ ├── mesos │ │ │ ├── ClusterContainers.java │ │ │ ├── ConsulContainer.java │ │ │ ├── MesosAgentContainer.java │ │ │ ├── MesosClusterContainersFactory.java │ │ │ ├── MesosContainerImpl.java │ │ │ ├── MesosDnsContainer.java │ │ │ ├── MesosMasterContainer.java │ │ │ ├── RegistratorContainer.java │ │ │ └── ZooKeeperContainer.java │ │ │ ├── state │ │ │ ├── Discovery.java │ │ │ ├── Executor.java │ │ │ ├── Framework.java │ │ │ ├── Port.java │ │ │ ├── Ports.java │ │ │ ├── State.java │ │ │ └── Task.java │ │ │ └── util │ │ │ ├── CollectionsUtils.java │ │ │ ├── Downloader.java │ │ │ ├── Environment.java │ │ │ ├── EnvironmentBuilder.java │ │ │ ├── Predicate.java │ │ │ └── ResourceUtil.java │ └── resources │ │ ├── logback.xml │ │ └── marathon │ │ ├── elasticsearch.json │ │ └── mesos-consul.json │ └── test │ ├── groovy │ └── com │ │ └── containersol │ │ └── minimesos │ │ └── config │ │ ├── AgentResourcesConfigTest.groovy │ │ ├── ConfigParserTest.groovy │ │ ├── ConfigWriterTest.groovy │ │ └── ResourceDefScalarTest.groovy │ ├── java │ └── com │ │ └── containersol │ │ └── minimesos │ │ ├── ClusterBuilderTest.java │ │ ├── ParseStateJSONTest.java │ │ ├── factory │ │ └── MesosClusterContainersFactoryTest.java │ │ ├── integrationtest │ │ └── container │ │ │ ├── ContainerNameTest.java │ │ │ └── MesosAgentTest.java │ │ ├── jdepend │ │ └── JDependCyclesTest.java │ │ ├── mesos │ │ ├── ClusterContainersTest.java │ │ └── ClusterUtilTest.java │ │ └── util │ │ ├── CollectionsUtilsTest.java │ │ ├── EnvironmentBuilderTest.java │ │ └── ResourceUtilTest.java │ └── resources │ ├── configFiles │ ├── minimesosFile-authenticationTest │ └── minimesosFile-mesosClusterTest │ └── logback-test.xml ├── opt ├── apps │ └── weave-scope.json ├── sonar │ ├── DockerFile │ ├── certificate.yaml │ ├── setup.md │ ├── sonar-deployment.yaml │ ├── sonar-plugins │ │ ├── sonar-github-plugin-1.1.jar │ │ ├── sonar-java-plugin-3.7.1.jar │ │ ├── sonar-scm-git-plugin-1.0.jar │ │ └── sonar-scm-svn-plugin-1.2.jar │ ├── sonar-postgres-deployment.yaml │ ├── sonar-postgres-service.yaml │ └── sonar-service.yaml └── vagrant │ └── debian │ └── jessie64 │ ├── Vagrantfile │ └── provision.sh ├── settings.gradle └── travis.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | end_of_line = lf 5 | insert_final_newline = true 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | 9 | [*.java] 10 | indent_style = space 11 | indent_size = 4 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | minimesosFile 2 | .minimesos/* 3 | *.class 4 | .gradle/ 5 | build/ 6 | 7 | # Vagrant working files 8 | .vagrant 9 | 10 | # Build system 11 | .gradle/ 12 | build/ 13 | 14 | # IDEA files 15 | *.i?? 16 | out/ 17 | .idea/ 18 | 19 | # Maven 20 | /target 21 | 22 | # Mobile Tools for Java (J2ME) 23 | .mtj.tmp/ 24 | 25 | # Package Files # 26 | *.war 27 | *.ear 28 | 29 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 30 | hs_err_pid* 31 | 32 | # private docker registry images 33 | .registry 34 | -------------------------------------------------------------------------------- /.pullapprove.yml: -------------------------------------------------------------------------------- 1 | approve_by_comment: true 2 | approve_regex: ^(Approved|LGTM|:\+1:) 3 | author_approval: ignored 4 | reject_regex: ^Rejected 5 | reset_on_push: false 6 | reviewers: 7 | members: 8 | - frankscholten 9 | - mwl 10 | - sadovnikov 11 | - philwinder 12 | - lguminski 13 | - adam-sandor 14 | name: default 15 | required: 1 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - oraclejdk8 5 | 6 | sudo: required 7 | 8 | install: 9 | # one liner installation of docker 1.9.1 below did not work (see https://github.com/moul/travis-docker/issues/38). 10 | # - curl -sLo - http://j.mp/install-travis-docker | sh -xe 11 | # Therefore installing it through a script 12 | - sudo sh -c 'echo "deb https://apt.dockerproject.org/repo ubuntu-precise main" > /etc/apt/sources.list.d/docker.list' 13 | - sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D 14 | - sudo apt-get update 15 | - sudo apt-key update 16 | - sudo apt-get -qqy install docker-engine=1.9.1-0~precise 17 | # Has to run this script with sudo because custom installation does not allow $USER to use docker and it's not possible to relogin 18 | - sudo make deps 19 | 20 | # Has to run the build script with sudo because custom installation does not allow $USER to use docker and it's not possible to relogin 21 | script: chmod +x travis.sh && sudo ./travis.sh 22 | 23 | notifications: 24 | email: true 25 | # see details on https://docs.travis-ci.com/user/notifications 26 | slack: 27 | secure: RWUEmM8nef6hH9+AmVaBWVxcjUt5hVPdbw02x+iBdTqAxPC2wxq3Ya/vlWDwhyyXdUgMujfWTJxks3A15qHAzPH22/mVsmAoz8Duspj/C3x8dp/7IncnkbX5AI1fEJy+z+D8uL4J6ALM90y8kUm2QKoddOq1+xO65xZyzvXoxFJDZ9eIlSVsDv7q7qqkaHnWH8nW+DqtGFPlhu5K/luaw56gy7lChUX/KvAy+8fzaUFNPKdJTVu+GpdgJZrqKeQS8+gY00k0AaAS6fOHxTeAUmyC6eDTL1FgBueS5auBha321qU84sQTCQSTHxl0J8YSQzzrBEiGn506DMKFjZLQZWmR4DxxGSc8jd4sdbVXBoWEBQvNI8jZoAzagFnNig1NKPtRAXIuip28FJUhsvK3WOs1H/XsnkRxKZ52jRrDg0yYi48HsqIr7af6nSzAkAK5JEL58Yc1nYvALa0vXjVWuyuo8um0sFNvEDRE/eDi5o6iul0I4CPOM0j+6d8ymVuD6oJ8eeGjYSFVk7XgdCBp1Gcl8NHLgiVjnygcT0U07kszDV7q8ab0iAfjMoTJwFTjPGkwFWJnlD5dciliO7ncWORl//A3JOQqRh5kMp/96995Ia9G4pVnEkh6tQI6G84/qMU0blDrOtTWIO6NjDV4UiGAYtaixr8BGKQWji9K+eY= 28 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | default: build 2 | .PHONY: setup deps test build 3 | 4 | setup: 5 | sudo route delete 172.17.0.0/16; sudo route -n add 172.17.0.0/16 $(shell docker-machine ip ${shell DOCKER_MACHINE_NAME}) 6 | 7 | deps: 8 | docker pull containersol/mesos-agent:1.0.0-0.1.0 9 | docker pull containersol/mesos-master:1.0.0-0.1.0 10 | docker pull gliderlabs/registrator:v6 11 | docker pull consul:0.7.1 12 | docker pull xebia/mesos-dns:0.0.5 13 | docker pull mesosphere/marathon:v1.3.5 14 | docker pull jplock/zookeeper:3.4.6 15 | docker pull containersol/alpine3.3-java8-jre:v1 16 | docker pull tutum/hello-world:latest 17 | 18 | clean: 19 | ./gradlew clean 20 | -docker rmi containersol/minimesos-cli:latest 21 | 22 | build: 23 | ./gradlew build --info --stacktrace 24 | 25 | build-no-tests: 26 | ./gradlew build --info --stacktrace -x test 27 | 28 | test: 29 | ./gradlew test --info --stacktrace 30 | 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # minimesos [](https://travis-ci.org/ContainerSolutions/minimesos) 2 | 3 | The experimentation and testing tool for Apache Mesos 4 | 5 | NOTE: NO LONGER MAINTAINED! 6 | 7 |
container.getNames()
41 | * @param clusterId cluster to check
42 | * @param role role to check
43 | * @return true if container has the role
44 | */
45 | public static boolean hasRoleInCluster(String[] dockerNames, String clusterId, String role) {
46 | String name = getFromDockerNames(dockerNames);
47 | return hasRoleInCluster(name, clusterId, role);
48 | }
49 |
50 | /**
51 | * @return true, if container with this name belongs to the cluster
52 | */
53 | public static boolean belongsToCluster(String containerName, String clusterId) {
54 | String pattern = getContainerNamePattern(clusterId);
55 | return containerName.matches(pattern);
56 | }
57 |
58 | /**
59 | * @return true, if container with these docker names belongs to the cluster
60 | */
61 | public static boolean belongsToCluster(String[] dockerNames, String clusterId) {
62 | String name = getFromDockerNames(dockerNames);
63 | return belongsToCluster(name, clusterId);
64 | }
65 |
66 | /**
67 | * Docker supports multiple names for a single container, when the container is linked from others.
68 | * This method selects the original name of the container and removes leading "/"
69 | *
70 | * @param dockerNames names, as they returned by container.getNames()
71 | * @return name of the container, which is not inherited from link
72 | */
73 | public static String getFromDockerNames(String[] dockerNames) {
74 | String name = null;
75 | for (String dockerName : dockerNames) {
76 | String slashLess = dockerName;
77 | if (dockerName.startsWith("/")) {
78 | slashLess = dockerName.substring(1);
79 | }
80 | if (!slashLess.contains("/")) {
81 | name = slashLess;
82 | break;
83 | }
84 | }
85 | return name;
86 | }
87 |
88 | }
89 |
--------------------------------------------------------------------------------
/minimesos/src/main/java/com/containersol/minimesos/junit/MesosClusterTestRule.java:
--------------------------------------------------------------------------------
1 | package com.containersol.minimesos.junit;
2 |
3 | import java.io.FileInputStream;
4 | import java.io.FileNotFoundException;
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 |
8 | import com.containersol.minimesos.MinimesosException;
9 | import com.containersol.minimesos.cluster.MesosCluster;
10 | import com.containersol.minimesos.cluster.MesosClusterFactory;
11 | import com.containersol.minimesos.mesos.MesosClusterContainersFactory;
12 |
13 | import org.junit.rules.TestRule;
14 | import org.junit.runner.Description;
15 | import org.junit.runners.model.Statement;
16 |
17 | /**
18 | * JUnit Rule extension of Mesos Cluster to use in JUnit.
19 | */
20 | public class MesosClusterTestRule implements TestRule {
21 |
22 | private MesosClusterFactory factory = new MesosClusterContainersFactory();
23 |
24 | private MesosCluster mesosCluster;
25 |
26 | public static MesosClusterTestRule fromClassPath(String path) {
27 | try (InputStream is = MesosClusterTestRule.class.getResourceAsStream(path)) {
28 | MesosCluster cluster = new MesosClusterContainersFactory().createMesosCluster(is);
29 | return new MesosClusterTestRule(cluster);
30 | } catch (IOException e) {
31 | throw new MinimesosException("Could not read minimesosFile on classpath " + path, e);
32 | }
33 | }
34 |
35 | public static MesosClusterTestRule fromFile(String minimesosFilePath) {
36 | try {
37 | MesosCluster cluster = new MesosClusterContainersFactory().createMesosCluster(new FileInputStream(minimesosFilePath));
38 | return new MesosClusterTestRule(cluster);
39 | } catch (FileNotFoundException e) {
40 | throw new MinimesosException("Could not read minimesosFile at " + minimesosFilePath, e);
41 | }
42 | }
43 |
44 | private MesosClusterTestRule(MesosCluster mesosCluster) {
45 | this.mesosCluster = mesosCluster;
46 | }
47 |
48 | /**
49 | * Modifies the method-running {@link Statement} to implement this test-running rule.
50 | *
51 | * @param base The {@link Statement} to be modified
52 | * @param description A {@link Description} of the test implemented in {@code base}
53 | * @return a new statement, which may be the same as {@code base}, a wrapper around {@code base}, or a completely new Statement.
54 | */
55 | @Override
56 | public Statement apply(Statement base, Description description) {
57 | return new Statement() {
58 | @Override
59 | public void evaluate() throws Throwable {
60 | before();
61 | try {
62 | base.evaluate();
63 | } finally {
64 | after();
65 | }
66 | }
67 | };
68 | }
69 |
70 | /**
71 | * Execute before the test
72 | */
73 | protected void before() {
74 | mesosCluster.start();
75 | Runtime.getRuntime().addShutdownHook(new Thread() {
76 | @Override
77 | public void run() {
78 | factory.destroyRunningCluster(mesosCluster.getClusterId());
79 | }
80 | });
81 | }
82 |
83 | /**
84 | * Execute after the test
85 | */
86 | protected void after() {
87 | stop();
88 | }
89 |
90 | /**
91 | * Destroys cluster using docker based factory of cluster members
92 | */
93 | public void stop() {
94 | mesosCluster.destroy(factory);
95 | }
96 |
97 | public MesosCluster getMesosCluster() {
98 | return mesosCluster;
99 | }
100 |
101 | public MesosClusterFactory getFactory() {
102 | return factory;
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/minimesos/src/main/java/com/containersol/minimesos/mesos/ClusterContainers.java:
--------------------------------------------------------------------------------
1 | package com.containersol.minimesos.mesos;
2 |
3 | import com.containersol.minimesos.cluster.ClusterProcess;
4 |
5 | import java.util.ArrayList;
6 | import java.util.List;
7 | import java.util.Optional;
8 | import java.util.function.Predicate;
9 |
10 | /**
11 | * Holds the containers and helper methods for the Mesos cluster
12 | */
13 | public class ClusterContainers {
14 |
15 | private final List
20 | * Example: 'ports(*):[31000-32000],;cpus(*):0.2; mem(*):256; disk(*):200' returns [31000, 32000]
21 | *
22 | * @param mesosResourceString Mesos resource string
23 | * @return list of ports if any
24 | * @throws MinimesosException if resource string is incorrect
25 | */
26 | public static ArrayList