1 import ./make-test-python.nix ({ lib, pkgs, ... }:
5 nodes.machine = { config, pkgs, ... }: {
6 boot.initrd.postDeviceCommands = ''
7 ${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux1 /dev/vdb
8 ${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux2 /dev/vdc
10 virtualisation.emptyDiskImages = [ 4096 4096 ];
11 virtualisation.fileSystems = {
12 "/aux1" = { # filesystem configured to be deduplicated
13 device = "/dev/disk/by-label/aux1";
16 "/aux2" = { # filesystem not configured to be deduplicated
17 device = "/dev/disk/by-label/aux2";
21 services.beesd.filesystems = {
32 someContentIsShared = loc: pkgs.writeShellScript "some-content-is-shared" ''
33 [[ $(btrfs fi du -s --raw ${lib.escapeShellArg loc}/dedup-me-{1,2} | awk 'BEGIN { count=0; } NR>1 && $3 == 0 { count++ } END { print count }') -eq 0 ]]
36 # shut down the instance started by systemd at boot, so we can test our test procedure
37 machine.succeed("systemctl stop beesd@aux1.service")
40 "dd if=/dev/urandom of=/aux1/dedup-me-1 bs=1M count=8",
41 "cp --reflink=never /aux1/dedup-me-1 /aux1/dedup-me-2",
42 "cp --reflink=never /aux1/* /aux2/",
46 "${someContentIsShared "/aux1"}",
47 "${someContentIsShared "/aux2"}",
49 machine.succeed("systemctl start beesd@aux1.service")
51 # assert that "Set Shared" column is nonzero
52 machine.wait_until_succeeds(
53 "${someContentIsShared "/aux1"}",
55 machine.fail("${someContentIsShared "/aux2"}")
57 # assert that 16MB hash table size requested was honored
59 "[[ $(stat -c %s /aux1/.beeshome/beeshash.dat) = $(( 16 * 1024 * 1024)) ]]"