Skip to content

Commit 52cc74d

Browse files
committed
Add remote write 2 receivers complicance tests
Signed-off-by: Julien Pivotto <291750+roidelapluie@users.noreply.github.com>
1 parent 1215c9d commit 52cc74d

File tree

13 files changed

+1754
-1
lines changed

13 files changed

+1754
-1
lines changed

remotewrite/receiver/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
results.json
2+
prometheus.yml

remotewrite/receiver/README.md

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,102 @@
1-
We currently do not have a test suite. We plan to introduce one and make it mandatory.
1+
# Prometheus Remote Write v2 Receiver Compliance Test Suite
2+
3+
This repository contains a compliance test suite for Prometheus Remote Write Protocol v2.0 receivers. It validates that remote write endpoints properly implement the Remote Write v2 specification according to the [official protocol requirements](https://prometheus.io/docs/specs/prw/remote_write_spec_2_0/).
4+
5+
## Overview
6+
7+
The test suite sends various Remote Write v2 requests to configured endpoints and validates responses against the protocol specification. It tests proper handling of:
8+
9+
- Sample data ingestion
10+
- Histogram data (including native histograms)
11+
- Exemplar data
12+
- Protocol headers and response codes
13+
- Error conditions and edge cases
14+
- Content-Type validation
15+
- Response header validation (`X-Prometheus-Remote-Write-*-Written`)
16+
17+
## Features
18+
19+
- **Protocol Compliance**: Tests MUST and SHOULD requirements from the Remote Write v2 specification
20+
- **Multi-Endpoint Testing**: Runs tests against multiple remote write configurations
21+
- **Comprehensive Coverage**: Tests samples, histograms, exemplars, and error conditions
22+
- **Response Validation**: Validates HTTP status codes, headers, and response bodies
23+
- **Native Histogram Support**: Full support for Prometheus native histogram format
24+
25+
## Limitations
26+
27+
- No reading of the data.
28+
- Some requests might be accepted by some backends and rejected by others. There is some tolerance w.r.t 200 vs 400 return codes as the receiver is responsible for the validation of the data.
29+
30+
## Prerequisites
31+
32+
- Go 1.25.0 or later
33+
- A Prometheus server with Remote Write Receiver enabled, as baseline:
34+
```bash
35+
prometheus --web.enable-remote-write-receiver --enable-feature=native-histograms
36+
```
37+
- Any other Remote Write Receiver.
38+
39+
## Configuration
40+
41+
Create a `prometheus.yml` file in the root directory with your remote write configurations:
42+
43+
```yaml
44+
remote_write:
45+
- name: local-prometheus
46+
url: http://127.0.0.1:9090/api/v1/write
47+
- name: remote-endpoint
48+
url: https://your-remote-write-endpoint.com/api/v1/write
49+
basic_auth:
50+
username: user
51+
password: pass
52+
```
53+
54+
If no `prometheus.yml` exists, the test suite will fall back to `prometheus_example.yml`.
55+
56+
Alternatively, a configuration file can be provided with the `PROMETHEUS_RW2_COMPLIANCE_CONFIG_FILE` environment variable.
57+
58+
## Running Tests
59+
60+
```bash
61+
# Run all compliance tests
62+
go test -v
63+
64+
# Run tests for a specific area
65+
go test -v -run TestHistograms
66+
go test -v -run TestMetrics
67+
68+
# Run tests with detailed output
69+
go test -v -count=1
70+
```
71+
72+
## HTML visualisation
73+
74+
This repository contains a `index.html` that enables viewing the results of the compliance tests.
75+
76+
It loads a `results.json` that can be generated with:
77+
78+
```bash
79+
go test -json | tee results.json
80+
```
81+
82+
## Protocol Compliance Levels
83+
84+
Tests are marked with compliance levels:
85+
- **MUST**: Required by specification
86+
- **SHOULD**: Recommended by specification
87+
88+
Use `t.Attr("rfcLevel", "MUST")` or `t.Attr("rfcLevel", "SHOULD")` to identify compliance levels.
89+
90+
## Response Validation
91+
92+
The test suite validates:
93+
- HTTP status codes (2xx for success, 4xx for client errors, 5xx for server errors)
94+
- Required response headers (`X-Prometheus-Remote-Write-*-Written`)
95+
96+
## License
97+
98+
Licensed under the Apache License, Version 2.0. See LICENSE file for details.
99+
100+
## Contributing
101+
102+
This is part of the Prometheus project. Please follow the standard Prometheus contribution guidelines.

remotewrite/receiver/go.mod

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
module github.com/prometheus/complicance/remotewrite2
2+
3+
go 1.25.0
4+
5+
require (
6+
github.com/golang/snappy v1.0.0
7+
github.com/prometheus/common v0.65.0
8+
github.com/prometheus/prometheus v0.305.0
9+
github.com/stretchr/testify v1.10.0
10+
)
11+
12+
require (
13+
cloud.google.com/go/auth v0.16.2 // indirect
14+
cloud.google.com/go/auth/oauth2adapt v0.2.8 // indirect
15+
cloud.google.com/go/compute/metadata v0.7.0 // indirect
16+
github.com/Azure/azure-sdk-for-go/sdk/azcore v1.18.0 // indirect
17+
github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.10.1 // indirect
18+
github.com/Azure/azure-sdk-for-go/sdk/internal v1.11.1 // indirect
19+
github.com/AzureAD/microsoft-authentication-library-for-go v1.4.2 // indirect
20+
github.com/alecthomas/units v0.0.0-20240927000941-0f3dac36c52b // indirect
21+
github.com/aws/aws-sdk-go-v2 v1.36.3 // indirect
22+
github.com/aws/aws-sdk-go-v2/config v1.29.14 // indirect
23+
github.com/aws/aws-sdk-go-v2/credentials v1.17.67 // indirect
24+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.30 // indirect
25+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.34 // indirect
26+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.34 // indirect
27+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 // indirect
28+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.3 // indirect
29+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.15 // indirect
30+
github.com/aws/aws-sdk-go-v2/service/sso v1.25.3 // indirect
31+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.30.1 // indirect
32+
github.com/aws/aws-sdk-go-v2/service/sts v1.33.19 // indirect
33+
github.com/aws/smithy-go v1.22.2 // indirect
34+
github.com/beorn7/perks v1.0.1 // indirect
35+
github.com/cespare/xxhash/v2 v2.3.0 // indirect
36+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
37+
github.com/dennwc/varint v1.0.0 // indirect
38+
github.com/felixge/httpsnoop v1.0.4 // indirect
39+
github.com/go-logr/logr v1.4.2 // indirect
40+
github.com/go-logr/stdr v1.2.2 // indirect
41+
github.com/go-viper/mapstructure/v2 v2.2.1 // indirect
42+
github.com/gobwas/glob v0.2.3 // indirect
43+
github.com/gogo/protobuf v1.3.2 // indirect
44+
github.com/golang-jwt/jwt/v5 v5.2.2 // indirect
45+
github.com/google/s2a-go v0.1.9 // indirect
46+
github.com/google/uuid v1.6.0 // indirect
47+
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
48+
github.com/googleapis/gax-go/v2 v2.14.2 // indirect
49+
github.com/grafana/regexp v0.0.0-20240518133315-a468a5bfb3bc // indirect
50+
github.com/hashicorp/go-version v1.7.0 // indirect
51+
github.com/jpillora/backoff v1.0.0 // indirect
52+
github.com/json-iterator/go v1.1.12 // indirect
53+
github.com/klauspost/compress v1.18.0 // indirect
54+
github.com/knadh/koanf/maps v0.1.2 // indirect
55+
github.com/knadh/koanf/providers/confmap v1.0.0 // indirect
56+
github.com/knadh/koanf/v2 v2.2.0 // indirect
57+
github.com/kylelemons/godebug v1.1.0 // indirect
58+
github.com/mitchellh/copystructure v1.2.0 // indirect
59+
github.com/mitchellh/reflectwalk v1.0.2 // indirect
60+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
61+
github.com/modern-go/reflect2 v1.0.2 // indirect
62+
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
63+
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
64+
github.com/open-telemetry/opentelemetry-collector-contrib/internal/exp/metrics v0.128.0 // indirect
65+
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/pdatautil v0.128.0 // indirect
66+
github.com/open-telemetry/opentelemetry-collector-contrib/processor/deltatocumulativeprocessor v0.128.0 // indirect
67+
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
68+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
69+
github.com/prometheus/client_golang v1.22.0 // indirect
70+
github.com/prometheus/client_model v0.6.2 // indirect
71+
github.com/prometheus/otlptranslator v0.0.0-20250527173959-2573485683d5 // indirect
72+
github.com/prometheus/procfs v0.15.1 // indirect
73+
github.com/prometheus/sigv4 v0.2.0 // indirect
74+
github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect
75+
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
76+
go.opentelemetry.io/collector/component v1.34.0 // indirect
77+
go.opentelemetry.io/collector/confmap v1.34.0 // indirect
78+
go.opentelemetry.io/collector/confmap/xconfmap v0.128.0 // indirect
79+
go.opentelemetry.io/collector/consumer v1.34.0 // indirect
80+
go.opentelemetry.io/collector/featuregate v1.34.0 // indirect
81+
go.opentelemetry.io/collector/internal/telemetry v0.128.0 // indirect
82+
go.opentelemetry.io/collector/pdata v1.34.0 // indirect
83+
go.opentelemetry.io/collector/pipeline v0.128.0 // indirect
84+
go.opentelemetry.io/collector/processor v1.34.0 // indirect
85+
go.opentelemetry.io/collector/semconv v0.128.0 // indirect
86+
go.opentelemetry.io/contrib/bridges/otelzap v0.11.0 // indirect
87+
go.opentelemetry.io/contrib/instrumentation/net/http/httptrace/otelhttptrace v0.61.0 // indirect
88+
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.61.0 // indirect
89+
go.opentelemetry.io/otel v1.36.0 // indirect
90+
go.opentelemetry.io/otel/log v0.12.2 // indirect
91+
go.opentelemetry.io/otel/metric v1.36.0 // indirect
92+
go.opentelemetry.io/otel/sdk v1.36.0 // indirect
93+
go.opentelemetry.io/otel/trace v1.36.0 // indirect
94+
go.uber.org/atomic v1.11.0 // indirect
95+
go.uber.org/multierr v1.11.0 // indirect
96+
go.uber.org/zap v1.27.0 // indirect
97+
golang.org/x/crypto v0.39.0 // indirect
98+
golang.org/x/net v0.41.0 // indirect
99+
golang.org/x/oauth2 v0.30.0 // indirect
100+
golang.org/x/sys v0.33.0 // indirect
101+
golang.org/x/text v0.26.0 // indirect
102+
golang.org/x/time v0.12.0 // indirect
103+
google.golang.org/api v0.238.0 // indirect
104+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250603155806-513f23925822 // indirect
105+
google.golang.org/grpc v1.73.0 // indirect
106+
google.golang.org/protobuf v1.36.6 // indirect
107+
gopkg.in/yaml.v2 v2.4.0 // indirect
108+
gopkg.in/yaml.v3 v3.0.1 // indirect
109+
k8s.io/apimachinery v0.32.3 // indirect
110+
k8s.io/client-go v0.32.3 // indirect
111+
k8s.io/klog/v2 v2.130.1 // indirect
112+
k8s.io/utils v0.0.0-20241104100929-3ea5e8cea738 // indirect
113+
sigs.k8s.io/yaml v1.4.0 // indirect
114+
)

0 commit comments

Comments
 (0)