nixosTests.containers-imperative: add tmpfiles test
(cherry picked from commit 92600a90e248aa27f2aedcce4ad309f987a390df)
This commit is contained in:
parent
1b7b1dbe2f
commit
bc71b6eaf6
@ -35,7 +35,17 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
testScript =
|
testScript = let
|
||||||
|
tmpfilesContainerConfig = pkgs.writeText "container-config-tmpfiles" ''
|
||||||
|
{
|
||||||
|
systemd.tmpfiles.rules = [ "d /foo - - - - -" ];
|
||||||
|
systemd.services.foo = {
|
||||||
|
serviceConfig.Type = "oneshot";
|
||||||
|
script = "ls -al /foo";
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
''; in
|
||||||
''
|
''
|
||||||
# Make sure we have a NixOS tree (required by ‘nixos-container create’).
|
# Make sure we have a NixOS tree (required by ‘nixos-container create’).
|
||||||
$machine->succeed("PAGER=cat nix-env -qa -A nixos.hello >&2");
|
$machine->succeed("PAGER=cat nix-env -qa -A nixos.hello >&2");
|
||||||
@ -93,6 +103,15 @@ import ./make-test.nix ({ pkgs, ...} : {
|
|||||||
$machine->succeed("nixos-container stop $id1");
|
$machine->succeed("nixos-container stop $id1");
|
||||||
$machine->succeed("nixos-container start $id1");
|
$machine->succeed("nixos-container start $id1");
|
||||||
|
|
||||||
|
# Ensure tmpfiles are present
|
||||||
|
$machine->log("creating container tmpfiles");
|
||||||
|
$machine->succeed("nixos-container create tmpfiles --config-file ${tmpfilesContainerConfig}");
|
||||||
|
$machine->log("created, starting…");
|
||||||
|
$machine->succeed("nixos-container start tmpfiles");
|
||||||
|
$machine->log("done starting, investigating…");
|
||||||
|
$machine->succeed("echo \$(nixos-container run tmpfiles -- systemctl is-active foo.service) | grep -q active;");
|
||||||
|
$machine->succeed("nixos-container destroy tmpfiles");
|
||||||
|
|
||||||
# Execute commands via the root shell.
|
# Execute commands via the root shell.
|
||||||
$machine->succeed("nixos-container run $id1 -- uname") =~ /Linux/ or die;
|
$machine->succeed("nixos-container run $id1 -- uname") =~ /Linux/ or die;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user