at 23.11-pre 1.1 kB view raw
1let 2 # arbitrary address 3 ipAddr = "192.168.42.42"; 4in 5import ./make-test-python.nix ({ lib, pkgs, ... }: { 6 name = "apcupsd"; 7 meta.maintainers = with lib.maintainers; [ bjornfor ]; 8 9 nodes = { 10 machine = { 11 services.apcupsd = { 12 enable = true; 13 configText = '' 14 UPSTYPE usb 15 BATTERYLEVEL 42 16 # Configure NISIP so that the only way apcaccess can work is to read 17 # this config. 18 NISIP ${ipAddr} 19 ''; 20 }; 21 networking.interfaces.eth1 = { 22 ipv4.addresses = [{ 23 address = ipAddr; 24 prefixLength = 24; 25 }]; 26 }; 27 }; 28 }; 29 30 # Check that the service starts, that the CLI (apcaccess) works and that it 31 # uses the config (ipAddr) defined in the service config. 32 testScript = '' 33 start_all() 34 machine.wait_for_unit("apcupsd.service") 35 machine.wait_for_open_port(3551, "${ipAddr}") 36 res = machine.succeed("apcaccess") 37 expect_line="MBATTCHG : 42 Percent" 38 assert "MBATTCHG : 42 Percent" in res, f"expected apcaccess output to contain '{expect_line}' but got '{res}'" 39 machine.shutdown() 40 ''; 41})