nixpkgs/nixos/tests/fluentd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

50 lines
1.1 KiB
Nix
Raw Normal View History

2019-11-09 21:45:52 +03:00
import ./make-test-python.nix ({ pkgs, lib, ... }: {
2019-07-29 18:35:27 +03:00
name = "fluentd";
2022-03-21 02:15:30 +03:00
nodes.machine = { pkgs, ... }: {
2019-07-29 18:35:27 +03:00
services.fluentd = {
enable = true;
config = ''
<source>
@type http
port 9880
</source>
<match **>
type copy
<store>
@type file
format json
path /tmp/fluentd
symlink_path /tmp/current-log
</store>
<store>
@type stdout
</store>
</match>
'';
};
};
testScript = let
testMessage = "an example log message";
payload = pkgs.writeText "test-message.json" (builtins.toJSON {
inherit testMessage;
});
in ''
2019-11-09 21:45:52 +03:00
machine.start()
machine.wait_for_unit("fluentd.service")
machine.wait_for_open_port(9880)
2019-07-29 18:35:27 +03:00
2019-11-09 21:45:52 +03:00
machine.succeed(
"curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"
)
2019-07-29 18:35:27 +03:00
2019-11-09 21:45:52 +03:00
# blocking flush
machine.succeed("systemctl stop fluentd")
2019-07-29 18:35:27 +03:00
2019-11-09 21:45:52 +03:00
machine.succeed("grep '${testMessage}' /tmp/current-log")
2019-07-29 18:35:27 +03:00
'';
})