Contract checking between services
Do these two services still fit together?
valerify answers that question at build time. Every service version is described by a spec sheet that is generated from its code. valerify compares what one side needs with what the other side offers, field by field, and ends with an exit status that a pipeline understands.
- Input
- Spec sheets: JSON documents generated from code by an extractor
- Output
- A report of findings and an exit status: 0 fits, 1 errors found, 2 could not do the job
- Runs
- As a one-shot step in CI, in the consumer's repository, the provider's, or both
- Written in
- Rust, a single statically linked binary
- Scope of version 1
- HTTP/REST with JSON bodies
The problem
Two services agree on how they talk to each other, but nothing keeps that agreement true. A
provider renames a field, lets a value become null, widens a number, removes an
endpoint. Its own tests pass. The consumer's tests pass as well, because they run against fixtures
that describe how the provider used to behave. The break shows up when both are deployed together,
or later.
Hand-written mocks and fixtures
They describe what somebody once believed about the other side. They keep passing after the other side has changed.
Recorded interactions
They cover what the tests happened to exercise. A field that no test touches is not part of the contract.
Shared integration environments
They find a mismatch late, only when both sides are deployed together, and they are infrastructure that has to be kept running.
valerify moves the question into the build of either side, without running either service. It compares what the code of one side says it needs with what the code of the other side says it offers. The answer does not depend on which test happened to run.
How it works, in short
1. Extract
An extractor runs as a step of the service's own build and reads the code. It never starts the service.
2. Describe
The result is a spec sheet: what the service offers and what it needs from each upstream.
3. Compare
valerify checkcompares the sheet of the project with the others, as a consumer and as a provider.4. Decide
Findings are errors, warnings or infos. Whether an error fails the run depends on where the check runs.
Read on
- How it works Consumer and provider, gate and report, the project files, the exit statuses.
- In action What the tool prints: a version that fits and one that does not.
- Limits What valerify checks, and what it does not and says so.
- Future What is considered next, what is open, and what is left out on purpose.
- Write an extractor What a spec sheet is and what an extractor has to do.
- Where things are The tracker, the documentation and the repositories.