1 import ./make-test-python.nix ({ lib, pkgs, ... }:
4 # Define an example Quickwit index schema,
5 # and some `exampleDocs` below, to test if ingesting
6 # and querying works as expected.
9 index_id: example_server_logs
18 output_format: iso8601
19 fast_precision: seconds
36 timestamp_field: datetime
39 default_search_fields: [message]
42 commit_timeout_secs: 10
46 {"datetime":"2024-05-03T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Processing request done","location":"path/to/server.c:6442:32","source":""}
47 {"datetime":"2024-05-04T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
48 {"datetime":"2024-05-05T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-1","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
49 {"datetime":"2024-05-06T02:36:41.017674444Z","git":"e6e1f087ce12065e44ed3b87b50784e6f9bcc2f9","hostname":"machine-2","level":"Info","message":"Got exception processing request: HTTP 404","location":"path/to/server.c:6444:32","source":""}
54 meta.maintainers = [ pkgs.lib.maintainers.happysalada ];
57 quickwit = { config, pkgs, ... }: {
58 services.quickwit.enable = true;
64 quickwit.wait_for_unit("quickwit")
65 quickwit.wait_for_open_port(7280)
66 quickwit.wait_for_open_port(7281)
68 quickwit.wait_until_succeeds(
69 "journalctl -o cat -u quickwit.service | grep 'version: ${pkgs.quickwit.version}'"
72 quickwit.wait_until_succeeds(
73 "journalctl -o cat -u quickwit.service | grep 'transitioned to ready state'"
76 with subtest("verify UI installed"):
77 machine.succeed("curl -sSf http://127.0.0.1:7280/ui/")
79 with subtest("injest and query data"):
83 print(machine.succeed('${pkgs.quickwit}/bin/quickwit index create --index-config ${pkgs.writeText "index.yaml" index_yaml}'))
84 # Important to use `--wait`, otherwise the queries below race with index processing.
85 print(machine.succeed('${pkgs.quickwit}/bin/quickwit index ingest --index example_server_logs --input-path ${pkgs.writeText "exampleDocs.json" exampleDocs} --wait'))
88 cli_query_output = machine.succeed('${pkgs.quickwit}/bin/quickwit index search --index example_server_logs --query "exception"')
89 print(cli_query_output)
91 # Assert query result is as expected.
92 num_hits = len(json.loads(cli_query_output)["hits"])
93 assert num_hits == 3, f"cli_query_output contains unexpected number of results: {num_hits}"
96 api_query_output = machine.succeed('curl --fail http://127.0.0.1:7280/api/v1/example_server_logs/search?query=exception')
97 print(api_query_output)
99 quickwit.log(quickwit.succeed(
100 "systemd-analyze security quickwit.service | grep -v '✓'"