mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-03 20:20:55 +03:00
Merge pull request #300728 from ck3d/nixos-test-machinectl-import-tar
nixos/test/machinectl: Add import-tar test
This commit is contained in:
commit
29b575a0e8
@ -1,7 +1,7 @@
|
||||
import ./make-test-python.nix ({ pkgs, ... }:
|
||||
let
|
||||
|
||||
container = {
|
||||
container = { config, ... }: {
|
||||
# We re-use the NixOS container option ...
|
||||
boot.isContainer = true;
|
||||
# ... and revert unwanted defaults
|
||||
@ -15,6 +15,8 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||
boot.loader.initScript.enable = true;
|
||||
|
||||
imports = [ ../modules/profiles/minimal.nix ];
|
||||
|
||||
system.stateVersion = config.system.nixos.version;
|
||||
};
|
||||
|
||||
containerSystem = (import ../lib/eval-config.nix {
|
||||
@ -25,6 +27,25 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||
containerName = "container";
|
||||
containerRoot = "/var/lib/machines/${containerName}";
|
||||
|
||||
containerTarball = pkgs.callPackage ../lib/make-system-tarball.nix {
|
||||
storeContents = [
|
||||
{
|
||||
object = containerSystem;
|
||||
symlink = "/nix/var/nix/profiles/system";
|
||||
}
|
||||
];
|
||||
|
||||
contents = [
|
||||
{
|
||||
source = containerSystem + "/etc/os-release";
|
||||
target = "/etc/os-release";
|
||||
}
|
||||
{
|
||||
source = containerSystem + "/init";
|
||||
target = "/sbin/init";
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
name = "systemd-machinectl";
|
||||
@ -40,7 +61,7 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||
# auto-start container
|
||||
systemd.targets.machines.wants = [ "systemd-nspawn@${containerName}.service" ];
|
||||
|
||||
virtualisation.additionalPaths = [ containerSystem ];
|
||||
virtualisation.additionalPaths = [ containerSystem containerTarball ];
|
||||
|
||||
systemd.tmpfiles.rules = [
|
||||
"d /var/lib/machines/shared-decl 0755 root root - -"
|
||||
@ -144,6 +165,13 @@ import ./make-test-python.nix ({ pkgs, ... }:
|
||||
# Show to to delete the container
|
||||
machine.succeed("chattr -i ${containerRoot}/var/empty");
|
||||
machine.succeed("rm -rf ${containerRoot}");
|
||||
|
||||
# Test import tarball, start, stop and remove
|
||||
machine.succeed("machinectl import-tar ${containerTarball}/tarball/*.tar* ${containerName}");
|
||||
machine.succeed("machinectl start ${containerName}");
|
||||
machine.wait_until_succeeds("systemctl -M ${containerName} is-active default.target");
|
||||
machine.succeed("machinectl stop ${containerName}");
|
||||
machine.wait_until_succeeds("test $(systemctl is-active systemd-nspawn@${containerName}) = inactive");
|
||||
machine.succeed("machinectl remove ${containerName}");
|
||||
'';
|
||||
}
|
||||
)
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user