docker: Add test for docker-edge, check for proper versions in tests
This commit is contained in:
parent
2bb57ef776
commit
380ed98bd7
@ -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)
|
||||
|
@ -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"; });
|
||||
|
47
nixos/tests/docker-edge.nix
Normal file
47
nixos/tests/docker-edge.nix
Normal file
@ -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" ]');
|
||||
'';
|
||||
})
|
@ -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" ]');
|
||||
'';
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user