mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
nixosTests.radicale: port to python
This commit is contained in:
parent
e1456b291c
commit
be911515eb
@ -28,7 +28,7 @@ let
|
|||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
import ./make-test.nix ({ lib, ... }@args: {
|
import ./make-test-python.nix ({ lib, ... }@args: {
|
||||||
name = "radicale";
|
name = "radicale";
|
||||||
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
|
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
|
||||||
|
|
||||||
@ -64,43 +64,59 @@ in
|
|||||||
newSystem = nodes.${nodeName}.config.system.build.toplevel;
|
newSystem = nodes.${nodeName}.config.system.build.toplevel;
|
||||||
in "${newSystem}/bin/switch-to-configuration test";
|
in "${newSystem}/bin/switch-to-configuration test";
|
||||||
in ''
|
in ''
|
||||||
# Check Radicale 1 functionality
|
with subtest("Check Radicale 1 functionality"):
|
||||||
$radicale->succeed('${switchToConfig "radicale1"} >&2');
|
radicale.succeed(
|
||||||
$radicale->waitForUnit('radicale.service');
|
"${switchToConfig "radicale1"} >&2"
|
||||||
$radicale->waitForOpenPort(${port});
|
)
|
||||||
$radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
|
radicale.wait_for_unit("radicale.service")
|
||||||
|
radicale.wait_for_open_port(${port})
|
||||||
|
radicale.succeed(
|
||||||
|
"curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/"
|
||||||
|
)
|
||||||
|
|
||||||
# Export data in Radicale 2 format
|
with subtest("Export data in Radicale 2 format"):
|
||||||
$radicale->succeed('systemctl stop radicale');
|
radicale.succeed("systemctl stop radicale")
|
||||||
$radicale->succeed('ls -al /tmp/collections');
|
radicale.succeed("ls -al /tmp/collections")
|
||||||
$radicale->fail('ls -al /tmp/collections-new');
|
radicale.fail("ls -al /tmp/collections-new")
|
||||||
# Radicale exits immediately after exporting storage
|
|
||||||
$radicale->succeed('${switchToConfig "radicale1_export"} >&2');
|
|
||||||
$radicale->waitUntilFails('systemctl status radicale');
|
|
||||||
$radicale->succeed('ls -al /tmp/collections');
|
|
||||||
$radicale->succeed('ls -al /tmp/collections-new');
|
|
||||||
|
|
||||||
# Verify data in Radicale 2 format
|
with subtest("Radicale exits immediately after exporting storage"):
|
||||||
$radicale->succeed('rm -r /tmp/collections/${user}');
|
radicale.succeed(
|
||||||
$radicale->succeed('mv /tmp/collections-new/collection-root /tmp/collections');
|
"${switchToConfig "radicale1_export"} >&2"
|
||||||
$radicale->succeed('${switchToConfig "radicale2_verify"} >&2');
|
)
|
||||||
$radicale->waitUntilFails('systemctl status radicale');
|
radicale.wait_until_fails("systemctl status radicale")
|
||||||
my ($retcode, $logs) = $radicale->execute('journalctl -u radicale -n 10');
|
radicale.succeed("ls -al /tmp/collections")
|
||||||
if ($retcode != 0 || index($logs, 'Verifying storage') == -1) {
|
radicale.succeed("ls -al /tmp/collections-new")
|
||||||
die "Radicale 2 didn't verify storage"
|
|
||||||
}
|
|
||||||
if (index($logs, 'failed') != -1 || index($logs, 'exception') != -1) {
|
|
||||||
die "storage verification failed"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check Radicale 2 functionality
|
with subtest("Verify data in Radicale 2 format"):
|
||||||
$radicale->succeed('${switchToConfig "radicale2"} >&2');
|
radicale.succeed("rm -r /tmp/collections/${user}")
|
||||||
$radicale->waitForUnit('radicale.service');
|
radicale.succeed("mv /tmp/collections-new/collection-root /tmp/collections")
|
||||||
$radicale->waitForOpenPort(${port});
|
radicale.succeed(
|
||||||
my ($retcode, $output) = $radicale->execute('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
|
"${switchToConfig "radicale2_verify"} >&2"
|
||||||
if ($retcode != 0 || index($output, 'VCALENDAR') == -1) {
|
)
|
||||||
die "Could not read calendar from Radicale 2"
|
radicale.wait_until_fails("systemctl status radicale")
|
||||||
}
|
|
||||||
$radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
|
(retcode, logs) = radicale.execute("journalctl -u radicale -n 10")
|
||||||
|
assert (
|
||||||
|
retcode == 0 and "Verifying storage" in logs
|
||||||
|
), "Radicale 2 didn't verify storage"
|
||||||
|
assert (
|
||||||
|
"failed" not in logs and "exception" not in logs
|
||||||
|
), "storage verification failed"
|
||||||
|
|
||||||
|
with subtest("Check Radicale 2 functionality"):
|
||||||
|
radicale.succeed(
|
||||||
|
"${switchToConfig "radicale2"} >&2"
|
||||||
|
)
|
||||||
|
radicale.wait_for_unit("radicale.service")
|
||||||
|
radicale.wait_for_open_port(${port})
|
||||||
|
|
||||||
|
(retcode, output) = radicale.execute(
|
||||||
|
"curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/"
|
||||||
|
)
|
||||||
|
assert (
|
||||||
|
retcode == 0 and "VCALENDAR" in output
|
||||||
|
), "Could not read calendar from Radicale 2"
|
||||||
|
|
||||||
|
radicale.succeed("curl --fail http://${user}:${password}@localhost:${port}/.web/")
|
||||||
'';
|
'';
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user