Note
This page is generated from src/devops/CONTRIBUTING.md. Edit the repository file, not this copy.
Contributing to DevOps and tests
This guide is for adding tests, benchmarks and repository tooling. For everyday commands, start with the DevOps README.
Add a test
1. Find the production contract
Choose the area that owns the behaviour, such as Search, Index, CodecKit, Store, Mapping or TextIntegration.
2. Choose the test role
| Category | Use it when |
|---|---|
Unit |
A focused component contract has a direct expected result |
Integration |
Behaviour crosses meaningful production, file or process boundaries |
Chaos |
Generated data, corruption, hostile conditions or operation histories expose the risk |
Techniques such as property-based, state-machine and metamorphic testing describe how a test works. They do not require separate projects.
3. Put the test under the owning area
src/devops/tests/Rowles.LeanCorpus.Tests.Core/
Search/
Unit/
Integration/
Chaos/
Do not create a new test project merely because a test uses a different technique.
4. Add metadata
[Category(TestCategory.Unit)]
[Area(TestArea.Search)]
public sealed class MyQueryTests
{
}
Use multiple areas only for a genuinely cross-cutting contract:
[Category(TestCategory.Integration)]
[Area(TestArea.Index)]
[Area(TestArea.Store)]
public sealed class IndexPersistenceTests
{
}
5. Run the focused selection
./devops test core --area Search --category Unit
6. Connect new production paths
Affected testing follows this flow:
flowchart LR
Change["Changed production path"] --> Mapping[".config/devops/code-areas.json"]
Mapping --> Targets["suite:area targets"]
Targets --> Traits["Tests with matching Area traits"]
Traits --> Run["Focused test projects"]
Update .config/devops/code-areas.json when adding or moving a production area.
7. Run affected tests
./devops test affected
./devops test affected --commit HEAD
./devops test affected --commit caf4bd5
./devops test affected --range HEAD~3..HEAD
Plain affected selects modified, staged and untracked non-ignored files only.
-Commit and -Range select only the named commit or explicit range, ignoring
unrelated dirty state; they are mutually exclusive and require affected.
Invalid revisions, unmapped paths and zero targets are hard failures. Selection
provenance is retained in the normal test run.json when artefacts are enabled.
If the test accompanies a user-visible feature or fix, make sure the underlying change is represented in the current release changelog.
Choose a useful oracle
| Technique | Useful oracle |
|---|---|
| Unit | Direct value, boundary or error assertion |
| Integration | Observable API, index or filesystem result |
| Property-based | Invariant, reference model or round trip |
| State machine | Model transition plus observable postcondition |
| Metamorphic | Defined relation between equivalent executions |
| Corruption | Explicit rejection or bounded fallback |
| Native AOT | Successful publish and execution |
Prefer stable logical IDs and stored fields over internal document IDs, segment names or incidental timing.
Warning
“Nothing threw” can be a robustness property, but it is rarely a complete correctness oracle.
Add a property test
Use FsCheck when a rule matters across many inputs:
decode(encode(x)) == x
normalise(normalise(x)) == normalise(x)
forceMerge(index(x)) preserves logical results
generated offsets remain inside the source text
Metadata normally includes:
[Category(TestCategory.Chaos)]
[Area(TestArea.Index)]
[Technique(TestTechnique.PropertyBased)]
Keep generators bounded and meaningful. Retain explicit examples where they communicate the contract more clearly.
Add a state machine
State machines are useful when failure depends on a history such as add, delete, commit, refresh, merge, reopen and rollback.
Place them under:
<Area>/Chaos/StateMachine/
Each machine should have:
- a simple reference model;
- an isolated system-under-test harness;
- explicit operations and model transitions;
- postconditions over observable behaviour;
- readable operation descriptions for shrinking.
Important
Each machine owns its filesystem, writer and readers. Shared mutable fixtures make shrinking and reproduction unreliable.
Add a metamorphic test
Use a metamorphic test when two executions should have a defined relationship:
sequential indexing is set-equivalent to concurrent indexing
unmerged results exactly match force-merged results
serialise then deserialise preserves the observation
Place tests under <Area>/Chaos/Metamorphic/ and use the shared relations in Rowles.LeanCorpus.Tests.Shared/Metamorphic/ where appropriate.
Compare logical results, not incidental segment layout or timing.
Add DevOps tooling
Choose the destination by responsibility:
| Change | Location |
|---|---|
| Managed command options and routing | src/devops/tooling/Rowles.LeanCorpus.DevOps/Program.cs |
| Command handlers and services | src/devops/tooling/Rowles.LeanCorpus.DevOps/Commands/ and their owning service directories |
| Test, benchmark and area configuration | .config/devops/*.json |
| Run artefacts and cleanup | src/devops/tooling/Rowles.LeanCorpus.DevOps/Artifacts/ |
| Package and CI validation | Managed services and tests under src/devops/tooling/Rowles.LeanCorpus.DevOps/; package policy under .config/devops/package-policy.json; workflow-specific admission checks under .github/scripts/ |
For a new top-level command:
- Add the command options and route to the managed root command in
Program.cs. - Keep orchestration in a managed handler or service with an explicit result contract.
- Add concise help, one useful example and command-line contract coverage.
- Put generic helpers and declarative configuration in their owning directories.
- Exercise the route through the managed apphost and run focused or affected tests.
- Update contributor documentation and the DevOps changelog when behaviour changes.
Keep the root apphost as the normal entry point. devops.ps1 remains a small
fingerprint-checking compatibility shim and must not import a second command
implementation. Retained PowerShell files are limited to the bootstrap,
managed-host forwarding, CI checks, independent data generation and package
validation; command behaviour belongs to the managed apphost.
Test execution infrastructure
All normal, affected, repeated, flaky and CI test commands use the shared
target pipeline. Add suite details such as the project, runner kind, supported
frameworks, coverage eligibility and diagnostic capabilities to
.config/devops/test-suites.json; do not duplicate that information in
workflow YAML or another runner.
The pipeline resolves concrete targets, prepares each project or AOT publish
once, then starts a fresh process for every iteration. Artifact-producing runs
checkpoint state.json after each target under
artifacts/test/runs/<run-id>/. Missing or malformed MTP TRX data must remain
an incomplete result, never a pass. Keep report generation in the common
finalisation path so a failed target still leaves usable evidence.
Use -Profile unit for test-case parallelisation, -Profile integration for
the collection-parallel default, and -Profile stress only for deliberate
contention. -CI and -Flaky select summary telemetry. -Flaky defaults to 30
repetitions and the stress profile, unless the caller supplies a profile. Only
-Diagnostics enables full managed telemetry and MTP diagnostic logging; it
wins over CI and flaky mode for telemetry selection. Full activity, metric,
runtime and test streams share a 128 MiB cap per target execution, and reports
show record drops and truncation. Individual test summaries are retained and
attached only for failures or telemetry anomalies. Explicit tests remain
excluded unless -Explicit or -ExplicitOnly is selected. Do not add retries
to core, filesystem, concurrency, codec or indexing tests.
Useful local checks include:
./devops test core --count 2 --filter 'FullyQualifiedName~Writer'
./devops test core --count 2 --fail-fast --filter 'FullyQualifiedName~Writer'
./devops test all --ci --framework net10.0
./devops diagnostics ps
Use --diagnostics for MTP diagnostic logs and the standalone
devops diagnostics commands for an explicitly selected process. Do not add
a full trace or memory dump to every repeated test iteration.
The manual GitHub Actions workflows Test Stress and Test Diagnostics
are separate entry points. Stress always supplies --ci --profile stress;
diagnostics supplies --ci --diagnostics --profile integration. Keep both as
thin argument builders over the managed ./devops test command; add suite resolution,
preparation or reporting behaviour to the DevOps pipeline and suite registry,
not to workflow YAML. Keep count and CHAOS_ITERATIONS independent when
documenting or reproducing either run.
Add or change a benchmark
- Select the suite and area that own the workload.
- Keep corpus and setup equivalent to the comparison target.
- Add a fast or dry route for smoke validation.
- Record source commit, framework, strategy, host and corpus provenance.
- Treat BenchmarkDotNet artefacts as evidence and generated pages as presentation.
List registered suites with:
./devops benchmark --list
Validation by change
| Change | Validation |
|---|---|
| Normal test addition | Focused selection, then -Suite affected |
| Test infrastructure | Affected tests plus every directly impacted suite |
| Architecture boundary | ./devops test architecture |
| AOT smoke path | ./devops aot |
| Benchmark registration | ./devops benchmark --list and a bounded smoke run |
| Coverage tooling | ./devops coverage -Clean |
| Documentation tooling | ./devops docs build --skip-benchmarks |
Warning
Generated coverage, benchmark and DocFX output must not be hand-edited. Change the inputs or generator and regenerate it through ./devops.
Repository guides copied into the site are mapped by docs/site-config/imports.json. Add the canonical source and its site destination there, then update docs/content/toc.yml when the page belongs in the top-level navigation. Do not introduce a second metadata file when the repository README already contains the required catalogue or workflow.
Before submitting
- [ ] The test or command has one clear owner.
- [ ] Metadata and affected mappings describe the real contract.
- [ ] The oracle is independent enough to catch the intended failure.
- [ ] Focused and affected validation were run.
- [ ] Platform, AOT and performance claims name their environment.
- [ ] Help, examples and contributor documentation match behaviour.