git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/borgbackup: add test

We had problems to get borg's own test suite running. This test is intended to perform a quick smoke test to see whether we have missed not any important dependency necessary to create backups with borg. tested with: $ nix-build nixos/release.nix -A tests.borgbackup.x86_64-linux

commit8a5f77ffbc8896a1f06ff4d2d61bb48d419cf66b authorJörg Thalheim <joerg@thalheim.io> dateTue 2 Jan 2018, 09:08 (9 years ago) parent57ecb3a
2 files changed+22
nixos/release.nix+1 nixos/tests/borgbackup.nix+21
nixos/release.nix+1
@@ -227,6 +227,7 @@ in rec {
227227 tests.blivet = callTest tests/blivet.nix {};
228228 tests.boot = callSubTests tests/boot.nix {};
229229 tests.boot-stage1 = callTest tests/boot-stage1.nix {};
230+ tests.borgbackup = callTest tests/borgbackup.nix {};
230231 tests.cadvisor = callTestOnTheseSystems ["x86_64-linux"] tests/cadvisor.nix {};
231232 tests.chromium = (callSubTestsOnTheseSystems ["x86_64-linux"] tests/chromium.nix {}).stable;
232233 tests.cjdns = callTest tests/cjdns.nix {};
nixos/tests/borgbackup.nixnew file+21
@@ -0,0 +1,21 @@
1+import ./make-test.nix ({ pkgs, ...}: {
2+ name = "borgbackup";
3+ meta = with pkgs.stdenv.lib.maintainers; {
4+ maintainers = [ mic92 ];
5+ };
6+
7+ nodes = {
8+ machine = { config, pkgs, ... }: {
9+ environment.systemPackages = [ pkgs.borgbackup ];
10+ };
11+ };
12+
13+ testScript = ''
14+ my $borg = "BORG_PASSPHRASE=supersecret borg";
15+ $machine->succeed("$borg init --encryption=repokey /tmp/backup");
16+ $machine->succeed("mkdir /tmp/data/ && echo 'data' >/tmp/data/file");
17+ $machine->succeed("$borg create --stats /tmp/backup::test /tmp/data");
18+ $machine->succeed("$borg extract /tmp/backup::test");
19+ $machine->succeed('c=$(cat data/file) && echo "c = $c" >&2 && [[ "$c" == "data" ]]');
20+ '';
21+})