summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorTim Steinbach <tim@nequissimus.com>2017-09-04 19:02:44 -0400
committerTim Steinbach <tim@nequissimus.com>2017-09-04 19:02:44 -0400
commit380ed98bd793b2f3cbf257b7ef9601770c4f8d48 (patch)
tree214dbc40e01af13e63344f1399f63f7e86491e6d /nixos
parent2bb57ef7761fc9d408bb27b2733d36c8640e0e4b (diff)
downloadnixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar.gz
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar.bz2
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar.lz
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar.xz
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.tar.zst
nixpkgs-380ed98bd793b2f3cbf257b7ef9601770c4f8d48.zip
docker: Add test for docker-edge, check for proper versions in tests
Diffstat (limited to 'nixos')
-rw-r--r--nixos/release-combined.nix2
-rw-r--r--nixos/release.nix1
-rw-r--r--nixos/tests/docker-edge.nix47
-rw-r--r--nixos/tests/docker.nix6
4 files changed, 55 insertions, 1 deletions
diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix
index 54fd4a15ffc..4bf5df293fe 100644
--- a/nixos/release-combined.nix
+++ b/nixos/release-combined.nix
@@ -81,6 +81,8 @@ in rec {
         (all nixos.tests.boot.uefiUsb)
         (all nixos.tests.boot-stage1)
         nixos.tests.hibernate.x86_64-linux # i686 is flaky, see #23107
+        nixos.tests.docker.x86_64-linux
+        nixos.tests.docker-edge.x86_64-linux
         (all nixos.tests.ecryptfs)
         (all nixos.tests.ipv6)
         (all nixos.tests.i3wm)
diff --git a/nixos/release.nix b/nixos/release.nix
index ca2a164bb6c..0e56fa28c1a 100644
--- a/nixos/release.nix
+++ b/nixos/release.nix
@@ -234,6 +234,7 @@ in rec {
   tests.containers-hosts = callTest tests/containers-hosts.nix {};
   tests.containers-macvlans = callTest tests/containers-macvlans.nix {};
   tests.docker = hydraJob (import tests/docker.nix { system = "x86_64-linux"; });
+  tests.docker-edge = hydraJob (import tests/docker-edge.nix { system = "x86_64-linux"; });
   tests.dnscrypt-proxy = callTest tests/dnscrypt-proxy.nix { system = "x86_64-linux"; };
   tests.ecryptfs = callTest tests/ecryptfs.nix {};
   tests.etcd = hydraJob (import tests/etcd.nix { system = "x86_64-linux"; });
diff --git a/nixos/tests/docker-edge.nix b/nixos/tests/docker-edge.nix
new file mode 100644
index 00000000000..38d25daff19
--- /dev/null
+++ b/nixos/tests/docker-edge.nix
@@ -0,0 +1,47 @@
+# This test runs docker and checks if simple container starts
+
+import ./make-test.nix ({ pkgs, ...} : {
+  name = "docker";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ nequissimus offline ];
+  };
+
+  nodes = {
+    docker =
+      { config, pkgs, ... }:
+        {
+          virtualisation.docker.enable = true;
+          virtualisation.docker.package = pkgs.docker-edge;
+
+          users.users = {
+            noprivs = {
+              isNormalUser = true;
+              description = "Can't access the docker daemon";
+              password = "foobar";
+            };
+
+            hasprivs = {
+              isNormalUser = true;
+              description = "Can access the docker daemon";
+              password = "foobar";
+              extraGroups = [ "docker" ];
+            };
+          };
+        };
+    };
+
+  testScript = ''
+    startAll;
+
+    $docker->waitForUnit("sockets.target");
+    $docker->succeed("tar cv --files-from /dev/null | docker import - scratchimg");
+    $docker->succeed("docker run -d --name=sleeping -v /nix/store:/nix/store -v /run/current-system/sw/bin:/bin scratchimg /bin/sleep 10");
+    $docker->succeed("docker ps | grep sleeping");
+    $docker->succeed("sudo -u hasprivs docker ps");
+    $docker->fail("sudo -u noprivs docker ps");
+    $docker->succeed("docker stop sleeping");
+
+    # Must match version twice to ensure client and server versions are correct
+    $docker->succeed('[ $(docker version | grep ${pkgs.docker-edge.version} | wc -l) = "2" ]');
+  '';
+})
diff --git a/nixos/tests/docker.nix b/nixos/tests/docker.nix
index 9096a5868f6..c6c8f4cdb5f 100644
--- a/nixos/tests/docker.nix
+++ b/nixos/tests/docker.nix
@@ -3,7 +3,7 @@
 import ./make-test.nix ({ pkgs, ...} : {
   name = "docker";
   meta = with pkgs.stdenv.lib.maintainers; {
-    maintainers = [ offline ];
+    maintainers = [ nequissimus offline ];
   };
 
   nodes = {
@@ -11,6 +11,7 @@ import ./make-test.nix ({ pkgs, ...} : {
       { config, pkgs, ... }:
         {
           virtualisation.docker.enable = true;
+          virtualisation.docker.package = pkgs.docker;
 
           users.users = {
             noprivs = {
@@ -39,5 +40,8 @@ import ./make-test.nix ({ pkgs, ...} : {
     $docker->succeed("sudo -u hasprivs docker ps");
     $docker->fail("sudo -u noprivs docker ps");
     $docker->succeed("docker stop sleeping");
+
+    # Must match version twice to ensure client and server versions are correct
+    $docker->succeed('[ $(docker version | grep ${pkgs.docker.version} | wc -l) = "2" ]');
   '';
 })