Skip to content

Commit 1faec56

Browse files
committed
nixosTests/frigate: convert to runTest
Part of #386873
1 parent 5c3df80 commit 1faec56

File tree

2 files changed

+63
-61
lines changed

2 files changed

+63
-61
lines changed

nixos/tests/all-tests.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ in {
410410
freeswitch = handleTest ./freeswitch.nix {};
411411
freetube = discoverTests (import ./freetube.nix);
412412
freshrss = handleTest ./freshrss {};
413-
frigate = handleTest ./frigate.nix {};
413+
frigate = runTest ./frigate.nix;
414414
frp = handleTest ./frp.nix {};
415415
frr = handleTest ./frr.nix {};
416416
fsck = handleTest ./fsck.nix {};

nixos/tests/frigate.nix

Lines changed: 62 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,81 @@
1-
import ./make-test-python.nix (
2-
{ pkgs, lib, ... }:
1+
{
2+
pkgs,
3+
lib,
4+
...
5+
}:
36

4-
{
5-
name = "frigate";
6-
meta.maintainers = with lib.maintainers; [ hexa ];
7+
{
8+
name = "frigate";
9+
meta = { inherit (pkgs.frigate.meta) maintainers; };
710

8-
nodes = {
9-
machine = {
10-
services.frigate = {
11-
enable = true;
11+
nodes = {
12+
machine = {
13+
services.frigate = {
14+
enable = true;
1215

13-
hostname = "localhost";
16+
hostname = "localhost";
1417

15-
settings = {
16-
mqtt.enabled = false;
18+
settings = {
19+
mqtt.enabled = false;
1720

18-
cameras.test = {
19-
ffmpeg = {
20-
input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
21-
inputs = [
22-
{
23-
path = "http://127.0.0.1:8080";
24-
roles = [
25-
"record"
26-
];
27-
}
28-
];
29-
};
21+
cameras.test = {
22+
ffmpeg = {
23+
input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
24+
inputs = [
25+
{
26+
path = "http://127.0.0.1:8080";
27+
roles = [
28+
"record"
29+
];
30+
}
31+
];
3032
};
31-
32-
record.enabled = true;
3333
};
34-
};
3534

36-
systemd.services.video-stream = {
37-
description = "Start a test stream that frigate can capture";
38-
before = [
39-
"frigate.service"
40-
];
41-
wantedBy = [
42-
"multi-user.target"
43-
];
44-
serviceConfig = {
45-
DynamicUser = true;
46-
ExecStart = "${lib.getExe pkgs.ffmpeg-headless} -re -f lavfi -i smptebars=size=1280x720:rate=5 -f mpegts -listen 1 http://0.0.0.0:8080";
47-
Restart = "always";
48-
};
35+
record.enabled = true;
4936
};
37+
};
5038

51-
environment.systemPackages = with pkgs; [ httpie ];
39+
systemd.services.video-stream = {
40+
description = "Start a test stream that frigate can capture";
41+
before = [
42+
"frigate.service"
43+
];
44+
wantedBy = [
45+
"multi-user.target"
46+
];
47+
serviceConfig = {
48+
DynamicUser = true;
49+
ExecStart = "${lib.getExe pkgs.ffmpeg-headless} -re -f lavfi -i smptebars=size=1280x720:rate=5 -f mpegts -listen 1 http://0.0.0.0:8080";
50+
Restart = "always";
51+
};
5252
};
53+
54+
environment.systemPackages = with pkgs; [ httpie ];
5355
};
56+
};
5457

55-
testScript = ''
56-
start_all()
58+
testScript = ''
59+
start_all()
5760
58-
# wait until frigate is up
59-
machine.wait_for_unit("frigate.service")
60-
machine.wait_for_open_port(5001)
61+
# wait until frigate is up
62+
machine.wait_for_unit("frigate.service")
63+
machine.wait_for_open_port(5001)
6164
62-
# extract admin password from logs
63-
machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
64-
password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
65+
# extract admin password from logs
66+
machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
67+
password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
6568
66-
# login and store session
67-
machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
69+
# login and store session
70+
machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
6871
69-
# make authenticated api request
70-
machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
72+
# make authenticated api request
73+
machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
7174
72-
# make unauthenticated api request
73-
machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version"))
75+
# make unauthenticated api request
76+
machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version"))
7477
75-
# wait for a recording to appear
76-
machine.wait_for_file("/var/cache/frigate/test@*.mp4")
77-
'';
78-
}
79-
)
78+
# wait for a recording to appear
79+
machine.wait_for_file("/var/cache/frigate/test@*.mp4")
80+
'';
81+
}

0 commit comments

Comments
 (0)