2020-04-20 13:31:07 +02: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 16:26:18 +02:00
|
|
|
meta.maintainers = lib.teams.serokell.members
|
2023-12-27 11:11:39 +01:00
|
|
|
++ (with lib.maintainers; [ benley mkaito ]);
|
2020-04-20 13:31:07 +02: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 10:24:26 +02: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 13:31:07 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
start_all()
|
|
|
|
${backend}.wait_for_unit("${backend}-nginx.service")
|
|
|
|
${backend}.wait_for_open_port(8181)
|
2020-09-16 17:31:34 +02:00
|
|
|
${backend}.wait_until_succeeds("curl -f http://localhost:8181 | grep Hello")
|
2023-08-10 10:24:26 +02:00
|
|
|
${backend}.succeed("systemctl stop ${backend}-nginx.service", timeout=10)
|
2020-04-20 13:31:07 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
lib.foldl' (attrs: backend: attrs // { ${backend} = mkOCITest backend; }) {} [
|
|
|
|
"docker"
|
|
|
|
"podman"
|
|
|
|
]
|