Add test with podman docker socket backend

This commit is contained in:
Robert Hensing 2021-05-26 16:57:56 +02:00
parent e0e7531f7d
commit 286d56a83c
7 changed files with 55 additions and 20 deletions

View file

@ -13,18 +13,23 @@ dimension "Nixpkgs version" {
nixpkgsSource = "nixos-19.03"; nixpkgsSource = "nixos-19.03";
enableDoc = false; enableDoc = false;
nixosTestIsPerl = true; nixosTestIsPerl = true;
dockerSupportsSystemd = true;
nixosHasPodmanDockerSocket = false;
}; };
"nixos-20_09" = { "nixos-20_09" = {
nixpkgsSource = "nixos-20.09"; nixpkgsSource = "nixos-20.09";
isReferenceNixpkgs = true; isReferenceNixpkgs = true;
enableDoc = true; enableDoc = true;
dockerSupportsSystemd = true;
nixosHasPodmanDockerSocket = false;
}; };
"nixos-unstable" = { "nixos-unstable" = {
nixpkgsSource = "nixos-unstable"; nixpkgsSource = "nixos-unstable";
enableDoc = true; enableDoc = true;
}; };
} ( } (
_name: { nixpkgsSource, isReferenceNixpkgs ? false, enableDoc ? true, nixosTestIsPerl ? false }: _name: { nixpkgsSource, isReferenceNixpkgs ? false, enableDoc ? true,
nixosTestIsPerl ? false, dockerSupportsSystemd ? false, nixosHasPodmanDockerSocket ? true }:
dimension "System" { dimension "System" {
@ -34,7 +39,7 @@ dimension "Nixpkgs version" {
system: { isReferenceTarget ? false, enableNixOSTests ? true }: system: { isReferenceTarget ? false, enableNixOSTests ? true }:
let let
pkgs = import ./. { pkgs = import ./. {
inherit system nixosTestIsPerl; inherit system nixosTestIsPerl dockerSupportsSystemd nixosHasPodmanDockerSocket;
nixpkgsSrc = sources.${nixpkgsSource}; nixpkgsSrc = sources.${nixpkgsSource};
}; };
in in

View file

@ -3,6 +3,8 @@
, nixpkgsSrc ? sources.${nixpkgsName} , nixpkgsSrc ? sources.${nixpkgsName}
, system ? builtins.currentSystem , system ? builtins.currentSystem
, nixosTestIsPerl ? false , nixosTestIsPerl ? false
, dockerSupportsSystemd ? false
, nixosHasPodmanDockerSocket ? true
, ... , ...
}: }:
@ -11,8 +13,12 @@ import nixpkgsSrc ({
config = { config = {
}; };
overlays = [ overlays = [
# all the packages are defined there: (_: _: {
(_: _: { inherit nixosTestIsPerl; }) inherit nixosTestIsPerl;
arionTestingFlags = {
inherit nixosTestIsPerl dockerSupportsSystemd nixosHasPodmanDockerSocket;
};
})
(import ./overlay.nix) (import ./overlay.nix)
]; ];
inherit system; inherit system;

View file

@ -36,15 +36,15 @@
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz" "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
}, },
"nixos-unstable": { "nixos-unstable": {
"branch": "nixos-unstable", "branch": "wip-arion-prs",
"description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to", "description": "A read-only mirror of NixOS/nixpkgs tracking the released channels. Send issues and PRs to",
"homepage": "https://github.com/NixOS/nixpkgs", "homepage": "https://github.com/NixOS/nixpkgs",
"owner": "NixOS", "owner": "hercules-ci",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "296793637b22bdb4d23b479879eba0a71c132a66", "rev": "4f5e5257f4385bb178f2b14393c06bada5fdb65e",
"sha256": "0j09yih9693w5vjx64ikfxyja1ha7pisygrwrpg3wfz3sssglg69", "sha256": "0m60fvajhx90hamn6arl3ifvbzfwrl2c80v5j44lwcl6n2bjgcmb",
"type": "tarball", "type": "tarball",
"url": "https://github.com/NixOS/nixpkgs/archive/296793637b22bdb4d23b479879eba0a71c132a66.tar.gz", "url": "https://github.com/hercules-ci/nixpkgs/archive/4f5e5257f4385bb178f2b14393c06bada5fdb65e.tar.gz",
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz", "url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
"version": "" "version": ""
}, },

View file

@ -2,14 +2,14 @@
"services": { "services": {
"webserver": { "webserver": {
"command": [ "command": [
"/nix/store/b9w61w4g8sqgrm3rid6ca22krslqghb3-nixos-system-unnamed-19.03.173100.e726e8291b2/init" "/usr/sbin/init"
], ],
"environment": { "environment": {
"NIX_REMOTE": "", "NIX_REMOTE": "",
"PATH": "/usr/bin:/run/current-system/sw/bin/", "PATH": "/usr/bin:/run/current-system/sw/bin/",
"container": "docker" "container": "docker"
}, },
"image": "arion-base:<HASH>", "image": "webserver:<HASH>",
"ports": [ "ports": [
"8000:80" "8000:80"
], ],
@ -23,8 +23,7 @@
"tty": true, "tty": true,
"volumes": [ "volumes": [
"/sys/fs/cgroup:/sys/fs/cgroup:ro", "/sys/fs/cgroup:/sys/fs/cgroup:ro",
"/nix/store:/nix/store:ro", "/nix/store:/nix/store:ro"
"/nix/store/pssdmhzjnhflawv7rwk1yw39350iv40g-container-system-env:/run/system:ro"
] ]
} }
}, },
@ -32,8 +31,8 @@
"x-arion": { "x-arion": {
"images": [ "images": [
{ {
"image": "<STOREPATH>", "imageExe": "<STOREPATH>",
"imageName": "arion-base", "imageName": "webserver",
"imageTag": "<HASH>" "imageTag": "<HASH>"
} }
], ],

View file

@ -24,7 +24,13 @@ in
../nixos/default-shell.nix ../nixos/default-shell.nix
(pkgs.path + "/nixos/modules/profiles/minimal.nix") (pkgs.path + "/nixos/modules/profiles/minimal.nix")
]; ];
image.command = [ "${config.nixos.build.toplevel}/init" ]; image.command = [ "/usr/sbin/init" ];
image.contents = [
(pkgs.runCommand "root-init" {} ''
mkdir -p $out/usr/sbin
ln -s ${config.nixos.build.toplevel}/init $out/usr/sbin/init
'')
];
service.environment.container = "docker"; service.environment.container = "docker";
service.environment.PATH = "/usr/bin:/run/current-system/sw/bin/"; service.environment.PATH = "/usr/bin:/run/current-system/sw/bin/";
service.volumes = [ service.volumes = [

View file

@ -1,4 +1,4 @@
{ pkgs, ... }: { usePodman ? false, pkgs, lib, ... }:
let let
# To make some prebuilt derivations available in the vm # To make some prebuilt derivations available in the vm
@ -6,14 +6,26 @@ let
inherit modules; inherit modules;
inherit pkgs; inherit pkgs;
}; };
inherit (lib)
optionalAttrs
optionalString
;
haveSystemd = usePodman || pkgs.arionTestingFlags.dockerSupportsSystemd;
in in
{ {
name = "arion-test"; name = "arion-test";
machine = { pkgs, lib, ... }: { machine = { pkgs, lib, ... }: {
environment.systemPackages = [ environment.systemPackages = [
pkgs.arion pkgs.arion
]; ] ++ lib.optional usePodman pkgs.docker;
virtualisation.docker.enable = true; virtualisation.docker.enable = !usePodman;
virtualisation.podman = optionalAttrs usePodman {
enable = true;
dockerSocket.enable = true;
};
# no caches, because no internet # no caches, because no internet
nix.binaryCaches = lib.mkForce []; nix.binaryCaches = lib.mkForce [];
@ -38,6 +50,7 @@ in
]; ];
virtualisation.memorySize = 1024; virtualisation.memorySize = 1024;
virtualisation.diskSize = 8000;
}; };
testScript = '' testScript = ''
machine.fail("curl --fail localhost:8000") machine.fail("curl --fail localhost:8000")
@ -71,6 +84,7 @@ in
# machine.succeed("cd work && NIX_PATH= arion down") # machine.succeed("cd work && NIX_PATH= arion down")
# machine.wait_until_fails("curl --fail localhost:8000") # machine.wait_until_fails("curl --fail localhost:8000")
${optionalString haveSystemd ''
# Tests # Tests
# - arion exec # - arion exec
# - examples/full-nixos # - examples/full-nixos
@ -95,6 +109,7 @@ in
"cd work && NIX_PATH=nixpkgs='${pkgs.path}' arion down" "cd work && NIX_PATH=nixpkgs='${pkgs.path}' arion down"
) )
machine.wait_until_fails("curl --fail localhost:8000") machine.wait_until_fails("curl --fail localhost:8000")
''}
# Tests # Tests
# - examples/nixos-unit # - examples/nixos-unit

View file

@ -1,4 +1,4 @@
{ pkgs ? import ../pkgs.nix, nixosTestIsPerl ? false }: { pkgs ? import ../pkgs.nix, nixosTestIsPerl ? false, arionTestingFlags ? {} }:
let let
inherit (pkgs) nixosTest recurseIntoAttrs arion; inherit (pkgs) nixosTest recurseIntoAttrs arion;
in in
@ -6,6 +6,10 @@ in
recurseIntoAttrs { recurseIntoAttrs {
test = if nixosTestIsPerl then nixosTest ./arion-test-perl else nixosTest ./arion-test; test = if nixosTestIsPerl then nixosTest ./arion-test-perl else nixosTest ./arion-test;
testWithPodman =
if arionTestingFlags.nixosHasPodmanDockerSocket
then nixosTest (pkgs.callPackage ./arion-test { usePodman = true; })
else {};
testBuild = arion.build { testBuild = arion.build {