python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / nixos / tests / syncthing.nix
blobaff1d87441308d05694662941bfc3102a5b56660
1 import ./make-test-python.nix ({ lib, pkgs, ... }: {
2   name = "syncthing";
3   meta.maintainers = with pkgs.lib.maintainers; [ chkno ];
5   nodes = rec {
6     a = {
7       environment.systemPackages = with pkgs; [ curl libxml2 syncthing ];
8       services.syncthing = {
9         enable = true;
10         openDefaultPorts = true;
11       };
12     };
13     b = a;
14   };
16   testScript = ''
17     import json
18     import shlex
20     confdir = "/var/lib/syncthing/.config/syncthing"
23     def addPeer(host, name, deviceID):
24         APIKey = host.succeed(
25             "xmllint --xpath 'string(configuration/gui/apikey)' %s/config.xml" % confdir
26         ).strip()
27         oldConf = host.succeed(
28             "curl -Ssf -H 'X-API-Key: %s' 127.0.0.1:8384/rest/config" % APIKey
29         )
30         conf = json.loads(oldConf)
31         conf["devices"].append({"deviceID": deviceID, "id": name})
32         conf["folders"].append(
33             {
34                 "devices": [{"deviceID": deviceID}],
35                 "id": "foo",
36                 "path": "/var/lib/syncthing/foo",
37                 "rescanIntervalS": 1,
38             }
39         )
40         newConf = json.dumps(conf)
41         host.succeed(
42             "curl -Ssf -H 'X-API-Key: %s' 127.0.0.1:8384/rest/config -X PUT -d %s"
43             % (APIKey, shlex.quote(newConf))
44         )
47     start_all()
48     a.wait_for_unit("syncthing.service")
49     b.wait_for_unit("syncthing.service")
50     a.wait_for_open_port(22000)
51     b.wait_for_open_port(22000)
53     aDeviceID = a.succeed("syncthing -home=%s -device-id" % confdir).strip()
54     bDeviceID = b.succeed("syncthing -home=%s -device-id" % confdir).strip()
55     addPeer(a, "b", bDeviceID)
56     addPeer(b, "a", aDeviceID)
58     a.wait_for_file("/var/lib/syncthing/foo")
59     b.wait_for_file("/var/lib/syncthing/foo")
60     a.succeed("echo a2b > /var/lib/syncthing/foo/a2b")
61     b.succeed("echo b2a > /var/lib/syncthing/foo/b2a")
62     a.wait_for_file("/var/lib/syncthing/foo/b2a")
63     b.wait_for_file("/var/lib/syncthing/foo/a2b")
64   '';