at 23.05-pre 1.6 kB view raw
1# This tests validates the order of generated sections that may contain 2# other sections. 3# When a `volume` section has both `subvolume` and `target` children, 4# `target` must go before `subvolume`. Otherwise, `target` will become 5# a child of the last `subvolume` instead of `volume`, due to the 6# order-sensitive config format. 7# 8# Issue: https://github.com/NixOS/nixpkgs/issues/195660 9import ./make-test-python.nix ({ lib, pkgs, ... }: { 10 name = "btrbk-section-order"; 11 meta.maintainers = with lib.maintainers; [ oxalica ]; 12 13 nodes.machine = { ... }: { 14 services.btrbk.instances.local = { 15 onCalendar = null; 16 settings = { 17 timestamp_format = "long"; 18 target."ssh://global-target/".ssh_user = "root"; 19 volume."/btrfs" = { 20 snapshot_dir = "/volume-snapshots"; 21 target."ssh://volume-target/".ssh_user = "root"; 22 subvolume."@subvolume" = { 23 snapshot_dir = "/subvolume-snapshots"; 24 target."ssh://subvolume-target/".ssh_user = "root"; 25 }; 26 }; 27 }; 28 }; 29 }; 30 31 testScript = '' 32 machine.wait_for_unit("basic.target") 33 got = machine.succeed("cat /etc/btrbk/local.conf") 34 expect = """ 35 backend btrfs-progs-sudo 36 timestamp_format long 37 target ssh://global-target/ 38 ssh_user root 39 volume /btrfs 40 snapshot_dir /volume-snapshots 41 target ssh://volume-target/ 42 ssh_user root 43 subvolume @subvolume 44 snapshot_dir /subvolume-snapshots 45 target ssh://subvolume-target/ 46 ssh_user root 47 """.strip() 48 print(got) 49 assert got == expect 50 ''; 51})