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