parent
a9085572f2
commit
ab404806ff
@ -1051,7 +1051,7 @@ in {
|
|||||||
scaphandre = handleTest ./scaphandre.nix {};
|
scaphandre = handleTest ./scaphandre.nix {};
|
||||||
schleuder = handleTest ./schleuder.nix {};
|
schleuder = handleTest ./schleuder.nix {};
|
||||||
scion-freestanding-deployment = handleTest ./scion/freestanding-deployment {};
|
scion-freestanding-deployment = handleTest ./scion/freestanding-deployment {};
|
||||||
scrutiny = handleTest ./scrutiny.nix {};
|
scrutiny = runTest ./scrutiny.nix;
|
||||||
sddm = handleTest ./sddm.nix {};
|
sddm = handleTest ./sddm.nix {};
|
||||||
sdl3 = handleTest ./sdl3.nix { };
|
sdl3 = handleTest ./sdl3.nix { };
|
||||||
seafile = handleTest ./seafile.nix {};
|
seafile = handleTest ./seafile.nix {};
|
||||||
|
@ -1,100 +1,98 @@
|
|||||||
import ./make-test-python.nix (
|
{ lib, ... }:
|
||||||
{ lib, ... }:
|
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "scrutiny";
|
name = "scrutiny";
|
||||||
meta.maintainers = with lib.maintainers; [ jnsgruk ];
|
meta.maintainers = with lib.maintainers; [ jnsgruk ];
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
machine =
|
machine =
|
||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
pkgs,
|
pkgs,
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
services = {
|
services = {
|
||||||
scrutiny = {
|
scrutiny = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
notify.urls = [
|
notify.urls = [
|
||||||
{
|
{
|
||||||
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
|
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
|
||||||
echo "HelloWorld" > /run/scrutiny/hello
|
echo "HelloWorld" > /run/scrutiny/hello
|
||||||
''}";
|
''}";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
|
||||||
};
|
};
|
||||||
scrutiny.collector.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
|
environment.systemPackages =
|
||||||
machine.wait_for_unit("scrutiny")
|
let
|
||||||
machine.wait_for_open_port(8080)
|
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
|
||||||
|
|
||||||
# Ensure the API responds as we expect
|
options = Options()
|
||||||
output = machine.succeed("curl localhost:8080/api/health")
|
options.add_argument("--headless")
|
||||||
assert output == '{"success":true}'
|
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
|
||||||
|
|
||||||
# Start the collector service to send some metrics
|
driver = webdriver.Firefox(options=options, service=service)
|
||||||
collect = machine.succeed("systemctl start scrutiny-collector.service")
|
driver.implicitly_wait(10)
|
||||||
|
driver.get("http://localhost:8080/web/dashboard")
|
||||||
|
|
||||||
# Ensure the application is actually rendered by the Javascript
|
wait = WebDriverWait(driver, 10).until(
|
||||||
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
|
EC.text_to_be_present_in_element(
|
||||||
|
(By.TAG_NAME, "body"), "Drive health at a glance")
|
||||||
|
)
|
||||||
|
|
||||||
# Test notification and genJqSecretsReplacementSnippet
|
body_text = driver.find_element(By.TAG_NAME, "body").text
|
||||||
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
|
assert "Temperature history for each device" in body_text
|
||||||
machine.wait_for_file("/run/scrutiny/hello")
|
|
||||||
output = machine.succeed("cat /run/scrutiny/hello")
|
driver.close()
|
||||||
assert "HelloWorld" in output
|
'';
|
||||||
'';
|
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")
|
||||||
|
|
||||||
|
# Test notification and genJqSecretsReplacementSnippet
|
||||||
|
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
|
||||||
|
machine.wait_for_file("/run/scrutiny/hello")
|
||||||
|
output = machine.succeed("cat /run/scrutiny/hello")
|
||||||
|
assert "HelloWorld" in output
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user