forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bees.nix
36 lines (32 loc) · 1.14 KB
/
bees.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import ./make-test.nix ({ lib, ... }:
{
name = "bees";
machine = { config, pkgs, ... }: {
boot.initrd.postDeviceCommands = ''
${pkgs.btrfs-progs}/bin/mkfs.btrfs -f -L aux /dev/vdb
'';
virtualisation.emptyDiskImages = [ 4096 ];
fileSystems = lib.mkVMOverride {
"/home" = {
device = "/dev/disk/by-label/aux";
fsType = "btrfs";
};
};
services.beesd.filesystems = {
aux = {
spec = "LABEL=aux";
hashTableSizeMB = 16;
};
};
};
testScript = ''
$machine->succeed("dd if=/dev/urandom of=/home/dedup-me-1 bs=1M count=8");
$machine->succeed("cp --reflink=never /home/dedup-me-1 /home/dedup-me-2");
$machine->succeed("sync");
$machine->succeed("systemctl start beesd\@aux.service");
# FIXME: Need to do a better job at polling
$machine->succeed("sleep 10");
# assert that "Set Shared" column is nonzero
$machine->succeed(q(max_tests=10; sleep_time=2; for ((i=0; i<max_tests; i++)); do [[ $(btrfs fi du -s --raw /home/dedup-me-{1,2} | awk 'NR>1 { print $3 }' | grep -E '^0$' | wc -l) -eq 0 ]] && exit 0; sleep "$sleep_time"; done));
'';
})