summaryrefslogtreecommitdiffstats
path: root/nixos/tests
diff options
context:
space:
mode:
authoradisbladis <adisbladis@gmail.com>2020-04-20 12:31:07 +0100
committeradisbladis <adisbladis@gmail.com>2020-05-04 13:47:25 +0100
commit2f7747526cc80844a506c4aa14706429324be157 (patch)
treee5e61dd3873c02c23cced6afbc79c7be45294d8e /nixos/tests
parent2fb5dac372fedd482ef3c65b608810bb7dd45083 (diff)
nixos/docker-containers: Rename to virtualisation.oci-containers.containers.
And allow the runtime to be configurable via the `virtualisation.oci-containers.backend` option. Valid choices are "podman" and "docker".
Diffstat (limited to 'nixos/tests')
-rw-r--r--nixos/tests/all-tests.nix2
-rw-r--r--nixos/tests/docker-containers.nix27
-rw-r--r--nixos/tests/oci-containers.nix43
3 files changed, 44 insertions, 28 deletions
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index eff1752bbbf8..ebb0dfef15ac 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -70,7 +70,7 @@ in
dhparams = handleTest ./dhparams.nix {};
dnscrypt-proxy2 = handleTestOn ["x86_64-linux"] ./dnscrypt-proxy2.nix {};
docker = handleTestOn ["x86_64-linux"] ./docker.nix {};
- docker-containers = handleTestOn ["x86_64-linux"] ./docker-containers.nix {};
+ oci-containers = handleTestOn ["x86_64-linux"] ./oci-containers.nix {};
docker-edge = handleTestOn ["x86_64-linux"] ./docker-edge.nix {};
docker-preloader = handleTestOn ["x86_64-linux"] ./docker-preloader.nix {};
docker-registry = handleTest ./docker-registry.nix {};
diff --git a/nixos/tests/docker-containers.nix b/nixos/tests/docker-containers.nix
deleted file mode 100644
index 0e318a52d9f1..000000000000
--- a/nixos/tests/docker-containers.nix
+++ /dev/null
@@ -1,27 +0,0 @@
-# Test Docker containers as systemd units
-
-import ./make-test-python.nix ({ pkgs, lib, ... }: {
- name = "docker-containers";
- meta = {
- maintainers = with lib.maintainers; [ benley mkaito ];
- };
-
- nodes = {
- docker = { pkgs, ... }: {
- virtualisation.docker.enable = true;
-
- docker-containers.nginx = {
- image = "nginx-container";
- imageFile = pkgs.dockerTools.examples.nginx;
- ports = ["8181:80"];
- };
- };
- };
-
- testScript = ''
- start_all()
- docker.wait_for_unit("docker-nginx.service")
- docker.wait_for_open_port(8181)
- docker.wait_until_succeeds("curl http://localhost:8181 | grep Hello")
- '';
-})
diff --git a/nixos/tests/oci-containers.nix b/nixos/tests/oci-containers.nix
new file mode 100644
index 000000000000..bb6c019f07c9
--- /dev/null
+++ b/nixos/tests/oci-containers.nix
@@ -0,0 +1,43 @@
+{ 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}";
+
+ meta = {
+ maintainers = with lib.maintainers; [ adisbladis benley mkaito ];
+ };
+
+ nodes = {
+ ${backend} = { pkgs, ... }: {
+ virtualisation.oci-containers = {
+ inherit backend;
+ containers.nginx = {
+ image = "nginx-container";
+ imageFile = pkgs.dockerTools.examples.nginx;
+ ports = ["8181:80"];
+ };
+ };
+ };
+ };
+
+ testScript = ''
+ start_all()
+ ${backend}.wait_for_unit("${backend}-nginx.service")
+ ${backend}.wait_for_open_port(8181)
+ ${backend}.wait_until_succeeds("curl http://localhost:8181 | grep Hello")
+ '';
+ };
+
+in
+lib.foldl' (attrs: backend: attrs // { ${backend} = mkOCITest backend; }) {} [
+ "docker"
+ "podman"
+]