diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index d1fe552bbc1f..5c81a9cb3ece 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1219,6 +1219,7 @@ in syncthing-no-settings = handleTest ./syncthing-no-settings.nix { }; syncthing-init = handleTest ./syncthing-init.nix { }; syncthing-many-devices = handleTest ./syncthing-many-devices.nix { }; + syncthing-folders = handleTest ./syncthing-folders.nix { }; syncthing-relay = handleTest ./syncthing-relay.nix { }; sysinit-reactivation = runTest ./sysinit-reactivation.nix; systemd = handleTest ./systemd.nix { }; diff --git a/nixos/tests/syncthing-folders.nix b/nixos/tests/syncthing-folders.nix new file mode 100644 index 000000000000..5914aacf0b2a --- /dev/null +++ b/nixos/tests/syncthing-folders.nix @@ -0,0 +1,69 @@ +import ../make-test-python.nix ( + { lib, pkgs, ... }: + let + genNodeId = + name: + pkgs.runCommand "syncthing-test-certs-${name}" { } '' + mkdir -p $out + ${pkgs.syncthing}/bin/syncthing generate --config=$out + ${pkgs.libxml2}/bin/xmllint --xpath 'string(configuration/device/@id)' $out/config.xml > $out/id + ''; + idA = genNodeId "a"; + idB = genNodeId "b"; + in + { + name = "syncthing"; + meta.maintainers = with pkgs.lib.maintainers; [ zarelit ]; + + nodes = { + a = { + services.syncthing = { + enable = true; + openDefaultPorts = true; + cert = "${idA}/cert.pem"; + key = "${idA}/key.pem"; + settings = { + devices.b = { + id = lib.fileContents "${idB}/id"; + }; + folders.foo = { + path = "/var/lib/syncthing/foo"; + devices = [ "b" ]; + }; + }; + }; + }; + b = { + services.syncthing = { + enable = true; + openDefaultPorts = true; + cert = "${idB}/cert.pem"; + key = "${idB}/key.pem"; + settings = { + devices.a = { + id = lib.fileContents "${idA}/id"; + }; + folders.foo = { + path = "/var/lib/syncthing/foo"; + devices = [ "a" ]; + }; + }; + }; + }; + }; + + testScript = '' + start_all() + a.wait_for_unit("syncthing.service") + b.wait_for_unit("syncthing.service") + a.wait_for_open_port(22000) + b.wait_for_open_port(22000) + a.wait_for_file("/var/lib/syncthing/foo") + b.wait_for_file("/var/lib/syncthing/foo") + a.succeed("echo a2b > /var/lib/syncthing/foo/a2b") + b.succeed("echo b2a > /var/lib/syncthing/foo/b2a") + a.wait_for_file("/var/lib/syncthing/foo/b2a") + b.wait_for_file("/var/lib/syncthing/foo/a2b") + ''; + } +)