forked from mirrors/nixpkgs
fetchdocker: Integration test exercising hocker and fetchdocker
This change adds a simple integration test exercising the fetchdocker Nix code and hocker utilities for the simple `hello-world` docker container. We exercise: - Fetching the docker image configuration json - Fetching the docker image layers - Building a compositor script - Loading the `hello-world` docker image into docker using the compositor script and `docker load` - Running that loaded container
This commit is contained in:
parent
25865688a7
commit
c1eb962516
|
@ -262,6 +262,7 @@ in rec {
|
|||
tests.hardened = callTest tests/hardened.nix { };
|
||||
tests.hibernate = callTest tests/hibernate.nix {};
|
||||
tests.hound = callTest tests/hound.nix {};
|
||||
tests.hocker-fetchdocker = callTest tests/hocker-fetchdocker {};
|
||||
tests.i3wm = callTest tests/i3wm.nix {};
|
||||
tests.initrd-network-ssh = callTest tests/initrd-network-ssh {};
|
||||
tests.installer = callSubTests tests/installer.nix {};
|
||||
|
|
15
nixos/tests/hocker-fetchdocker/default.nix
Normal file
15
nixos/tests/hocker-fetchdocker/default.nix
Normal file
|
@ -0,0 +1,15 @@
|
|||
import ../make-test.nix ({ pkgs, ...} : {
|
||||
name = "test-hocker-fetchdocker";
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ ixmatus ];
|
||||
};
|
||||
|
||||
machine = import ./machine.nix;
|
||||
|
||||
testScript = ''
|
||||
startAll;
|
||||
|
||||
$machine->waitForUnit("sockets.target");
|
||||
$machine->waitUntilSucceeds("docker run registry-1.docker.io/v2/library/hello-world:latest");
|
||||
'';
|
||||
})
|
19
nixos/tests/hocker-fetchdocker/hello-world-container.nix
Normal file
19
nixos/tests/hocker-fetchdocker/hello-world-container.nix
Normal file
|
@ -0,0 +1,19 @@
|
|||
{ fetchDockerConfig, fetchDockerLayer, fetchdocker }:
|
||||
fetchdocker rec {
|
||||
name = "hello-world";
|
||||
registry = "https://registry-1.docker.io/v2/";
|
||||
repository = "library";
|
||||
imageName = "hello-world";
|
||||
tag = "latest";
|
||||
imageConfig = fetchDockerConfig {
|
||||
inherit tag registry repository imageName;
|
||||
sha256 = "1ivbd23hyindkahzfw4kahgzi6ibzz2ablmgsz6340vc6qr1gagj";
|
||||
};
|
||||
imageLayers = let
|
||||
layer0 = fetchDockerLayer {
|
||||
inherit registry repository imageName;
|
||||
layerDigest = "ca4f61b1923c10e9eb81228bd46bee1dfba02b9c7dac1844527a734752688ede";
|
||||
sha256 = "1plfd194fwvsa921ib3xkhms1yqxxrmx92r2h7myj41wjaqn2kya";
|
||||
};
|
||||
in [ layer0 ];
|
||||
}
|
31
nixos/tests/hocker-fetchdocker/machine.nix
Normal file
31
nixos/tests/hocker-fetchdocker/machine.nix
Normal file
|
@ -0,0 +1,31 @@
|
|||
{ config, pkgs, ... }:
|
||||
{ nixpkgs.config.packageOverrides = pkgs': {
|
||||
hello-world-container = pkgs'.callPackage ./hello-world-container.nix { };
|
||||
haskellPackages = pkgs'.haskellPackages.override {
|
||||
overrides = new: old: {
|
||||
hocker = pkgs'.haskell.lib.dontCheck old.hocker;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
virtualisation.docker = {
|
||||
enable = true;
|
||||
package = pkgs.docker;
|
||||
};
|
||||
|
||||
systemd.services.docker-load-fetchdocker-image = {
|
||||
description = "Docker load hello-world-container";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "docker.service" "local-fs.target" ];
|
||||
after = [ "docker.service" "local-fs.target" ];
|
||||
|
||||
script = ''
|
||||
${pkgs.hello-world-container}/compositeImage.sh | ${pkgs.docker}/bin/docker load
|
||||
'';
|
||||
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in a new issue