notes: 2.3.0 -> 2.3.1 (#352950)
[NixPkgs.git] / nixos / tests / oci-containers.nix
blob9adceb11f18c160995ec82a98b4a9ed542191921
1 { system ? builtins.currentSystem
2 , config ? {}
3 , pkgs ? import ../.. { inherit system config; }
4 , lib ? pkgs.lib
5 }:
7 let
9   inherit (import ../lib/testing-python.nix { inherit system pkgs; }) makeTest;
11   mkOCITest = backend: makeTest {
12     name = "oci-containers-${backend}";
14     meta.maintainers = lib.teams.serokell.members
15                        ++ (with lib.maintainers; [ benley mkaito ]);
17     nodes = {
18       ${backend} = { pkgs, ... }: {
19         virtualisation.oci-containers = {
20           inherit backend;
21           containers.nginx = {
22             image = "nginx-container";
23             imageStream = pkgs.dockerTools.examples.nginxStream;
24             ports = ["8181:80"];
25           };
26         };
28         # Stop systemd from killing remaining processes if ExecStop script
29         # doesn't work, so that proper stopping can be tested.
30         systemd.services."${backend}-nginx".serviceConfig.KillSignal = "SIGCONT";
31       };
32     };
34     testScript = ''
35       start_all()
36       ${backend}.wait_for_unit("${backend}-nginx.service")
37       ${backend}.wait_for_open_port(8181)
38       ${backend}.wait_until_succeeds("curl -f http://localhost:8181 | grep Hello")
39       ${backend}.succeed("systemctl stop ${backend}-nginx.service", timeout=10)
40     '';
41   };
44 lib.foldl' (attrs: backend: attrs // { ${backend} = mkOCITest backend; }) {} [
45   "docker"
46   "podman"