2015-07-12 11:09:40 +01:00
|
|
|
import ./make-test.nix ({ pkgs, ...} : rec {
|
2014-12-07 20:52:52 +00:00
|
|
|
name = "simple";
|
2015-07-12 11:09:40 +01:00
|
|
|
meta = with pkgs.stdenv.lib.maintainers; {
|
|
|
|
maintainers = [ offline ];
|
|
|
|
};
|
2014-12-07 20:52:52 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
node1 =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
|
|
services = {
|
|
|
|
etcd = {
|
|
|
|
enable = true;
|
|
|
|
listenPeerUrls = ["http://0.0.0.0:7001"];
|
|
|
|
initialAdvertisePeerUrls = ["http://node1:7001"];
|
|
|
|
initialCluster = ["node1=http://node1:7001" "node2=http://node2:7001"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-12-11 22:32:37 +00:00
|
|
|
services.fleet = {
|
2014-12-07 20:52:52 +00:00
|
|
|
enable = true;
|
|
|
|
metadata.name = "node1";
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 7001 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
node2 =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
|
|
services = {
|
|
|
|
etcd = {
|
|
|
|
enable = true;
|
|
|
|
listenPeerUrls = ["http://0.0.0.0:7001"];
|
|
|
|
initialAdvertisePeerUrls = ["http://node2:7001"];
|
|
|
|
initialCluster = ["node1=http://node1:7001" "node2=http://node2:7001"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2014-12-11 22:32:37 +00:00
|
|
|
services.fleet = {
|
2014-12-07 20:52:52 +00:00
|
|
|
enable = true;
|
|
|
|
metadata.name = "node2";
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 7001 ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
service = builtins.toFile "hello.service" ''
|
|
|
|
[Unit]
|
|
|
|
Description=Hello World
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=/bin/sh -c "while true; do echo \"Hello, world\"; /var/run/current-system/sw/bin/sleep 1; done"
|
|
|
|
|
|
|
|
[X-Fleet]
|
|
|
|
MachineMetadata=name=node2
|
|
|
|
'';
|
|
|
|
|
|
|
|
testScript =
|
|
|
|
''
|
|
|
|
startAll;
|
|
|
|
$node1->waitForUnit("fleet.service");
|
|
|
|
$node2->waitForUnit("fleet.service");
|
|
|
|
|
|
|
|
$node2->waitUntilSucceeds("fleetctl list-machines | grep node1");
|
|
|
|
$node1->waitUntilSucceeds("fleetctl list-machines | grep node2");
|
|
|
|
|
|
|
|
$node1->succeed("cp ${service} hello.service && fleetctl submit hello.service");
|
|
|
|
$node1->succeed("fleetctl list-unit-files | grep hello");
|
|
|
|
$node1->succeed("fleetctl start hello.service");
|
|
|
|
$node1->waitUntilSucceeds("fleetctl list-units | grep running");
|
|
|
|
$node1->succeed("fleetctl stop hello.service");
|
|
|
|
$node1->succeed("fleetctl destroy hello.service");
|
|
|
|
'';
|
2015-07-12 11:09:40 +01:00
|
|
|
})
|