diff options
author | Andrew Childs <lorne@cons.org.nz> | 2019-07-30 00:35:27 +0900 |
---|---|---|
committer | Andrew Childs <lorne@cons.org.nz> | 2019-07-30 00:37:21 +0900 |
commit | a5328e13862f717c8d048c3322e705005dfbd0e7 (patch) | |
tree | 62665616d9bd6e63c6c2c0f79cc4a9b8b8a56b1a /nixos/tests/fluentd.nix | |
parent | 66b551b088756b5f3f97526e5d033fb338edaedc (diff) |
fluentd: add simple test
Diffstat (limited to 'nixos/tests/fluentd.nix')
-rw-r--r-- | nixos/tests/fluentd.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/nixos/tests/fluentd.nix b/nixos/tests/fluentd.nix new file mode 100644 index 000000000000..e5c4c3d21631 --- /dev/null +++ b/nixos/tests/fluentd.nix @@ -0,0 +1,46 @@ +import ./make-test.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->waitForUnit('fluentd.service'); + $machine->waitForOpenPort(9880); + + $machine->succeed("curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"); + + $machine->succeed("systemctl stop fluentd"); # blocking flush + + $machine->succeed("grep '${testMessage}' /tmp/current-log"); + ''; +}) |