2020-02-28 11:17:01 +00:00
|
|
|
import ./make-test-python.nix ({ pkgs, ... }: {
|
|
|
|
name = "service-runner";
|
2021-01-10 19:08:30 +00:00
|
|
|
meta = with pkgs.lib.maintainers; {
|
2020-02-28 11:17:01 +00:00
|
|
|
maintainers = [ roberth ];
|
|
|
|
};
|
|
|
|
|
|
|
|
nodes = {
|
|
|
|
machine = { pkgs, lib, ... }: {
|
|
|
|
services.nginx.enable = true;
|
|
|
|
services.nginx.virtualHosts.machine.root = pkgs.runCommand "webroot" {} ''
|
|
|
|
mkdir $out
|
|
|
|
echo 'yay' >$out/index.html
|
|
|
|
'';
|
|
|
|
systemd.services.nginx.enable = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = { nodes, ... }: ''
|
|
|
|
url = "http://localhost/index.html"
|
|
|
|
|
|
|
|
with subtest("check systemd.services.nginx.runner"):
|
|
|
|
machine.fail(f"curl {url}")
|
|
|
|
machine.succeed(
|
|
|
|
"""
|
2020-04-27 20:07:13 +01:00
|
|
|
mkdir -p /run/nginx /var/log/nginx /var/cache/nginx
|
2020-02-28 11:17:01 +00:00
|
|
|
${nodes.machine.config.systemd.services.nginx.runner} &
|
|
|
|
echo $!>my-nginx.pid
|
|
|
|
"""
|
|
|
|
)
|
|
|
|
machine.wait_for_open_port(80)
|
2020-09-16 16:25:34 +01:00
|
|
|
machine.succeed(f"curl -f {url}")
|
2020-02-28 11:17:01 +00:00
|
|
|
machine.succeed("kill -INT $(cat my-nginx.pid)")
|
|
|
|
machine.wait_for_closed_port(80)
|
|
|
|
'';
|
|
|
|
})
|