mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 15:13:46 +00:00
4f0dadbf38
After final improvements to the official formatter implementation, this commit now performs the first treewide reformat of Nix files using it. This is part of the implementation of RFC 166. Only "inactive" files are reformatted, meaning only files that aren't being touched by any PR with activity in the past 2 months. This is to avoid conflicts for PRs that might soon be merged. Later we can do a full treewide reformat to get the rest, which should not cause as many conflicts. A CI check has already been running for some time to ensure that new and already-formatted files are formatted, so the files being reformatted here should also stay formatted. This commit was automatically created and can be verified using nix-builda08b3a4d19
.tar.gz \ --argstr baseRevb32a094368
result/bin/apply-formatting $NIXPKGS_PATH
84 lines
2.7 KiB
Nix
84 lines
2.7 KiB
Nix
import ./make-test-python.nix (
|
|
{ lib, ... }:
|
|
|
|
{
|
|
name = "scrutiny";
|
|
meta.maintainers = with lib.maintainers; [ jnsgruk ];
|
|
|
|
nodes = {
|
|
machine =
|
|
{
|
|
self,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
{
|
|
services = {
|
|
scrutiny.enable = true;
|
|
scrutiny.collector.enable = true;
|
|
};
|
|
|
|
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
|
|
from selenium.webdriver.support import expected_conditions as EC
|
|
|
|
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("http://localhost:8080/web/dashboard")
|
|
|
|
wait = WebDriverWait(driver, 10).until(
|
|
EC.text_to_be_present_in_element(
|
|
(By.TAG_NAME, "body"), "Drive health at a glance")
|
|
)
|
|
|
|
body_text = driver.find_element(By.TAG_NAME, "body").text
|
|
assert "Temperature history for each device" in body_text
|
|
|
|
driver.close()
|
|
'';
|
|
in
|
|
with pkgs;
|
|
[
|
|
curl
|
|
firefox-unwrapped
|
|
geckodriver
|
|
seleniumScript
|
|
];
|
|
};
|
|
};
|
|
# This is the test code that will check if our service is running correctly:
|
|
testScript = ''
|
|
start_all()
|
|
|
|
# Wait for Scrutiny to be available
|
|
machine.wait_for_unit("scrutiny")
|
|
machine.wait_for_open_port(8080)
|
|
|
|
# Ensure the API responds as we expect
|
|
output = machine.succeed("curl localhost:8080/api/health")
|
|
assert output == '{"success":true}'
|
|
|
|
# Start the collector service to send some metrics
|
|
collect = machine.succeed("systemctl start scrutiny-collector.service")
|
|
|
|
# Ensure the application is actually rendered by the Javascript
|
|
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
|
|
'';
|
|
}
|
|
)
|