tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
nixosTests.goss: init
Anthony Roussel
2 years ago
1efdbc2f
3a2d3bc3
+54
2 changed files
expand all
collapse all
unified
split
nixos
tests
all-tests.nix
goss.nix
+1
nixos/tests/all-tests.nix
···
328
328
gollum = handleTest ./gollum.nix {};
329
329
gonic = handleTest ./gonic.nix {};
330
330
google-oslogin = handleTest ./google-oslogin {};
331
331
+
goss = handleTest ./goss.nix {};
331
332
gotify-server = handleTest ./gotify-server.nix {};
332
333
gotosocial = runTest ./web-apps/gotosocial.nix;
333
334
grafana = handleTest ./grafana {};
+53
nixos/tests/goss.nix
···
1
1
+
import ./make-test-python.nix ({ pkgs, lib, ... }: {
2
2
+
name = "goss";
3
3
+
meta.maintainers = [ lib.maintainers.anthonyroussel ];
4
4
+
5
5
+
nodes.machine = {
6
6
+
environment.systemPackages = [ pkgs.jq ];
7
7
+
8
8
+
services.goss = {
9
9
+
enable = true;
10
10
+
11
11
+
environment = {
12
12
+
GOSS_FMT = "json";
13
13
+
};
14
14
+
15
15
+
settings = {
16
16
+
addr."tcp://localhost:8080" = {
17
17
+
reachable = true;
18
18
+
local-address = "127.0.0.1";
19
19
+
};
20
20
+
command."check-goss-version" = {
21
21
+
exec = "${lib.getExe pkgs.goss} --version";
22
22
+
exit-status = 0;
23
23
+
};
24
24
+
dns.localhost.resolvable = true;
25
25
+
file."/nix" = {
26
26
+
filetype = "directory";
27
27
+
exists = true;
28
28
+
};
29
29
+
group.root.exists = true;
30
30
+
kernel-param."kernel.ostype".value = "Linux";
31
31
+
service.goss = {
32
32
+
enabled = true;
33
33
+
running = true;
34
34
+
};
35
35
+
user.root.exists = true;
36
36
+
};
37
37
+
};
38
38
+
};
39
39
+
40
40
+
testScript = ''
41
41
+
import json
42
42
+
43
43
+
machine.wait_for_unit("goss.service")
44
44
+
machine.wait_for_open_port(8080)
45
45
+
46
46
+
with subtest("returns health status"):
47
47
+
result = json.loads(machine.succeed("curl -sS http://localhost:8080/healthz"))
48
48
+
49
49
+
assert len(result["results"]) == 10, f".results should be an array of 10 items, was {result['results']!r}"
50
50
+
assert result["summary"]["failed-count"] == 0, f".summary.failed-count should be zero, was {result['summary']['failed-count']}"
51
51
+
assert result["summary"]["test-count"] == 10, f".summary.test-count should be 10, was {result['summary']['test-count']}"
52
52
+
'';
53
53
+
})