aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/tests/borgbackup.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/tests/borgbackup.nix')
-rw-r--r--nixpkgs/nixos/tests/borgbackup.nix122
1 files changed, 66 insertions, 56 deletions
diff --git a/nixpkgs/nixos/tests/borgbackup.nix b/nixpkgs/nixos/tests/borgbackup.nix
index 165f64b0d6d..d97471e293e 100644
--- a/nixpkgs/nixos/tests/borgbackup.nix
+++ b/nixpkgs/nixos/tests/borgbackup.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, ... }:
+import ./make-test-python.nix ({ pkgs, ... }:
let
passphrase = "supersecret";
@@ -106,60 +106,70 @@ in {
};
testScript = ''
- startAll;
-
- $client->fail('test -d "${remoteRepo}"');
-
- $client->succeed("cp ${privateKey} /root/id_ed25519");
- $client->succeed("chmod 0600 /root/id_ed25519");
- $client->succeed("cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly");
- $client->succeed("chmod 0600 /root/id_ed25519.appendOnly");
-
- $client->succeed("mkdir -p ${dataDir}");
- $client->succeed("touch ${dataDir}/${excludeFile}");
- $client->succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}");
-
- subtest "local", sub {
- my $borg = "BORG_PASSPHRASE='${passphrase}' borg";
- $client->systemctl("start --wait borgbackup-job-local");
- $client->fail("systemctl is-failed borgbackup-job-local");
- # Make sure exactly one archive has been created
- $client->succeed("c=\$($borg list '${localRepo}' | wc -l) && [[ \$c == '1' ]]");
- # Make sure excludeFile has been excluded
- $client->fail("$borg list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'");
- # Make sure keepFile has the correct content
- $client->succeed("$borg extract '${localRepo}::${archiveName}'");
- $client->succeed('c=$(cat ${dataDir}/${keepFile}) && [[ "$c" == "${keepFileData}" ]]');
- # Make sure the same is true when using `borg mount`
- $client->succeed("mkdir -p /mnt/borg && $borg mount '${localRepo}::${archiveName}' /mnt/borg");
- $client->succeed('c=$(cat /mnt/borg/${dataDir}/${keepFile}) && [[ "$c" == "${keepFileData}" ]]');
- };
-
- subtest "remote", sub {
- my $borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg";
- $server->waitForUnit("sshd.service");
- $client->waitForUnit("network.target");
- $client->systemctl("start --wait borgbackup-job-remote");
- $client->fail("systemctl is-failed borgbackup-job-remote");
-
- # Make sure we can't access repos other than the specified one
- $client->fail("$borg list borg\@server:wrong");
-
- #TODO: Make sure that data is actually deleted
- };
-
- subtest "remoteAppendOnly", sub {
- my $borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg";
- $server->waitForUnit("sshd.service");
- $client->waitForUnit("network.target");
- $client->systemctl("start --wait borgbackup-job-remoteAppendOnly");
- $client->fail("systemctl is-failed borgbackup-job-remoteAppendOnly");
-
- # Make sure we can't access repos other than the specified one
- $client->fail("$borg list borg\@server:wrong");
-
- #TODO: Make sure that data is not actually deleted
- };
-
+ start_all()
+
+ client.fail('test -d "${remoteRepo}"')
+
+ client.succeed(
+ "cp ${privateKey} /root/id_ed25519"
+ )
+ client.succeed("chmod 0600 /root/id_ed25519")
+ client.succeed(
+ "cp ${privateKeyAppendOnly} /root/id_ed25519.appendOnly"
+ )
+ client.succeed("chmod 0600 /root/id_ed25519.appendOnly")
+
+ client.succeed("mkdir -p ${dataDir}")
+ client.succeed("touch ${dataDir}/${excludeFile}")
+ client.succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}")
+
+ with subtest("local"):
+ borg = "BORG_PASSPHRASE='${passphrase}' borg"
+ client.systemctl("start --wait borgbackup-job-local")
+ client.fail("systemctl is-failed borgbackup-job-local")
+ # Make sure exactly one archive has been created
+ assert int(client.succeed("{} list '${localRepo}' | wc -l".format(borg))) > 0
+ # Make sure excludeFile has been excluded
+ client.fail(
+ "{} list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'".format(borg)
+ )
+ # Make sure keepFile has the correct content
+ client.succeed("{} extract '${localRepo}::${archiveName}'".format(borg))
+ assert "${keepFileData}" in client.succeed("cat ${dataDir}/${keepFile}")
+ # Make sure the same is true when using `borg mount`
+ client.succeed(
+ "mkdir -p /mnt/borg && {} mount '${localRepo}::${archiveName}' /mnt/borg".format(
+ borg
+ )
+ )
+ assert "${keepFileData}" in client.succeed(
+ "cat /mnt/borg/${dataDir}/${keepFile}"
+ )
+
+ with subtest("remote"):
+ borg = "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519' borg"
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-remote")
+ client.fail("systemctl is-failed borgbackup-job-remote")
+
+ # Make sure we can't access repos other than the specified one
+ client.fail("{} list borg\@server:wrong".format(borg))
+
+ # TODO: Make sure that data is actually deleted
+
+ with subtest("remoteAppendOnly"):
+ borg = (
+ "BORG_RSH='ssh -oStrictHostKeyChecking=no -i /root/id_ed25519.appendOnly' borg"
+ )
+ server.wait_for_unit("sshd.service")
+ client.wait_for_unit("network.target")
+ client.systemctl("start --wait borgbackup-job-remoteAppendOnly")
+ client.fail("systemctl is-failed borgbackup-job-remoteAppendOnly")
+
+ # Make sure we can't access repos other than the specified one
+ client.fail("{} list borg\@server:wrong".format(borg))
+
+ # TODO: Make sure that data is not actually deleted
'';
})