2020-11-24 04:53:21 +03:00
|
|
|
import ./make-test-python.nix ({ lib, pkgs, ... }:
|
|
|
|
let inherit (import ./ssh-keys.nix pkgs) snakeOilPrivateKey snakeOilPublicKey;
|
|
|
|
in {
|
|
|
|
name = "locate";
|
2021-01-10 22:08:30 +03:00
|
|
|
meta.maintainers = with pkgs.lib.maintainers; [ chkno ];
|
2020-11-24 04:53:21 +03:00
|
|
|
|
|
|
|
nodes = rec {
|
|
|
|
a = {
|
2020-11-23 08:57:00 +03:00
|
|
|
environment.systemPackages = with pkgs; [ sshfs ];
|
2021-02-14 14:23:50 +03:00
|
|
|
virtualisation.fileSystems = {
|
2020-11-23 08:57:00 +03:00
|
|
|
"/ssh" = {
|
|
|
|
device = "alice@b:/";
|
|
|
|
fsType = "fuse.sshfs";
|
|
|
|
options = [
|
|
|
|
"allow_other"
|
|
|
|
"IdentityFile=/privkey"
|
|
|
|
"noauto"
|
|
|
|
"StrictHostKeyChecking=no"
|
|
|
|
"UserKnownHostsFile=/dev/null"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2020-11-24 04:53:21 +03:00
|
|
|
services.locate = {
|
|
|
|
enable = true;
|
|
|
|
interval = "*:*:0/5";
|
|
|
|
};
|
|
|
|
};
|
2020-11-23 08:57:00 +03:00
|
|
|
b = {
|
|
|
|
services.openssh.enable = true;
|
|
|
|
users.users.alice = {
|
|
|
|
isNormalUser = true;
|
|
|
|
openssh.authorizedKeys.keys = [ snakeOilPublicKey ];
|
|
|
|
};
|
|
|
|
};
|
2020-11-24 04:53:21 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
2020-11-23 08:57:00 +03:00
|
|
|
start_all()
|
|
|
|
|
|
|
|
# Set up sshfs mount
|
|
|
|
a.succeed(
|
|
|
|
"(umask 077; cat ${snakeOilPrivateKey} > /privkey)"
|
|
|
|
)
|
|
|
|
b.succeed("touch /file-on-b-machine")
|
|
|
|
b.wait_for_open_port(22)
|
|
|
|
a.succeed("mkdir /ssh")
|
|
|
|
a.succeed("mount /ssh")
|
|
|
|
|
|
|
|
# Core locatedb functionality
|
2020-11-24 04:53:21 +03:00
|
|
|
a.succeed("touch /file-on-a-machine-1")
|
|
|
|
a.wait_for_file("/var/cache/locatedb")
|
|
|
|
a.wait_until_succeeds("locate file-on-a-machine-1")
|
2020-11-23 08:57:00 +03:00
|
|
|
|
|
|
|
# Wait for a second update to make sure we're using a locatedb from a run
|
|
|
|
# that began after the sshfs mount
|
|
|
|
a.succeed("touch /file-on-a-machine-2")
|
|
|
|
a.wait_until_succeeds("locate file-on-a-machine-2")
|
|
|
|
|
|
|
|
# We shouldn't be able to see files on the other machine
|
|
|
|
a.fail("locate file-on-b-machine")
|
2020-11-24 04:53:21 +03:00
|
|
|
'';
|
|
|
|
})
|