diff options
Diffstat (limited to 'nixos/tests/fluentd.nix')
-rw-r--r-- | nixos/tests/fluentd.nix | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/nixos/tests/fluentd.nix b/nixos/tests/fluentd.nix new file mode 100644 index 00000000000..918f2f87db1 --- /dev/null +++ b/nixos/tests/fluentd.nix @@ -0,0 +1,49 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "fluentd"; + + 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") + ''; +}) |