1 import ../make-test-python.nix ({ pkgs, ... }: {
4 nodes.machine = { lib, ... }: {
10 environment.systemPackages =
12 seleniumScript = pkgs.writers.writePython3Bin "selenium-script"
14 libraries = with pkgs.python3Packages; [ selenium ];
16 from selenium import webdriver
17 from selenium.webdriver.common.by import By
18 from selenium.webdriver.firefox.options import Options
19 from selenium.webdriver.support.ui import WebDriverWait
22 options.add_argument("--headless")
23 service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
25 driver = webdriver.Firefox(options=options, service=service)
26 driver.implicitly_wait(10)
27 driver.get("https://localhost:8443/ui")
29 wait = WebDriverWait(driver, 60)
31 assert len(driver.find_elements(By.CLASS_NAME, "l-application")) > 0
32 assert len(driver.find_elements(By.CLASS_NAME, "l-navigation__drawer")) > 0
37 with pkgs; [ curl firefox-unwrapped geckodriver seleniumScript ];
42 machine.wait_for_unit("sockets.target")
43 machine.wait_for_unit("lxd.service")
44 machine.wait_for_file("/var/lib/lxd/unix.socket")
46 # Wait for lxd to settle
47 machine.succeed("lxd waitready")
49 # Configure LXC listen address
50 machine.succeed("lxc config set core.https_address :8443")
51 machine.succeed("systemctl restart lxd")
53 # Check that the LXD_UI environment variable is populated in the systemd unit
54 machine.succeed("cat /etc/systemd/system/lxd.service | grep 'LXD_UI'")
56 # Ensure the endpoint returns an HTML page with 'LXD UI' in the title
57 machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>LXD UI</title>'")
59 # Ensure the application is actually rendered by the Javascript
60 machine.succeed("PYTHONUNBUFFERED=1 selenium-script")