1import ./make-test-python.nix (
2 { pkgs, lib, ... }:
3 {
4 name = "fluentd";
5
6 nodes.machine =
7 { pkgs, ... }:
8 {
9 services.fluentd = {
10 enable = true;
11 config = ''
12 <source>
13 @type http
14 port 9880
15 </source>
16
17 <match **>
18 type copy
19 <store>
20 @type file
21 format json
22 path /tmp/fluentd
23 symlink_path /tmp/current-log
24 </store>
25 <store>
26 @type stdout
27 </store>
28 </match>
29 '';
30 };
31 };
32
33 testScript =
34 let
35 testMessage = "an example log message";
36
37 payload = pkgs.writeText "test-message.json" (
38 builtins.toJSON {
39 inherit testMessage;
40 }
41 );
42 in
43 ''
44 machine.start()
45 machine.wait_for_unit("fluentd.service")
46 machine.wait_for_open_port(9880)
47
48 machine.succeed(
49 "curl -fsSL -X POST -H 'Content-type: application/json' -d @${payload} http://localhost:9880/test.tag"
50 )
51
52 # blocking flush
53 machine.succeed("systemctl stop fluentd")
54
55 machine.succeed("grep '${testMessage}' /tmp/current-log")
56 '';
57 }
58)