1{
2 name = "zram-generator";
3
4 nodes = {
5 single =
6 { ... }:
7 {
8 virtualisation = {
9 emptyDiskImages = [ 512 ];
10 };
11 zramSwap = {
12 enable = true;
13 priority = 10;
14 algorithm = "lz4";
15 swapDevices = 1;
16 memoryPercent = 30;
17 memoryMax = 10 * 1024 * 1024;
18 writebackDevice = "/dev/vdb";
19 };
20 };
21 machine =
22 { ... }:
23 {
24 zramSwap = {
25 enable = true;
26 priority = 10;
27 algorithm = "lz4";
28 swapDevices = 2;
29 memoryPercent = 30;
30 memoryMax = 10 * 1024 * 1024;
31 };
32 };
33 };
34
35 testScript = ''
36 single.wait_for_unit("systemd-zram-setup@zram0.service")
37
38 machine.wait_for_unit("systemd-zram-setup@zram0.service")
39 machine.wait_for_unit("systemd-zram-setup@zram1.service")
40 zram = machine.succeed("zramctl --noheadings --raw")
41 swap = machine.succeed("swapon --show --noheadings --raw")
42 for i in range(2):
43 assert f"/dev/zram{i} lz4 10M" in zram
44 assert f"/dev/zram{i} partition 10M" in swap
45 '';
46}