1import ../make-test-python.nix ({ pkgs, lib, ... }: {
2 name = "lxd-ui";
3
4 meta = with pkgs.lib.maintainers; {
5 maintainers = [ jnsgruk ];
6 };
7
8 nodes.machine = { lib, ... }: {
9 virtualisation = {
10 lxd.enable = true;
11 lxd.ui.enable = true;
12 };
13
14 environment.systemPackages = [ pkgs.curl ];
15 };
16
17 testScript = ''
18 machine.wait_for_unit("sockets.target")
19 machine.wait_for_unit("lxd.service")
20 machine.wait_for_file("/var/lib/lxd/unix.socket")
21
22 # Wait for lxd to settle
23 machine.succeed("lxd waitready")
24
25 # Configure LXC listen address
26 machine.succeed("lxc config set core.https_address :8443")
27 machine.succeed("systemctl restart lxd")
28
29 # Check that the LXD_UI environment variable is populated in the systemd unit
30 machine.succeed("cat /etc/systemd/system/lxd.service | grep 'LXD_UI'")
31
32 # Ensure the endpoint returns an HTML page with 'LXD UI' in the title
33 machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>LXD UI</title>'")
34 '';
35})