0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10:33 +03:00

Merge pull request #269199 from jnsgruk/lxd-ui-0.4

This commit is contained in:
Ryan Lahfa 2023-11-24 21:48:14 +01:00 committed by GitHub
commit 264ddf3f05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 68 additions and 115 deletions

View file

@ -11,9 +11,37 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: {
lxd.ui.enable = true;
};
environment.systemPackages = [ pkgs.curl ];
environment.systemPackages =
let
seleniumScript = pkgs.writers.writePython3Bin "selenium-script"
{
libraries = with pkgs.python3Packages; [ selenium ];
} ''
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.support.ui import WebDriverWait
options = Options()
options.add_argument("--headless")
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
driver = webdriver.Firefox(options=options, service=service)
driver.implicitly_wait(10)
driver.get("https://localhost:8443/ui")
wait = WebDriverWait(driver, 60)
assert len(driver.find_elements(By.CLASS_NAME, "l-application")) > 0
assert len(driver.find_elements(By.CLASS_NAME, "l-navigation__drawer")) > 0
driver.close()
'';
in
with pkgs; [ curl firefox-unwrapped geckodriver seleniumScript ];
};
testScript = ''
machine.wait_for_unit("sockets.target")
machine.wait_for_unit("lxd.service")
@ -31,5 +59,8 @@ import ../make-test-python.nix ({ pkgs, lib, ... }: {
# Ensure the endpoint returns an HTML page with 'LXD UI' in the title
machine.succeed("curl -kLs https://localhost:8443/ui | grep '<title>LXD UI</title>'")
# Ensure the application is actually rendered by the Javascript
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
'';
})