1 import ../make-test-python.nix ({ pkgs, lib, incus ? pkgs.incus-lts, ... }: {
5 maintainers = lib.teams.lxc.members;
8 nodes.machine = { lib, ... }: {
14 incus.ui.enable = true;
16 networking.nftables.enable = true;
18 environment.systemPackages =
20 seleniumScript = pkgs.writers.writePython3Bin "selenium-script"
22 libraries = with pkgs.python3Packages; [ selenium ];
24 from selenium import webdriver
25 from selenium.webdriver.common.by import By
26 from selenium.webdriver.firefox.options import Options
27 from selenium.webdriver.support.ui import WebDriverWait
30 options.add_argument("--headless")
31 service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
33 driver = webdriver.Firefox(options=options, service=service)
34 driver.implicitly_wait(10)
35 driver.get("https://localhost:8443/ui")
37 wait = WebDriverWait(driver, 60)
39 assert len(driver.find_elements(By.CLASS_NAME, "l-application")) > 0
40 assert len(driver.find_elements(By.CLASS_NAME, "l-navigation__drawer")) > 0
45 with pkgs; [ curl firefox-unwrapped geckodriver seleniumScript ];
50 machine.wait_for_unit("sockets.target")
51 machine.wait_for_unit("incus.service")
52 machine.wait_for_file("/var/lib/incus/unix.socket")
54 # Configure incus listen address
55 machine.succeed("incus config set core.https_address :8443")
56 machine.succeed("systemctl restart incus")
58 # Check that the INCUS_UI environment variable is populated in the systemd unit
59 machine.succeed("cat /etc/systemd/system/incus.service | grep 'INCUS_UI'")
61 # Ensure the endpoint returns an HTML page with 'Incus UI' in the title
62 machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>Incus UI</title>'")
64 # Ensure the application is actually rendered by the Javascript
65 machine.succeed("PYTHONUNBUFFERED=1 selenium-script")