···
1
-
import ./make-test-python.nix (
6
-
meta.maintainers = with lib.maintainers; [ jnsgruk ];
5
+
meta.maintainers = with lib.maintainers; [ jnsgruk ];
23
-
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
24
-
echo "HelloWorld" > /run/scrutiny/hello
22
+
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
23
+
echo "HelloWorld" > /run/scrutiny/hello
30
-
scrutiny.collector.enable = true;
29
+
scrutiny.collector.enable = true;
33
-
environment.systemPackages =
36
-
pkgs.writers.writePython3Bin "selenium-script"
38
-
libraries = with pkgs.python3Packages; [ selenium ];
41
-
from selenium import webdriver
42
-
from selenium.webdriver.common.by import By
43
-
from selenium.webdriver.firefox.options import Options
44
-
from selenium.webdriver.support.ui import WebDriverWait
45
-
from selenium.webdriver.support import expected_conditions as EC
32
+
environment.systemPackages =
35
+
pkgs.writers.writePython3Bin "selenium-script"
37
+
libraries = with pkgs.python3Packages; [ selenium ];
40
+
from selenium import webdriver
41
+
from selenium.webdriver.common.by import By
42
+
from selenium.webdriver.firefox.options import Options
43
+
from selenium.webdriver.support.ui import WebDriverWait
44
+
from selenium.webdriver.support import expected_conditions as EC
48
-
options.add_argument("--headless")
49
-
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
47
+
options.add_argument("--headless")
48
+
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
51
-
driver = webdriver.Firefox(options=options, service=service)
52
-
driver.implicitly_wait(10)
53
-
driver.get("http://localhost:8080/web/dashboard")
50
+
driver = webdriver.Firefox(options=options, service=service)
51
+
driver.implicitly_wait(10)
52
+
driver.get("http://localhost:8080/web/dashboard")
55
-
wait = WebDriverWait(driver, 10).until(
56
-
EC.text_to_be_present_in_element(
57
-
(By.TAG_NAME, "body"), "Drive health at a glance")
54
+
wait = WebDriverWait(driver, 10).until(
55
+
EC.text_to_be_present_in_element(
56
+
(By.TAG_NAME, "body"), "Drive health at a glance")
60
-
body_text = driver.find_element(By.TAG_NAME, "body").text
61
-
assert "Temperature history for each device" in body_text
59
+
body_text = driver.find_element(By.TAG_NAME, "body").text
60
+
assert "Temperature history for each device" in body_text
75
-
# This is the test code that will check if our service is running correctly:
74
+
# This is the test code that will check if our service is running correctly:
79
-
# Wait for Scrutiny to be available
80
-
machine.wait_for_unit("scrutiny")
81
-
machine.wait_for_open_port(8080)
78
+
# Wait for Scrutiny to be available
79
+
machine.wait_for_unit("scrutiny")
80
+
machine.wait_for_open_port(8080)
83
-
# Ensure the API responds as we expect
84
-
output = machine.succeed("curl localhost:8080/api/health")
85
-
assert output == '{"success":true}'
82
+
# Ensure the API responds as we expect
83
+
output = machine.succeed("curl localhost:8080/api/health")
84
+
assert output == '{"success":true}'
87
-
# Start the collector service to send some metrics
88
-
collect = machine.succeed("systemctl start scrutiny-collector.service")
86
+
# Start the collector service to send some metrics
87
+
collect = machine.succeed("systemctl start scrutiny-collector.service")
90
-
# Ensure the application is actually rendered by the Javascript
91
-
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
89
+
# Ensure the application is actually rendered by the Javascript
90
+
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
93
-
# Test notification and genJqSecretsReplacementSnippet
94
-
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
95
-
machine.wait_for_file("/run/scrutiny/hello")
96
-
output = machine.succeed("cat /run/scrutiny/hello")
97
-
assert "HelloWorld" in output
92
+
# Test notification and genJqSecretsReplacementSnippet
93
+
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
94
+
machine.wait_for_file("/run/scrutiny/hello")
95
+
output = machine.succeed("cat /run/scrutiny/hello")
96
+
assert "HelloWorld" in output