1 import ./make-test-python.nix ({ pkgs, lib, ...} :
5 meta.maintainers = with lib.maintainers; [ hexa ];
12 hostname = "localhost";
19 input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
21 path = "http://127.0.0.1:8080";
29 record.enabled = true;
33 systemd.services.video-stream = {
34 description = "Start a test stream that frigate can capture";
43 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";
48 environment.systemPackages = with pkgs; [ httpie ];
55 # wait until frigate is up
56 machine.wait_for_unit("frigate.service")
57 machine.wait_for_open_port(5001)
59 # extract admin password from logs
60 machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
61 password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
63 # login and store session
64 machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
66 # make authenticated api requested
67 machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
69 # wait for a recording to appear
70 machine.wait_for_file("/var/cache/frigate/test@*.mp4")