Skip to content

Commit

Permalink
Merge pull request #74114 from andrew-d/andrew/syncthing-tests-python
Browse files Browse the repository at this point in the history
nixosTests.syncthing*: port to python
  • Loading branch information
worldofpeace authored Nov 25, 2019
2 parents b0fa7bc + 7398211 commit 7188210
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
12 changes: 5 additions & 7 deletions nixos/tests/syncthing-init.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, pkgs, ... }: let
import ./make-test-python.nix ({ lib, pkgs, ... }: let

testId = "7CFNTQM-IMTJBHJ-3UWRDIU-ZGQJFR6-VCXZ3NB-XUH3KZO-N52ITXR-LAIYUAU";

Expand All @@ -22,13 +22,11 @@ in {
};

testScript = ''
my $config;
$machine->waitForUnit("syncthing-init.service");
$config = $machine->succeed("cat /var/lib/syncthing/.config/syncthing/config.xml");
machine.wait_for_unit("syncthing-init.service")
config = machine.succeed("cat /var/lib/syncthing/.config/syncthing/config.xml")
$config =~ /${testId}/ or die;
$config =~ /testFolder/ or die;
assert "testFolder" in config
assert "${testId}" in config
'';
})

14 changes: 9 additions & 5 deletions nixos/tests/syncthing-relay.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import ./make-test.nix ({ lib, pkgs, ... }: {
import ./make-test-python.nix ({ lib, pkgs, ... }: {
name = "syncthing-relay";
meta.maintainers = with pkgs.stdenv.lib.maintainers; [ delroth ];

Expand All @@ -14,9 +14,13 @@ import ./make-test.nix ({ lib, pkgs, ... }: {
};

testScript = ''
$machine->waitForUnit("syncthing-relay.service");
$machine->waitForOpenPort(12345);
$machine->waitForOpenPort(12346);
$machine->succeed("curl http://localhost:12346/status | jq -r '.options.\"provided-by\"'") =~ /nixos-test/ or die;
machine.wait_for_unit("syncthing-relay.service")
machine.wait_for_open_port(12345)
machine.wait_for_open_port(12346)
out = machine.succeed(
"curl -sS http://localhost:12346/status | jq -r '.options.\"provided-by\"'"
)
assert "nixos-test" in out
'';
})

0 comments on commit 7188210

Please sign in to comment.