Merge pull request #74764 from mmilata/radicale-python-test
nixosTests.radicale: port to python
This commit is contained in:
commit
85a345327f
@ -28,7 +28,7 @@ let
|
||||
|
||||
in
|
||||
|
||||
import ./make-test.nix ({ lib, ... }@args: {
|
||||
import ./make-test-python.nix ({ lib, ... }@args: {
|
||||
name = "radicale";
|
||||
meta.maintainers = with lib.maintainers; [ aneeshusa infinisil ];
|
||||
|
||||
@ -64,43 +64,59 @@ in
|
||||
newSystem = nodes.${nodeName}.config.system.build.toplevel;
|
||||
in "${newSystem}/bin/switch-to-configuration test";
|
||||
in ''
|
||||
# Check Radicale 1 functionality
|
||||
$radicale->succeed('${switchToConfig "radicale1"} >&2');
|
||||
$radicale->waitForUnit('radicale.service');
|
||||
$radicale->waitForOpenPort(${port});
|
||||
$radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
|
||||
with subtest("Check Radicale 1 functionality"):
|
||||
radicale.succeed(
|
||||
"${switchToConfig "radicale1"} >&2"
|
||||
)
|
||||
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
|
||||
$radicale->succeed('systemctl stop radicale');
|
||||
$radicale->succeed('ls -al /tmp/collections');
|
||||
$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');
|
||||
with subtest("Export data in Radicale 2 format"):
|
||||
radicale.succeed("systemctl stop radicale")
|
||||
radicale.succeed("ls -al /tmp/collections")
|
||||
radicale.fail("ls -al /tmp/collections-new")
|
||||
|
||||
# Verify data in Radicale 2 format
|
||||
$radicale->succeed('rm -r /tmp/collections/${user}');
|
||||
$radicale->succeed('mv /tmp/collections-new/collection-root /tmp/collections');
|
||||
$radicale->succeed('${switchToConfig "radicale2_verify"} >&2');
|
||||
$radicale->waitUntilFails('systemctl status radicale');
|
||||
my ($retcode, $logs) = $radicale->execute('journalctl -u radicale -n 10');
|
||||
if ($retcode != 0 || index($logs, 'Verifying storage') == -1) {
|
||||
die "Radicale 2 didn't verify storage"
|
||||
}
|
||||
if (index($logs, 'failed') != -1 || index($logs, 'exception') != -1) {
|
||||
die "storage verification failed"
|
||||
}
|
||||
with subtest("Radicale exits immediately after exporting storage"):
|
||||
radicale.succeed(
|
||||
"${switchToConfig "radicale1_export"} >&2"
|
||||
)
|
||||
radicale.wait_until_fails("systemctl status radicale")
|
||||
radicale.succeed("ls -al /tmp/collections")
|
||||
radicale.succeed("ls -al /tmp/collections-new")
|
||||
|
||||
# Check Radicale 2 functionality
|
||||
$radicale->succeed('${switchToConfig "radicale2"} >&2');
|
||||
$radicale->waitForUnit('radicale.service');
|
||||
$radicale->waitForOpenPort(${port});
|
||||
my ($retcode, $output) = $radicale->execute('curl --fail http://${user}:${password}@localhost:${port}/someuser/calendar.ics/');
|
||||
if ($retcode != 0 || index($output, 'VCALENDAR') == -1) {
|
||||
die "Could not read calendar from Radicale 2"
|
||||
}
|
||||
$radicale->succeed('curl --fail http://${user}:${password}@localhost:${port}/.web/');
|
||||
with subtest("Verify data in Radicale 2 format"):
|
||||
radicale.succeed("rm -r /tmp/collections/${user}")
|
||||
radicale.succeed("mv /tmp/collections-new/collection-root /tmp/collections")
|
||||
radicale.succeed(
|
||||
"${switchToConfig "radicale2_verify"} >&2"
|
||||
)
|
||||
radicale.wait_until_fails("systemctl status radicale")
|
||||
|
||||
(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