diff options
author | oxalica <oxalicc@pm.me> | 2022-10-18 23:50:44 +0800 |
---|---|---|
committer | oxalica <oxalicc@pm.me> | 2022-10-24 08:52:25 +0800 |
commit | 50eb816d2994682b3269205b5cf7a4bdeb4a482c (patch) | |
tree | c96b010790ac0d5d7aa4cb5a40b7676d6989ad55 /nixos/tests/btrbk-section-order.nix | |
parent | 1e684b371cf05300bc2b432f958f285855bac8fb (diff) |
nixos/btrbk: fix ordering of subsections and refactor
Diffstat (limited to 'nixos/tests/btrbk-section-order.nix')
-rw-r--r-- | nixos/tests/btrbk-section-order.nix | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/nixos/tests/btrbk-section-order.nix b/nixos/tests/btrbk-section-order.nix new file mode 100644 index 0000000000000..20f1afcf80ec7 --- /dev/null +++ b/nixos/tests/btrbk-section-order.nix @@ -0,0 +1,51 @@ +# This tests validates the order of generated sections that may contain +# other sections. +# When a `volume` section has both `subvolume` and `target` children, +# `target` must go before `subvolume`. Otherwise, `target` will become +# a child of the last `subvolume` instead of `volume`, due to the +# order-sensitive config format. +# +# Issue: https://github.com/NixOS/nixpkgs/issues/195660 +import ./make-test-python.nix ({ lib, pkgs, ... }: { + name = "btrbk-section-order"; + meta.maintainers = with lib.maintainers; [ oxalica ]; + + nodes.machine = { ... }: { + services.btrbk.instances.local = { + onCalendar = null; + settings = { + timestamp_format = "long"; + target."ssh://global-target/".ssh_user = "root"; + volume."/btrfs" = { + snapshot_dir = "/volume-snapshots"; + target."ssh://volume-target/".ssh_user = "root"; + subvolume."@subvolume" = { + snapshot_dir = "/subvolume-snapshots"; + target."ssh://subvolume-target/".ssh_user = "root"; + }; + }; + }; + }; + }; + + testScript = '' + machine.wait_for_unit("basic.target") + got = machine.succeed("cat /etc/btrbk/local.conf") + expect = """ + backend btrfs-progs-sudo + timestamp_format long + target ssh://global-target/ + ssh_user root + volume /btrfs + snapshot_dir /volume-snapshots + target ssh://volume-target/ + ssh_user root + subvolume @subvolume + snapshot_dir /subvolume-snapshots + target ssh://subvolume-target/ + ssh_user root + """.strip() + print(got) + assert got == expect + ''; +}) |