mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 12:15:34 +03:00
parent
5c3df8025f
commit
1faec56024
2 changed files with 64 additions and 62 deletions
|
@ -410,7 +410,7 @@ in {
|
||||||
freeswitch = handleTest ./freeswitch.nix {};
|
freeswitch = handleTest ./freeswitch.nix {};
|
||||||
freetube = discoverTests (import ./freetube.nix);
|
freetube = discoverTests (import ./freetube.nix);
|
||||||
freshrss = handleTest ./freshrss {};
|
freshrss = handleTest ./freshrss {};
|
||||||
frigate = handleTest ./frigate.nix {};
|
frigate = runTest ./frigate.nix;
|
||||||
frp = handleTest ./frp.nix {};
|
frp = handleTest ./frp.nix {};
|
||||||
frr = handleTest ./frr.nix {};
|
frr = handleTest ./frr.nix {};
|
||||||
fsck = handleTest ./fsck.nix {};
|
fsck = handleTest ./fsck.nix {};
|
||||||
|
|
|
@ -1,79 +1,81 @@
|
||||||
import ./make-test-python.nix (
|
{
|
||||||
{ pkgs, lib, ... }:
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
{
|
{
|
||||||
name = "frigate";
|
name = "frigate";
|
||||||
meta.maintainers = with lib.maintainers; [ hexa ];
|
meta = { inherit (pkgs.frigate.meta) maintainers; };
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
machine = {
|
machine = {
|
||||||
services.frigate = {
|
services.frigate = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|
||||||
hostname = "localhost";
|
hostname = "localhost";
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
mqtt.enabled = false;
|
mqtt.enabled = false;
|
||||||
|
|
||||||
cameras.test = {
|
cameras.test = {
|
||||||
ffmpeg = {
|
ffmpeg = {
|
||||||
input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
|
input_args = "-fflags nobuffer -strict experimental -fflags +genpts+discardcorrupt -r 10 -use_wallclock_as_timestamps 1";
|
||||||
inputs = [
|
inputs = [
|
||||||
{
|
{
|
||||||
path = "http://127.0.0.1:8080";
|
path = "http://127.0.0.1:8080";
|
||||||
roles = [
|
roles = [
|
||||||
"record"
|
"record"
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
record.enabled = true;
|
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
systemd.services.video-stream = {
|
record.enabled = true;
|
||||||
description = "Start a test stream that frigate can capture";
|
|
||||||
before = [
|
|
||||||
"frigate.service"
|
|
||||||
];
|
|
||||||
wantedBy = [
|
|
||||||
"multi-user.target"
|
|
||||||
];
|
|
||||||
serviceConfig = {
|
|
||||||
DynamicUser = true;
|
|
||||||
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";
|
|
||||||
Restart = "always";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [ httpie ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.video-stream = {
|
||||||
|
description = "Start a test stream that frigate can capture";
|
||||||
|
before = [
|
||||||
|
"frigate.service"
|
||||||
|
];
|
||||||
|
wantedBy = [
|
||||||
|
"multi-user.target"
|
||||||
|
];
|
||||||
|
serviceConfig = {
|
||||||
|
DynamicUser = true;
|
||||||
|
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";
|
||||||
|
Restart = "always";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
environment.systemPackages = with pkgs; [ httpie ];
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
testScript = ''
|
testScript = ''
|
||||||
start_all()
|
start_all()
|
||||||
|
|
||||||
# wait until frigate is up
|
# wait until frigate is up
|
||||||
machine.wait_for_unit("frigate.service")
|
machine.wait_for_unit("frigate.service")
|
||||||
machine.wait_for_open_port(5001)
|
machine.wait_for_open_port(5001)
|
||||||
|
|
||||||
# extract admin password from logs
|
# extract admin password from logs
|
||||||
machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
|
machine.wait_until_succeeds("journalctl -u frigate.service -o cat | grep -q 'Password: '")
|
||||||
password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
|
password = machine.execute("journalctl -u frigate.service -o cat | grep -oP '([a-f0-9]{32})'")[1]
|
||||||
|
|
||||||
# login and store session
|
# login and store session
|
||||||
machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
|
machine.log(machine.succeed(f"http --check-status --session=frigate post http://localhost/api/login user=admin password={password}"))
|
||||||
|
|
||||||
# make authenticated api request
|
# make authenticated api request
|
||||||
machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
|
machine.log(machine.succeed("http --check-status --session=frigate get http://localhost/api/version"))
|
||||||
|
|
||||||
# make unauthenticated api request
|
# make unauthenticated api request
|
||||||
machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version"))
|
machine.log(machine.succeed("http --check-status get http://localhost:5000/api/version"))
|
||||||
|
|
||||||
# wait for a recording to appear
|
# wait for a recording to appear
|
||||||
machine.wait_for_file("/var/cache/frigate/test@*.mp4")
|
machine.wait_for_file("/var/cache/frigate/test@*.mp4")
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
)
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue