|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +This file provides guidance to AI coding agents when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +OATs (OpenTelemetry Acceptance Tests) is a declarative test framework for |
| 8 | +OpenTelemetry written in Go. It enables full round-trip testing from |
| 9 | +instrumented applications to the observability stack (LGTM: Loki, Grafana, |
| 10 | +Tempo, Prometheus, Mimir, OpenTelemetry Collector). |
| 11 | + |
| 12 | +Test cases are defined in YAML files with `oats-schema-version: 2` and can |
| 13 | +validate traces (TraceQL), logs (LogQL), metrics (PromQL), and profiles |
| 14 | +(Pyroscope queries) using Docker Compose or Kubernetes backends. |
| 15 | + |
| 16 | +## Build Commands |
| 17 | + |
| 18 | +```bash |
| 19 | +# Build |
| 20 | +mise run build |
| 21 | + |
| 22 | +# Run unit tests |
| 23 | +mise run test |
| 24 | + |
| 25 | +# Run integration tests (requires Docker) |
| 26 | +mise run integration-test |
| 27 | + |
| 28 | +# Run end-to-end tests |
| 29 | +mise run e2e-test |
| 30 | + |
| 31 | +# Run all checks (lint + test + format check) |
| 32 | +mise run check |
| 33 | +``` |
| 34 | + |
| 35 | +## Linting |
| 36 | + |
| 37 | +```bash |
| 38 | +# Auto-fix and verify (recommended dev workflow) |
| 39 | +mise run fix |
| 40 | + |
| 41 | +# Verify only (same command used in CI) |
| 42 | +mise run lint |
| 43 | + |
| 44 | +# Go linting only |
| 45 | +mise run lint:go |
| 46 | + |
| 47 | +# Format Go code |
| 48 | +mise run fmt |
| 49 | +``` |
| 50 | + |
| 51 | +Lint tasks are sourced from [grafana/flint](https://github.com/grafana/flint). |
| 52 | + |
| 53 | +## Architecture |
| 54 | + |
| 55 | +### Package Organization |
| 56 | + |
| 57 | +- **`main.go`** — CLI entry point. Parses flags, discovers YAML test files, runs them sequentially |
| 58 | +- **`model/`** — Core data models (`TestCaseDefinition`, expected signals) |
| 59 | +- **`yaml/`** — Test case parsing, execution, signal-specific assertions (`runner.go`, `traces.go`, `metrics.go`, `logs.go`, `profiles.go`) |
| 60 | +- **`testhelpers/`** — Docker Compose management, Kubernetes (k3d), HTTP request helpers, response parsing |
| 61 | +- **`observability/`** — Observability endpoint interface |
| 62 | +- **`tests/`** — Integration and e2e test fixtures |
| 63 | + |
| 64 | +### Test Case Schema |
| 65 | + |
| 66 | +Required fields: |
| 67 | + |
| 68 | +- `oats-schema-version: 2` (must be present in all test files) |
| 69 | +- `oats-template: true` (for template files used in `include`) |
| 70 | + |
| 71 | +Core sections: `include`, `docker-compose`, `kubernetes`, `matrix`, `input`, `interval`, `expected` |
| 72 | + |
| 73 | +File discovery scans for `.yaml`/`.yml` files containing `oats-schema-version`. Files with `oats-template: true` are skipped as entry points. `.oatsignore` causes a directory to be ignored. |
| 74 | + |
| 75 | +## CLI Usage |
| 76 | + |
| 77 | +```bash |
| 78 | +# Run specific test file |
| 79 | +oats /path/to/test.yaml |
| 80 | + |
| 81 | +# Scan directory for all tests |
| 82 | +oats /path/to/tests/ |
| 83 | + |
| 84 | +# With flags |
| 85 | +oats -timeout 1m -lgtm-version latest /path/to/test.yaml |
| 86 | +``` |
| 87 | + |
| 88 | +Key flags: `-timeout` (default 30s), `-lgtm-version` (default "latest"), `-manual-debug` (keep containers running) |
| 89 | + |
| 90 | +## Code Conventions |
| 91 | + |
| 92 | +- Go 1.24+ |
| 93 | +- Assertions: gomega |
| 94 | +- YAML parsing: `go.yaml.in/yaml/v3` with strict field validation |
| 95 | +- Logging: `log/slog` |
| 96 | +- Docker: `docker compose` (not legacy `docker-compose`) |
| 97 | + |
| 98 | +## Testing |
| 99 | + |
| 100 | +- Unit tests: `mise run test` |
| 101 | +- Integration tests require `INTEGRATION_TESTS=true` env var |
| 102 | +- Uses gomega for assertions, stretchr/testify for test utilities |
| 103 | + |
| 104 | +## CI |
| 105 | + |
| 106 | +- Build + lint + test on PRs (`mise run check`) |
| 107 | +- Integration tests and e2e tests in separate workflows |
| 108 | +- Linting via flint (super-linter, lychee, golangci-lint) |
0 commit comments