1 import ../make-test-python.nix (
12 maintainers = lib.teams.lxc.members;
21 package = if lts then pkgs.incus-lts else pkgs.incus;
23 incus.ui.enable = true;
25 networking.nftables.enable = true;
27 environment.systemPackages =
30 pkgs.writers.writePython3Bin "selenium-script"
32 libraries = with pkgs.python3Packages; [ selenium ];
35 from selenium import webdriver
36 from selenium.webdriver.common.by import By
37 from selenium.webdriver.firefox.options import Options
38 from selenium.webdriver.support.ui import WebDriverWait
41 options.add_argument("--headless")
42 service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
44 driver = webdriver.Firefox(options=options, service=service)
45 driver.implicitly_wait(10)
46 driver.get("https://localhost:8443/ui")
48 wait = WebDriverWait(driver, 60)
50 assert len(driver.find_elements(By.CLASS_NAME, "l-application")) > 0
51 assert len(driver.find_elements(By.CLASS_NAME, "l-navigation__drawer")) > 0
66 machine.wait_for_unit("sockets.target")
67 machine.wait_for_unit("incus.service")
68 machine.wait_for_file("/var/lib/incus/unix.socket")
70 # Configure incus listen address
71 machine.succeed("incus config set core.https_address :8443")
72 machine.succeed("systemctl restart incus")
74 # Check that the INCUS_UI environment variable is populated in the systemd unit
75 machine.succeed("cat /etc/systemd/system/incus.service | grep 'INCUS_UI'")
77 # Ensure the endpoint returns an HTML page with 'Incus UI' in the title
78 machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>Incus UI</title>'")
80 # Ensure the application is actually rendered by the Javascript
81 machine.succeed("PYTHONUNBUFFERED=1 selenium-script")