master
md 88 lines 2.47 KB
Rendered Raw
1 # Functions Validation (CLI + Containers)
2
3 ## TL;DR
4 - Bring up databases with Docker Compose.
5 - Use `go.d.plugin --function` with the configs in `./config`.
6 - Config files live under `./config/go.d`.
7 - Validate output against the embedded schema.
8 - Use `./e2e.sh` for automated end-to-end checks in `/tmp` (runs per-DB scripts).
9
10 ## Start containers
11 ```
12 docker compose up -d
13 ```
14
15 ## Example CLI run (Postgres)
16 ```
17 cd ../../../
18 src/go/go.d.plugin \
19 --config-dir src/go/tools/functions-validation/config \
20 --function postgres:top-queries \
21 --function-args info
22 ```
23
24 ## Validate output
25
26 ```
27 echo '{"status":200,"type":"table","columns":{},"data":[]}' | \
28 (cd src/go && go run ./tools/functions-validation/validate)
29 ```
30
31 ## Validate topology v1 fixtures
32
33 ```
34 (cd src/go && \
35 go run ./tools/functions-validation/validate \
36 --schema ../plugins.d/FUNCTION_TOPOLOGY_SCHEMA.json \
37 --input tools/functions-validation/fixtures/topology-v1/network-connections.json)
38 ```
39
40 Topology v1 validation uses the JSON Schema and additional compact-table
41 semantic checks: decoded column lengths must match `rows`, dictionary indexes
42 must be in range, actor/link references must point to existing rows, and
43 correlation rules must reference existing actor/link types and point/claim key
44 columns.
45
46 ## Validate output (require rows)
47 ```
48 src/go/go.d.plugin \
49 --config-dir src/go/tools/functions-validation/config \
50 --function postgres:top-queries \
51 --function-args __job:local \
52 > /tmp/pg.json
53
54 (cd src/go && go run ./tools/functions-validation/validate --input /tmp/pg.json --min-rows 1)
55 ```
56
57 ## E2E runner (recommended)
58 ```
59 ./e2e.sh
60 ```
61 ```
62 ./e2e.sh --jobs 4
63 ```
64 ```
65 ./e2e.sh --only postgres,mysql
66 ```
67 ```
68 ./e2e.sh --list
69 ```
70
71 ## Per-DB E2E (single DB)
72 ```
73 ./e2e/postgres.sh
74 ```
75
76 ### Behavior
77 - Each DB script creates a workspace under `/tmp` and runs Docker Compose there.
78 - Ports are auto-selected per run to avoid collisions.
79 - Builds `go.d.plugin` into the `/tmp` workspace.
80 - Validates schema **and** that data rows are returned for top-queries.
81 - Cleans up the `/tmp` workspace on success; keeps it on failure for debugging.
82
83 ## Notes
84 - The compose file sets credentials that match the sample configs in `./config`.
85 - MSSQL uses an init container to enable Query Store and seed data.
86 - MongoDB enables the profiler to populate `system.profile`.
87 - The validator reads the canonical schema at `src/plugins.d/FUNCTION_UI_SCHEMA.json`.
88 - Topology v1 fixtures live under `src/go/tools/functions-validation/fixtures/topology-v1/`.