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