1import ./make-test-python.nix (
2 { lib, pkgs, ... }:
3 let
4 confPath = "/etc/waagent.conf";
5 in
6 {
7 name = "waagent";
8
9 meta = {
10 maintainers = with lib.maintainers; [ codgician ];
11 };
12
13 nodes.machine = {
14 services.waagent = {
15 enable = true;
16 settings = {
17 Provisioning = {
18 Enable = false;
19 Agent = "waagent";
20 DeleteRootPassword = false;
21 RegenerateSshHostKeyPair = false;
22 SshHostKeyPairType = "ed25519";
23 MonitorHostName = false;
24 };
25 ResourceDisk = {
26 Format = false;
27 MountOptions = [
28 "compress=lzo"
29 "mode=0600"
30 ];
31 };
32 OS.RootDeviceScsiTimeout = 300;
33 HttpProxy = {
34 Host = null;
35 Port = null;
36 };
37 CGroups = {
38 EnforceLimits = false;
39 Excluded = [ ];
40 };
41 };
42 };
43 };
44
45 testScript = ''
46 # Defined values should be reflected in waagent.conf
47 machine.succeed("grep -q '^Provisioning.Enable=n$' '${confPath}'")
48 machine.succeed("grep -q '^Provisioning.Agent=waagent$' '${confPath}'")
49 machine.succeed("grep -q '^Provisioning.DeleteRootPassword=n$' '${confPath}'")
50 machine.succeed("grep -q '^Provisioning.RegenerateSshHostKeyPair=n$' '${confPath}'")
51 machine.succeed("grep -q '^Provisioning.SshHostKeyPairType=ed25519$' '${confPath}'")
52 machine.succeed("grep -q '^Provisioning.MonitorHostName=n$' '${confPath}'")
53 machine.succeed("grep -q '^ResourceDisk.Format=n$' '${confPath}'")
54 machine.succeed("grep -q '^ResourceDisk.MountOptions=compress=lzo,mode=0600$' '${confPath}'")
55 machine.succeed("grep -q '^OS.RootDeviceScsiTimeout=300$' '${confPath}'")
56
57 # Undocumented options should also be supported
58 machine.succeed("grep -q '^CGroups.EnforceLimits=n$' '${confPath}'")
59
60 # Null values should be skipped and not exist in waagent.conf
61 machine.fail("grep -q '^HttpProxy.Host=' '${confPath}'")
62 machine.fail("grep -q '^HttpProxy.Port=' '${confPath}'")
63
64 # Empty lists should be skipped and not exist in waagent.conf
65 machine.fail("grep -q '^CGroups.Excluded=' '${confPath}'")
66
67 # Test service start
68 # Skip testing actual functionality due to lacking Azure infrasturcture
69 machine.wait_for_unit("waagent.service")
70 '';
71 }
72)