tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixosTests.scrutiny: migrate to runTest
Part of #386873
Moraxyc
1 year ago
ab404806
a9085572
+84
-86
2 changed files
expand all
collapse all
unified
split
nixos
tests
all-tests.nix
scrutiny.nix
+1
-1
nixos/tests/all-tests.nix
reviewed
···
1051
1051
scaphandre = handleTest ./scaphandre.nix {};
1052
1052
schleuder = handleTest ./schleuder.nix {};
1053
1053
scion-freestanding-deployment = handleTest ./scion/freestanding-deployment {};
1054
1054
-
scrutiny = handleTest ./scrutiny.nix {};
1054
1054
+
scrutiny = runTest ./scrutiny.nix;
1055
1055
sddm = handleTest ./sddm.nix {};
1056
1056
sdl3 = handleTest ./sdl3.nix { };
1057
1057
seafile = handleTest ./seafile.nix {};
+83
-85
nixos/tests/scrutiny.nix
reviewed
···
1
1
-
import ./make-test-python.nix (
2
2
-
{ lib, ... }:
1
1
+
{ lib, ... }:
3
2
4
4
-
{
5
5
-
name = "scrutiny";
6
6
-
meta.maintainers = with lib.maintainers; [ jnsgruk ];
3
3
+
{
4
4
+
name = "scrutiny";
5
5
+
meta.maintainers = with lib.maintainers; [ jnsgruk ];
7
6
8
8
-
nodes = {
9
9
-
machine =
10
10
-
{
11
11
-
self,
12
12
-
pkgs,
13
13
-
lib,
14
14
-
...
15
15
-
}:
16
16
-
{
17
17
-
services = {
18
18
-
scrutiny = {
19
19
-
enable = true;
20
20
-
settings = {
21
21
-
notify.urls = [
22
22
-
{
23
23
-
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
24
24
-
echo "HelloWorld" > /run/scrutiny/hello
25
25
-
''}";
26
26
-
}
27
27
-
];
28
28
-
};
7
7
+
nodes = {
8
8
+
machine =
9
9
+
{
10
10
+
self,
11
11
+
pkgs,
12
12
+
lib,
13
13
+
...
14
14
+
}:
15
15
+
{
16
16
+
services = {
17
17
+
scrutiny = {
18
18
+
enable = true;
19
19
+
settings = {
20
20
+
notify.urls = [
21
21
+
{
22
22
+
_secret = pkgs.writeText "notify-script" "script://${pkgs.writeShellScript "touch-test-file" ''
23
23
+
echo "HelloWorld" > /run/scrutiny/hello
24
24
+
''}";
25
25
+
}
26
26
+
];
29
27
};
30
30
-
scrutiny.collector.enable = true;
31
28
};
29
29
+
scrutiny.collector.enable = true;
30
30
+
};
32
31
33
33
-
environment.systemPackages =
34
34
-
let
35
35
-
seleniumScript =
36
36
-
pkgs.writers.writePython3Bin "selenium-script"
37
37
-
{
38
38
-
libraries = with pkgs.python3Packages; [ selenium ];
39
39
-
}
40
40
-
''
41
41
-
from selenium import webdriver
42
42
-
from selenium.webdriver.common.by import By
43
43
-
from selenium.webdriver.firefox.options import Options
44
44
-
from selenium.webdriver.support.ui import WebDriverWait
45
45
-
from selenium.webdriver.support import expected_conditions as EC
32
32
+
environment.systemPackages =
33
33
+
let
34
34
+
seleniumScript =
35
35
+
pkgs.writers.writePython3Bin "selenium-script"
36
36
+
{
37
37
+
libraries = with pkgs.python3Packages; [ selenium ];
38
38
+
}
39
39
+
''
40
40
+
from selenium import webdriver
41
41
+
from selenium.webdriver.common.by import By
42
42
+
from selenium.webdriver.firefox.options import Options
43
43
+
from selenium.webdriver.support.ui import WebDriverWait
44
44
+
from selenium.webdriver.support import expected_conditions as EC
46
45
47
47
-
options = Options()
48
48
-
options.add_argument("--headless")
49
49
-
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
46
46
+
options = Options()
47
47
+
options.add_argument("--headless")
48
48
+
service = webdriver.FirefoxService(executable_path="${lib.getExe pkgs.geckodriver}") # noqa: E501
50
49
51
51
-
driver = webdriver.Firefox(options=options, service=service)
52
52
-
driver.implicitly_wait(10)
53
53
-
driver.get("http://localhost:8080/web/dashboard")
50
50
+
driver = webdriver.Firefox(options=options, service=service)
51
51
+
driver.implicitly_wait(10)
52
52
+
driver.get("http://localhost:8080/web/dashboard")
54
53
55
55
-
wait = WebDriverWait(driver, 10).until(
56
56
-
EC.text_to_be_present_in_element(
57
57
-
(By.TAG_NAME, "body"), "Drive health at a glance")
58
58
-
)
54
54
+
wait = WebDriverWait(driver, 10).until(
55
55
+
EC.text_to_be_present_in_element(
56
56
+
(By.TAG_NAME, "body"), "Drive health at a glance")
57
57
+
)
59
58
60
60
-
body_text = driver.find_element(By.TAG_NAME, "body").text
61
61
-
assert "Temperature history for each device" in body_text
59
59
+
body_text = driver.find_element(By.TAG_NAME, "body").text
60
60
+
assert "Temperature history for each device" in body_text
62
61
63
63
-
driver.close()
64
64
-
'';
65
65
-
in
66
66
-
with pkgs;
67
67
-
[
68
68
-
curl
69
69
-
firefox-unwrapped
70
70
-
geckodriver
71
71
-
seleniumScript
72
72
-
];
73
73
-
};
74
74
-
};
75
75
-
# This is the test code that will check if our service is running correctly:
76
76
-
testScript = ''
77
77
-
start_all()
62
62
+
driver.close()
63
63
+
'';
64
64
+
in
65
65
+
with pkgs;
66
66
+
[
67
67
+
curl
68
68
+
firefox-unwrapped
69
69
+
geckodriver
70
70
+
seleniumScript
71
71
+
];
72
72
+
};
73
73
+
};
74
74
+
# This is the test code that will check if our service is running correctly:
75
75
+
testScript = ''
76
76
+
start_all()
78
77
79
79
-
# Wait for Scrutiny to be available
80
80
-
machine.wait_for_unit("scrutiny")
81
81
-
machine.wait_for_open_port(8080)
78
78
+
# Wait for Scrutiny to be available
79
79
+
machine.wait_for_unit("scrutiny")
80
80
+
machine.wait_for_open_port(8080)
82
81
83
83
-
# Ensure the API responds as we expect
84
84
-
output = machine.succeed("curl localhost:8080/api/health")
85
85
-
assert output == '{"success":true}'
82
82
+
# Ensure the API responds as we expect
83
83
+
output = machine.succeed("curl localhost:8080/api/health")
84
84
+
assert output == '{"success":true}'
86
85
87
87
-
# Start the collector service to send some metrics
88
88
-
collect = machine.succeed("systemctl start scrutiny-collector.service")
86
86
+
# Start the collector service to send some metrics
87
87
+
collect = machine.succeed("systemctl start scrutiny-collector.service")
89
88
90
90
-
# Ensure the application is actually rendered by the Javascript
91
91
-
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
89
89
+
# Ensure the application is actually rendered by the Javascript
90
90
+
machine.succeed("PYTHONUNBUFFERED=1 selenium-script")
92
91
93
93
-
# Test notification and genJqSecretsReplacementSnippet
94
94
-
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
95
95
-
machine.wait_for_file("/run/scrutiny/hello")
96
96
-
output = machine.succeed("cat /run/scrutiny/hello")
97
97
-
assert "HelloWorld" in output
98
98
-
'';
99
99
-
}
100
100
-
)
92
92
+
# Test notification and genJqSecretsReplacementSnippet
93
93
+
machine.succeed("curl -X POST http://localhost:8080/api/health/notify")
94
94
+
machine.wait_for_file("/run/scrutiny/hello")
95
95
+
output = machine.succeed("cat /run/scrutiny/hello")
96
96
+
assert "HelloWorld" in output
97
97
+
'';
98
98
+
}