depot/third_party/nixpkgs/nixos/tests/fluentd.nix
Default email d56f44df06 Project import generated by Copybara.
GitOrigin-RevId: bc4b9eef3ce3d5a90d8693e8367c9cbfc9fc1e13
2022-04-03 20:54:34 +02:00

49 lines
1.1 KiB
Nix

import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "fluentd";
nodes.machine = { pkgs, ... }: {
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 ''
machine.start()
machine.wait_for_unit("fluentd.service")
machine.wait_for_open_port(9880)
machine.succeed(
"curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"
)
# blocking flush
machine.succeed("systemctl stop fluentd")
machine.succeed("grep '${testMessage}' /tmp/current-log")
'';
})