blob: 17b454d9595e6071f34c9df406ba0168ad428872 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
{ pkgs, ... }:
{
name = "systemd-journal-gateway";
meta = with pkgs.lib.maintainers; {
maintainers = [
minijackson
];
};
# Named client for coherence with the systemd-journal-upload test.
nodes.client = {
services.journald.gateway.enable = true;
};
testScript = ''
import json
client.wait_for_unit("multi-user.target")
curl = '${pkgs.curl}/bin/curl'
accept_json = '--header "Accept: application/json"'
base_url = 'http://client:19531'
curl_cli = f"{curl} {accept_json} --fail"
machine_info = client.succeed(f"{curl_cli} {base_url}/machine")
assert json.loads(machine_info)["hostname"] == "client", "wrong machine name"
# The HTTP request should have started the gateway service, triggered by
# the .socket unit
client.wait_for_unit("systemd-journal-gatewayd.service")
identifier = "nixos-test"
message = "Hello from NixOS test infrastructure"
client.succeed(f"systemd-cat --identifier={identifier} <<< '{message}'")
entries = client.succeed(
f"{curl_cli} {base_url}/entries?SYSLOG_IDENTIFIER={identifier}"
)
# Number of entries should be only 1
added_entry = json.loads(entries)
assert added_entry["SYSLOG_IDENTIFIER"] == identifier and added_entry["MESSAGE"] == message, "journal entry does not correspond"
'';
}
|