2016-12-28 05:19:51 +00:00
|
|
|
import ./make-test.nix ({ pkgs, ...} : rec {
|
|
|
|
name = "mesos";
|
2015-07-12 10:09:40 +00:00
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
2016-12-28 05:19:51 +00:00
|
|
|
maintainers = [ offline kamilchm cstrahan ];
|
2015-07-12 10:09:40 +00:00
|
|
|
};
|
2014-12-11 22:32:37 +00:00
|
|
|
|
2016-12-28 05:19:51 +00:00
|
|
|
nodes = {
|
|
|
|
master = { config, pkgs, ... }: {
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
services.zookeeper.enable = true;
|
|
|
|
services.mesos.master = {
|
|
|
|
enable = true;
|
|
|
|
zk = "zk://master:2181/mesos";
|
2014-12-11 22:32:37 +00:00
|
|
|
};
|
2016-12-28 05:19:51 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
slave = { config, pkgs, ... }: {
|
|
|
|
networking.firewall.enable = false;
|
|
|
|
networking.nat.enable = true;
|
|
|
|
virtualisation.docker.enable = true;
|
|
|
|
services.mesos = {
|
|
|
|
slave = {
|
|
|
|
enable = true;
|
|
|
|
master = "master:5050";
|
|
|
|
dockerRegistry = registry;
|
|
|
|
executorEnvironmentVariables = {
|
|
|
|
PATH = "/run/current-system/sw/bin";
|
|
|
|
};
|
|
|
|
};
|
2014-12-11 22:32:37 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2016-12-28 05:19:51 +00:00
|
|
|
simpleDocker = pkgs.dockerTools.buildImage {
|
|
|
|
name = "echo";
|
|
|
|
contents = [ pkgs.stdenv.shellPackage pkgs.coreutils ];
|
|
|
|
config = {
|
|
|
|
Env = [
|
|
|
|
# When shell=true, mesos invokes "sh -c '<cmd>'", so make sure "sh" is
|
|
|
|
# on the PATH.
|
|
|
|
"PATH=${pkgs.stdenv.shellPackage}/bin:${pkgs.coreutils}/bin"
|
|
|
|
];
|
|
|
|
Entrypoint = [ "echo" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
registry = pkgs.runCommand "registry" { } ''
|
|
|
|
mkdir -p $out
|
|
|
|
cp ${simpleDocker} $out/echo:latest.tar
|
|
|
|
'';
|
|
|
|
|
|
|
|
testFramework = pkgs.pythonPackages.buildPythonPackage {
|
|
|
|
name = "mesos-tests";
|
|
|
|
propagatedBuildInputs = [ pkgs.mesos ];
|
|
|
|
catchConflicts = false;
|
|
|
|
src = ./mesos_test.py;
|
|
|
|
phases = [ "installPhase" "fixupPhase" ];
|
|
|
|
installPhase = ''
|
2017-09-24 12:52:44 +00:00
|
|
|
install -Dvm 0755 $src $out/bin/mesos_test.py
|
2016-12-28 05:19:51 +00:00
|
|
|
|
|
|
|
echo "done" > test.result
|
|
|
|
tar czf $out/test.tar.gz test.result
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2014-12-11 22:32:37 +00:00
|
|
|
testScript =
|
|
|
|
''
|
|
|
|
startAll;
|
2016-12-28 05:19:51 +00:00
|
|
|
$master->waitForUnit("mesos-master.service");
|
|
|
|
$slave->waitForUnit("mesos-slave.service");
|
|
|
|
|
|
|
|
$master->waitForOpenPort(5050);
|
|
|
|
$slave->waitForOpenPort(5051);
|
|
|
|
|
2017-09-24 12:52:44 +00:00
|
|
|
# is slave registered?
|
2016-12-28 05:19:51 +00:00
|
|
|
$master->waitUntilSucceeds("curl -s --fail http://master:5050/master/slaves".
|
|
|
|
" | grep -q \"\\\"hostname\\\":\\\"slave\\\"\"");
|
|
|
|
|
2017-09-24 12:52:44 +00:00
|
|
|
# try to run docker image
|
2016-12-28 05:19:51 +00:00
|
|
|
$master->succeed("${pkgs.mesos}/bin/mesos-execute --master=master:5050".
|
|
|
|
" --resources=\"cpus:0.1;mem:32\" --name=simple-docker".
|
|
|
|
" --containerizer=mesos --docker_image=echo:latest".
|
|
|
|
" --shell=true --command=\"echo done\" | grep -q TASK_FINISHED");
|
|
|
|
|
|
|
|
# simple command with .tar.gz uri
|
2017-09-24 12:52:44 +00:00
|
|
|
$master->succeed("${testFramework}/bin/mesos_test.py master ".
|
2016-12-28 05:19:51 +00:00
|
|
|
"${testFramework}/test.tar.gz");
|
2014-12-11 22:32:37 +00:00
|
|
|
'';
|
2015-07-12 10:09:40 +00:00
|
|
|
})
|