-
-
Save aszlig/0c845fa29645866d5f879feac3f9d194 to your computer and use it in GitHub Desktop.
VM test for reproducing https://github.com/NixOS/nixpkgs/issues/30289
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let | |
dockerConfig = { pkgs, ... }: { | |
virtualisation.docker.enable = true; | |
virtualisation.docker.package = pkgs.docker; | |
virtualisation.docker.liveRestore = false; | |
}; | |
dockerImage = { | |
name = "rabbitmq"; | |
hash = "bcdfca2f591e9d8e88d4002305b480b036e4b9a1ab26b517e853446f2d20b815"; | |
}; | |
imageSpec = with dockerImage; "${name}@sha256:${hash}"; | |
in import <nixpkgs/nixos/tests/make-test.nix> { | |
name = "docker-swarm"; | |
machine = { config, lib, pkgs, ... }: let | |
saved-image = (import <nixpkgs/nixos/lib/testing.nix> { | |
inherit (config.nixpkgs) system; | |
}).runInMachine { | |
drv = pkgs.runCommand "docker-image" { | |
outputHashAlgo = "sha256"; | |
outputHash = "1jy0pb38d4fbbr3sh9y74x4gqrvbd3kppwhwyg8w3xxyfzdfb27z"; | |
outputHashMode = "recursive"; | |
nativeBuildInputs = [ pkgs.docker ]; | |
} '' | |
docker pull ${imageSpec} | |
docker save ${imageSpec} > "$out/image.tar" | |
''; | |
machine = dockerConfig; | |
}; | |
in { | |
system.build.saved-image = saved-image; | |
imports = [ dockerConfig ]; | |
}; | |
testScript = { nodes, ... }: let | |
inherit (nodes.machine.config.networking) primaryIPAddress; | |
inherit (nodes.machine.config.system.build) saved-image; | |
in '' | |
$machine->waitForUnit('multi-user.target'); | |
$machine->succeed( | |
'docker swarm init --advertise-addr=${primaryIPAddress}', | |
'docker network create ci -d overlay', | |
'docker load -i ${saved-image}/image.tar', | |
); | |
$machine->succeed('docker service create --name rabbit --detach=false '. | |
'-p 15672:15672 "$(docker images --format "{{.ID}}")"'); | |
$machine->succeed('curl http://127.0.0.1:15672/ >&2'); | |
''; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment