2020-04-20 11:31:07 +00:00
|
|
|
{ system ? builtins.currentSystem
|
|
|
|
, config ? {}
|
|
|
|
, pkgs ? import ../.. { inherit system config; }
|
|
|
|
, lib ? pkgs.lib
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
|
|
|
|
|
|
|
|
mkOCITest = backend: makeTest {
|
|
|
|
name = "oci-containers-${backend}";
|
|
|
|
|
2023-04-30 14:26:18 +00:00
|
|
|
meta.maintainers = lib.teams.serokell.members
|
2023-12-27 10:11:39 +00:00
|
|
|
++ (with lib.maintainers; [ benley mkaito ]);
|
2020-04-20 11:31:07 +00:00
|
|
|
|
|
|
|
nodes = {
|
|
|
|
${backend} = { pkgs, ... }: {
|
|
|
|
virtualisation.oci-containers = {
|
|
|
|
inherit backend;
|
|
|
|
containers.nginx = {
|
|
|
|
image = "nginx-container";
|
|
|
|
imageFile = pkgs.dockerTools.examples.nginx;
|
|
|
|
ports = ["8181:80"];
|
|
|
|
};
|
|
|
|
};
|
2023-08-10 08:24:26 +00:00
|
|
|
|
|
|
|
# Stop systemd from killing remaining processes if ExecStop script
|
|
|
|
# doesn't work, so that proper stopping can be tested.
|
|
|
|
systemd.services."${backend}-nginx".serviceConfig.KillSignal = "SIGCONT";
|
2020-04-20 11:31:07 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
${backend}.wait_for_unit("${backend}-nginx.service")
|
|
|
|
${backend}.wait_for_open_port(8181)
|
2020-09-16 15:31:34 +00:00
|
|
|
${backend}.wait_until_succeeds("curl -f http://localhost:8181 | grep Hello")
|
2023-08-10 08:24:26 +00:00
|
|
|
${backend}.succeed("systemctl stop ${backend}-nginx.service", timeout=10)
|
2020-04-20 11:31:07 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
lib.foldl' (attrs: backend: attrs // { ${backend} = mkOCITest backend; }) {} [
|
|
|
|
"docker"
|
|
|
|
"podman"
|
|
|
|
]
|